Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion edalize/vunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def configure_main(self):
# vunit does not allow empty library name or 'work', so we use `vunit_test_runner_lib`:
libraries = OrderedDict()

core_files = {}
core_files = {core: [] for core in self.edam.get("dependencies", {})}
depend = {}
for f in src_files:
lib = f.logical_name if f.logical_name else "vunit_test_runner_lib"
Expand Down
56 changes: 56 additions & 0 deletions tests/test_vunit.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,62 @@ def subprocess_intercept(args, **kwargs):
hooks.main.assert_called_with(vu_mock)


@pytest.mark.parametrize("with_source_files", [True, False])
def test_vunit_empty_cores(tmp_path, monkeypatch, with_source_files):
import runpy
import sys
from types import ModuleType

from edalize.edatool import get_edatool

sources = {
"design.vhd": MagicMock(),
"dependency.vhd": MagicMock(),
}
files = (
[
{"name": name, "file_type": "vhdlSource", "core": core}
for name, core in (
("design.vhd", "design"),
("dependency.vhd", "dependency"),
)
]
if with_source_files
else []
)
edam = {
"name": "empty_cores",
"toplevel": "top",
"files": files,
"dependencies": {
"empty": [],
"dependency": [],
"design": ["dependency", "empty"],
},
}
backend = get_edatool("vunit")(edam=edam, work_root=str(tmp_path))
backend.configure()

hooks = MagicMock()
vu = hooks.create.return_value
vu.add_library.return_value.add_source_file.side_effect = lambda name: sources[name]
hooks_module = ModuleType("edalize.vunit_hooks")
hooks_module.VUnitRunner = MagicMock(return_value=hooks)
monkeypatch.setitem(sys.modules, "edalize.vunit_hooks", hooks_module)

result = runpy.run_path(str(tmp_path / "run.py"))

assert result["core_files"]["empty"] == []
if with_source_files:
sources["design.vhd"].add_dependency_on.assert_any_call(
[sources["dependency.vhd"]]
)
sources["dependency.vhd"].add_dependency_on.assert_not_called()
else:
vu.add_library.assert_not_called()
hooks.main.assert_called_once_with(vu)


if __name__ == "__main__":
from os.path import dirname
import sys
Expand Down