当前位置: 首页>>代码示例>>Python>>正文


Python Project._hash_file_name_of方法代码示例

本文整理汇总了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())
开发者ID:go2sh,项目名称:vunit,代码行数:69,代码来源:test_project.py

示例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():
开发者ID:enzochiau,项目名称:vunit,代码行数:70,代码来源:test_project.py

示例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")
开发者ID:tomasnilefrost,项目名称:vunit,代码行数:70,代码来源:test_project.py


注:本文中的vunit.project.Project._hash_file_name_of方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。