Skip to content

Commit 4090eb5

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

11 files changed

Lines changed: 729 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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
-- This Source Code Form is subject to the terms of the Mozilla Public
2+
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
-- You can obtain one at http://mozilla.org/MPL/2.0/.
4+
--
5+
-- Copyright (c) 2014-2026, Lars Asplund lars.anders.asplund@gmail.com
6+
7+
library vunit_lib;
8+
context vunit_lib.vunit_context;
9+
10+
library foo_lib;
11+
use foo_lib.foo_pkg.all;
12+
13+
entity tb_vunit_pkg is
14+
generic (runner_cfg : string);
15+
end entity;
16+
17+
architecture vunit_test_bench of tb_vunit_pkg is
18+
begin
19+
test_runner : process
20+
begin
21+
test_runner_setup(runner, runner_cfg);
22+
check(foo_pkg_is_present);
23+
test_runner_cleanup(runner);
24+
wait;
25+
end process;
26+
end architecture;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
# You can obtain one at http://mozilla.org/MPL/2.0/.
4+
#
5+
# Copyright (c) 2014-2026, Lars Asplund lars.anders.asplund@gmail.com
6+
7+
raise RuntimeError("This file must not be executed when adding foo as a VUnit package.")
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- This Source Code Form is subject to the terms of the Mozilla Public
2+
-- License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
-- You can obtain one at http://mozilla.org/MPL/2.0/.
4+
--
5+
-- Copyright (c) 2014-2026, Lars Asplund lars.anders.asplund@gmail.com
6+
7+
package foo_pkg is
8+
constant foo_pkg_is_present : boolean := true;
9+
end package;
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# This Source Code Form is subject to the terms of the Mozilla Public
2+
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
3+
# You can obtain one at http://mozilla.org/MPL/2.0/.
4+
#
5+
# Copyright (c) 2014-2026, Lars Asplund lars.anders.asplund@gmail.com
6+
7+
[package]
8+
library = "foo_lib"
9+
[[package.sources]]
10+
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)