Skip to content

Commit ab6ba57

Browse files
committed
Added initial support for external package addition.
1 parent a275bbe commit ab6ba57

10 files changed

Lines changed: 685 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ classifiers = [
3636
requires-python = ">=3.10"
3737
dependencies = [
3838
"colorama",
39+
"tomli; python_version < '3.11'",
3940
]
4041

4142
[tool.setuptools]

tests/acceptance/artificial/vhdl/run.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#
55
# Copyright (c) 2014-2026, Lars Asplund lars.anders.asplund@gmail.com
66

7+
import sys
78
from pathlib import Path
89
from glob import glob
910
from vunit import VUnit, VUnitCLI
@@ -164,6 +165,7 @@ def pre_config(output_path):
164165
for idx, (extra_time, fail) in enumerate([(5, False), (2, True)], 1):
165166
tb.add_config(name=f"test_{idx}", pre_config=make_pre_config(idx, extra_time, fail))
166167

168+
167169
def configure_tb_seed(ui):
168170
tb = ui.library("lib").test_bench("tb_seed")
169171

@@ -174,6 +176,12 @@ def configure_tb_seed(ui):
174176
tb.test("test_1").set_generic("expected_seed", "ffa08cd9489aad14")
175177
tb.test("test_2").set_generic("expected_seed", "9a292b3679afd081")
176178

179+
180+
def configure_tb_vunit_pkg(vu):
181+
sys.path.append(str(root.parent / "vunit_pkg"))
182+
vu.add_package("foo")
183+
184+
177185
configure_tb_with_generic_config()
178186
configure_tb_same_sim_all_pass(vu)
179187
configure_tb_set_generic(vu)
@@ -182,6 +190,7 @@ def configure_tb_seed(ui):
182190
configure_tb_no_fail_on_warning(vu)
183191
configure_tb_test_prio(vu)
184192
configure_tb_seed(vu)
193+
configure_tb_vunit_pkg(vu)
185194
lib.entity("tb_no_generic_override").set_generic("g_val", False)
186195
lib.entity("tb_ieee_warning").test("pass").set_sim_option("disable_ieee_warnings", True)
187196
lib.entity("tb_other_file_tests").scan_tests_from_file(str(root / "other_file_tests.vhd"))
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
raise RuntimeError("This file must not be executed when adding foo as a VUnit package.")
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
package foo_pkg is
2+
constant foo_pkg_is_present : boolean := true;
3+
end package;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[package]
2+
library = "foo_lib"
3+
[[package.sources]]
4+
include=["foo_pkg.vhd"]

tests/acceptance/test_artificial.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,13 @@ def test_repeated_seed(self):
107107
],
108108
)
109109

110+
def test_not_executing_package_init_on_package_addition(self):
111+
self.check(self.artificial_run_vhdl, args=["lib.tb_vunit_pkg.all"])
112+
check_report(
113+
self.report_file,
114+
[("passed", "lib.tb_vunit_pkg.all")],
115+
)
116+
110117
def _test_artificial(self, args=None):
111118
"""
112119
Utility function to run and check the result of all test benches
@@ -311,4 +318,5 @@ def test_exit_0_flag(self):
311318
("failed", "lib.tb_test_prio_2.test_2"),
312319
("passed", "lib.tb_seed.test_1"),
313320
("passed", "lib.tb_seed.test_2"),
321+
("passed", "lib.tb_vunit_pkg.all"),
314322
)

0 commit comments

Comments
 (0)