Add project configuration and build tools
- Introduced new scripts for project generation and synthesis (dodo.py, generate_prj.py, generate_scr.py, run_xst.py). - Implemented configuration parsing for VHDL sources and project settings (config.py). - Added default configuration values (defaults.py). - Updated .gitignore to include additional file types. - Created test cases for project generation and configuration parsing (test_generate_prj.py, test_generate_scr.py, test_project_cfg.py).
This commit is contained in:
72
tests/test_config.py
Normal file
72
tests/test_config.py
Normal file
@@ -0,0 +1,72 @@
|
||||
from tools.config import parse_vhdl_ls_toml
|
||||
from pathlib import Path
|
||||
import tempfile
|
||||
import textwrap
|
||||
import pytest
|
||||
|
||||
|
||||
def test_parsing_skips_third_party_libs():
|
||||
content = textwrap.dedent("""
|
||||
[libraries.lib]
|
||||
files = ["src/main.vhd"]
|
||||
|
||||
[libraries.XILINX]
|
||||
files = ["/opt/Xilinx/abc.vhd"]
|
||||
is_third_party = true
|
||||
""")
|
||||
with tempfile.NamedTemporaryFile("w+", suffix=".toml", delete=False) as f:
|
||||
f.write(content)
|
||||
f.flush()
|
||||
result = parse_vhdl_ls_toml(Path(f.name))
|
||||
|
||||
assert "work" in result
|
||||
assert "XILINX" not in result
|
||||
assert result["work"] == [Path("src/main.vhd")]
|
||||
|
||||
|
||||
def test_parsing_multiple_libraries():
|
||||
content = textwrap.dedent("""
|
||||
[libraries.lib]
|
||||
files = ["src/foo.vhd", "src/bar.vhd"]
|
||||
|
||||
[libraries.myip]
|
||||
files = ["ipcore/top.vhd"]
|
||||
""")
|
||||
with tempfile.NamedTemporaryFile("w+", suffix=".toml", delete=False) as f:
|
||||
f.write(content)
|
||||
f.flush()
|
||||
result = parse_vhdl_ls_toml(Path(f.name))
|
||||
|
||||
assert "work" in result
|
||||
assert "myip" in result
|
||||
assert result["work"] == [Path("src/foo.vhd"), Path("src/bar.vhd")]
|
||||
assert result["myip"] == [Path("ipcore/top.vhd")]
|
||||
|
||||
|
||||
def test_empty_toml_file():
|
||||
with tempfile.NamedTemporaryFile("w+", suffix=".toml", delete=False) as f:
|
||||
f.write("") # Empty file
|
||||
f.flush()
|
||||
result = parse_vhdl_ls_toml(Path(f.name))
|
||||
|
||||
assert result == {}
|
||||
|
||||
|
||||
def test_missing_file_raises_error():
|
||||
with pytest.raises(FileNotFoundError):
|
||||
parse_vhdl_ls_toml(Path("nonexistent.toml"))
|
||||
|
||||
|
||||
def test_libname_translation_to_work():
|
||||
content = textwrap.dedent("""
|
||||
[libraries.lib]
|
||||
files = ["src/xyz.vhd"]
|
||||
""")
|
||||
with tempfile.NamedTemporaryFile("w+", suffix=".toml", delete=False) as f:
|
||||
f.write(content)
|
||||
f.flush()
|
||||
result = parse_vhdl_ls_toml(Path(f.name))
|
||||
|
||||
assert "work" in result
|
||||
assert "lib" not in result
|
||||
assert result["work"] == [Path("src/xyz.vhd")]
|
Reference in New Issue
Block a user