VUnit/vunit

Provide public API for finding dependent testbench

javValverde opened this issue · 0 comments

As discussed in gitter (sorry I don't know how to link the conversation), I want to know which testbenches depend on some desired VHDL/Verilog files.
This code does exactly that, but using private methods:

vu = VUnit.from_argv()

# Add source files to your project here

project = vu._project
dependency_graph = project.create_dependency_graph()
my_files = ["absolute/path/to/file1.vhd", ...]
source_files = [f for f in project.get_source_files_in_order() if f.name in my_files]
dependent_files = [f.name for f in project._get_affected_files(source_files, dependency_graph.get_dependent)]
testbench_files = [tb._test_bench.design_unit.source_file.name for lib in vu.get_libraries() for tb in lib.get_test_benches(allow_empty=True)]
dependent_testbench_files = [f for f in testbench_files if f in dependent_files]

It would be nice to have a public (and stable) API for this use case