本文整理汇总了Python中vunit.project.Project._hash_file_name_of方法的典型用法代码示例。如果您正苦于以下问题:Python Project._hash_file_name_of方法的具体用法?Python Project._hash_file_name_of怎么用?Python Project._hash_file_name_of使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vunit.project.Project
的用法示例。
在下文中一共展示了Project._hash_file_name_of方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestProject
# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import _hash_file_name_of [as 别名]
#.........这里部分代码省略.........
self.assertEqual(len(source_file.design_units), int(not no_parse))
def test_add_source_file_has_no_parse_verilog(self):
for no_parse in (True, False):
project = Project()
file_name = "file.v"
write_file(file_name, """
module mod;
endmodule
""")
project.add_library("lib", "work_path")
source_file = project.add_source_file(file_name,
"lib",
file_type=file_type_of(file_name),
no_parse=no_parse)
self.assertEqual(len(source_file.design_units), int(not no_parse))
def add_source_file(self, library_name, file_name, contents, defines=None):
"""
Convenient wrapper arround project.add_source_file
"""
write_file(file_name, contents)
source_file = self.project.add_source_file(file_name,
library_name,
file_type=file_type_of(file_name),
defines=defines)
return source_file
def hash_file_name_of(self, source_file):
"""
Get the hash file name of a source_file
"""
return self.project._hash_file_name_of(source_file) # pylint: disable=protected-access
def update(self, source_file):
"""
Wrapper arround project.update
"""
self.project.update(source_file)
def assert_should_recompile(self, source_files):
self.assert_count_equal(source_files, self.project.get_files_in_compile_order())
def assert_compiles(self, source_file, before):
"""
Assert that the compile order of source_file is before the file named 'before'.
"""
for src_file in self.project.get_files_in_compile_order():
self.update(src_file)
self.assert_should_recompile([])
tick()
self.update(source_file)
self.assertIn(before, self.project.get_files_in_compile_order())
def assert_not_compiles(self, source_file, before):
"""
Assert that the compile order of source_file is not before the file named 'before'.
"""
for src_file in self.project.get_files_in_compile_order():
self.update(src_file)
self.assert_should_recompile([])
tick()
self.update(source_file)
self.assertNotIn(before, self.project.get_files_in_compile_order())
示例2: TestProject
# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import _hash_file_name_of [as 别名]
#.........这里部分代码省略.........
end architecture;
""")
self.add_source_file("lib", "file2.vhd", """\
entity module2 is
end entity;
architecture arch of module2 is
begin
module1_inst : entity lib.module1;
end architecture;
""")
self.add_source_file("lib", "file3.vhd", """\
entity module3 is
end entity;
architecture arch of module3 is
begin
module1_inst : entity work.module2;
end architecture;
""")
def add_source_file(self, library_name, file_name, contents):
"""
Convenient wrapper arround project.add_source_file
"""
write_file(file_name, contents)
self.project.add_source_file(file_name, library_name, file_type=file_type_of(file_name))
def hash_file_name_of(self, file_name):
"""
Get the hash file name of a file with 'file_name'
"""
return self.project._hash_file_name_of(self.get_source_file(file_name)) # pylint: disable=protected-access
def get_source_file(self, file_name):
"""
Wrapper arround project.get_source_file
"""
return self.project.get_source_file(file_name)
def update(self, file_name):
"""
Wrapper arround project.update
"""
self.project.update(self.get_source_file(file_name))
def assert_should_recompile(self, file_names):
self.assert_count_equal(file_names, [dep.name for dep in self.project.get_files_in_compile_order()])
def assert_compiles(self, file_name, before):
"""
Assert that the compile order of file_name is before the file named 'before'.
"""
for src_file in self.project.get_files_in_compile_order():
self.update(src_file.name)
self.assert_should_recompile([])
tick()
self.update(file_name)
self.assertIn(before, [dep.name for dep in self.project.get_files_in_compile_order()])
def assert_not_compiles(self, file_name, before):
"""
Assert that the compile order of file_name is not before the file named 'before'.
"""
for src_file in self.project.get_files_in_compile_order():
示例3: TestProject
# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import _hash_file_name_of [as 别名]
#.........这里部分代码省略.........
def test_finds_context_dependencies(self):
self.project.add_library("lib", "lib_path")
self.add_source_file("lib", "context.vhd", """
context foo is
end context;
""")
self.project.add_library("lib2", "work_path")
self.add_source_file("lib2", "module.vhd", """
library lib;
context lib.foo;
entity module is
end entity;
architecture arch of module is
begin
end architecture;
""")
self.assert_compiles_before("context.vhd", before="module.vhd")
def test_should_recompile_all_files_initially(self):
self.create_dummy_three_file_project()
self.assert_should_recompile(["file1.vhd", "file2.vhd", "file3.vhd"])
self.assert_should_recompile(["file1.vhd", "file2.vhd", "file3.vhd"])
def test_updating_creates_hash_files(self):
self.create_dummy_three_file_project()
for file_name in ["file1.vhd", "file2.vhd", "file3.vhd"]:
self.update(file_name)
self.assertIn(self.project._hash_file_name_of(self.get_source_file(file_name)), self.stub._files.keys())
def test_should_not_recompile_updated_files(self):
self.create_dummy_three_file_project()
self.update("file1.vhd")
self.assert_should_recompile(["file2.vhd", "file3.vhd"])
self.update("file2.vhd")
self.assert_should_recompile(["file3.vhd"])
self.update("file3.vhd")
self.assert_should_recompile([])
def test_should_recompile_files_affected_by_change(self):
self.create_dummy_three_file_project()
self.update("file1.vhd")
self.update("file2.vhd")
self.update("file3.vhd")
self.assert_should_recompile([])
self.create_dummy_three_file_project()
self.assert_should_recompile([])
self.create_dummy_three_file_project(update_file1=True)
self.assert_should_recompile(["file1.vhd", "file2.vhd", "file3.vhd"])
def test_should_recompile_files_affected_by_change_with_later_timestamp(self):
self.create_dummy_three_file_project()
self.update("file1.vhd")
self.update("file2.vhd")