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


Python Project.get_files_in_compile_order方法代码示例

本文整理汇总了Python中vunit.project.Project.get_files_in_compile_order方法的典型用法代码示例。如果您正苦于以下问题:Python Project.get_files_in_compile_order方法的具体用法?Python Project.get_files_in_compile_order怎么用?Python Project.get_files_in_compile_order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在vunit.project.Project的用法示例。


在下文中一共展示了Project.get_files_in_compile_order方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_compile_source_files_run_command_error

# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import get_files_in_compile_order [as 别名]
    def test_compile_source_files_run_command_error(self):
        simif = create_simulator_interface()
        simif.compile_source_file_command.return_value = ["command"]
        project = Project()
        project.add_library("lib", "lib_path")
        write_file("file.vhd", "")
        source_file = project.add_source_file("file.vhd", "lib", file_type="vhdl")

        with mock.patch("vunit.simulator_interface.run_command", autospec=True) as run_command:
            run_command.return_value = False
            self.assertRaises(CompileError, simif.compile_source_files, project)
            run_command.assert_called_once_with(["command"])
        self.assertEqual(project.get_files_in_compile_order(incremental=True), [source_file])
开发者ID:KevinKes,项目名称:vunit,代码行数:15,代码来源:test_simulator_interface.py

示例2: test_compile_source_files_create_command_error

# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import get_files_in_compile_order [as 别名]
    def test_compile_source_files_create_command_error(self):
        simif = create_simulator_interface()
        project = Project()
        project.add_library("lib", "lib_path")
        write_file("file.vhd", "")
        source_file = project.add_source_file("file.vhd", "lib", file_type="vhdl")

        with mock.patch("vunit.simulator_interface.run_command", autospec=True) as run_command:
            run_command.return_value = True

            def raise_compile_error(*args, **kwargs):
                raise CompileError

            simif.compile_source_file_command.side_effect = raise_compile_error
            self.assertRaises(CompileError, simif.compile_source_files, project)
        self.assertEqual(project.get_files_in_compile_order(incremental=True), [source_file])
开发者ID:KevinKes,项目名称:vunit,代码行数:18,代码来源:test_simulator_interface.py

示例3: test_compile_source_files

# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import get_files_in_compile_order [as 别名]
    def test_compile_source_files(self):
        simif = create_simulator_interface()
        simif.compile_source_file_command.side_effect = iter([["command1"], ["command2"]])
        project = Project()
        project.add_library("lib", "lib_path")
        write_file("file1.vhd", "")
        file1 = project.add_source_file("file1.vhd", "lib", file_type="vhdl")
        write_file("file2.vhd", "")
        file2 = project.add_source_file("file2.vhd", "lib", file_type="vhdl")
        project.add_manual_dependency(file2, depends_on=file1)

        with mock.patch("vunit.simulator_interface.run_command", autospec=True) as run_command:
            run_command.side_effect = iter([True, True])
            simif.compile_source_files(project)
            run_command.assert_has_calls([mock.call(["command1"]),
                                          mock.call(["command2"])])
        self.assertEqual(project.get_files_in_compile_order(incremental=True), [])
开发者ID:KevinKes,项目名称:vunit,代码行数:19,代码来源:test_simulator_interface.py

示例4: test_compile_source_files_continue_on_error

# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import get_files_in_compile_order [as 别名]
    def test_compile_source_files_continue_on_error(self):
        simif = create_simulator_interface()

        project = Project()
        project.add_library("lib", "lib_path")
        write_file("file1.vhd", "")
        file1 = project.add_source_file("file1.vhd", "lib", file_type="vhdl")
        write_file("file2.vhd", "")
        file2 = project.add_source_file("file2.vhd", "lib", file_type="vhdl")
        write_file("file3.vhd", "")
        file3 = project.add_source_file("file3.vhd", "lib", file_type="vhdl")
        project.add_manual_dependency(file2, depends_on=file1)

        def compile_source_file_command(source_file):
            if source_file == file1:
                return ["command1"]
            elif source_file == file2:
                return ["command2"]
            elif source_file == file3:
                return ["command3"]

        def run_command_side_effect(command):
            if command == ["command1"]:
                return False
            else:
                return True

        simif.compile_source_file_command.side_effect = compile_source_file_command

        with mock.patch("vunit.simulator_interface.run_command", autospec=True) as run_command:
            run_command.side_effect = run_command_side_effect
            self.assertRaises(CompileError, simif.compile_source_files, project, continue_on_error=True)
            self.assertEqual(len(run_command.mock_calls), 2)
            run_command.assert_has_calls([mock.call(["command1"]),
                                          mock.call(["command3"])], any_order=True)
        self.assertEqual(project.get_files_in_compile_order(incremental=True), [file1, file2])
开发者ID:KevinKes,项目名称:vunit,代码行数:38,代码来源:test_simulator_interface.py

示例5: TestProject

# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import get_files_in_compile_order [as 别名]

#.........这里部分代码省略.........
  inst : comp;
end architecture;
""")

        self.assert_compiles("ent_a1.vhd", before="top1.vhd")
        self.assert_compiles("ent_a2.vhd", before="top2.vhd")

    @mock.patch("vunit.project.LOGGER")
    def test_warning_on_missing_specific_architecture_reference(self, mock_logger):
        self.project.add_library("lib", "lib_path")

        self.add_source_file("lib", "ent.vhd", """
entity ent is
end entity;
""")

        self.add_source_file("lib", "arch.vhd", """
architecture a1 of ent is
begin
end architecture;
""")

        self.add_source_file("lib", "top.vhd", """
entity top1 is
end entity;

architecture a of top1 is
begin
  inst1 : entity work.ent(a1);
  inst2 : entity work.ent(a2); # Missing
end architecture;
""")

        self.project.get_files_in_compile_order()
        warning_calls = mock_logger.warning.call_args_list
        log_msg = warning_calls[0][0][0] % warning_calls[0][0][1:]
        self.assertEqual(len(warning_calls), 1)
        self.assertIn("top.vhd", log_msg)
        self.assertIn("a2", log_msg)
        self.assertIn("lib.ent", log_msg)

    def _test_warning_on_duplicate(self, mock_logger, code, message):
        """
        Utility function to test adding the same duplicate code under
        file.vhd and file_copy.vhd where the duplication should cause a warning message.
        """
        self.add_source_file("lib", "file.vhd", code)

        warning_calls = mock_logger.warning.call_args_list

        self.assertEqual(len(warning_calls), 0)

        self.add_source_file("lib", "file_copy.vhd", code)

        warning_calls = mock_logger.warning.call_args_list
        self.assertEqual(len(warning_calls), 1)

        log_msg = warning_calls[0][0][0] % warning_calls[0][0][1:]
        self.assertEqual(log_msg, message)

    @mock.patch("vunit.project.LOGGER")
    def test_warning_on_duplicate_entity(self, mock_logger):
        self.project.add_library("lib", "lib_path")
        self._test_warning_on_duplicate(
            mock_logger, """
entity ent is
开发者ID:enzochiau,项目名称:vunit,代码行数:70,代码来源:test_project.py

示例6: TestProject

# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import get_files_in_compile_order [as 别名]

#.........这里部分代码省略.........
  inst : comp;
end architecture;
""")

        self.assert_compiles(ent_a1, before=top1)
        self.assert_compiles(ent_a2, before=top2)

    @mock.patch("vunit.project.LOGGER")
    def test_warning_on_missing_specific_architecture_reference(self, mock_logger):
        self.project.add_library("lib", "lib_path")

        self.add_source_file("lib", "ent.vhd", """
entity ent is
end entity;
""")

        self.add_source_file("lib", "arch.vhd", """
architecture a1 of ent is
begin
end architecture;
""")

        self.add_source_file("lib", "top.vhd", """
entity top1 is
end entity;

architecture a of top1 is
begin
  inst1 : entity work.ent(a1);
  inst2 : entity work.ent(a2); # Missing
end architecture;
""")

        self.project.get_files_in_compile_order()
        warning_calls = mock_logger.warning.call_args_list
        log_msg = warning_calls[0][0][0] % warning_calls[0][0][1:]
        self.assertEqual(len(warning_calls), 1)
        self.assertIn("top.vhd", log_msg)
        self.assertIn("a2", log_msg)
        self.assertIn("lib.ent", log_msg)

    def _test_warning_on_duplicate(self, mock_logger, code, message):
        """
        Utility function to test adding the same duplicate code under
        file.vhd and file_copy.vhd where the duplication should cause a warning message.
        """
        self.add_source_file("lib", "file.vhd", code)

        warning_calls = mock_logger.warning.call_args_list

        self.assertEqual(len(warning_calls), 0)

        self.add_source_file("lib", "file_copy.vhd", code)

        warning_calls = mock_logger.warning.call_args_list
        self.assertEqual(len(warning_calls), 1)

        log_msg = warning_calls[0][0][0] % warning_calls[0][0][1:]
        self.assertEqual(log_msg, message)

    @mock.patch("vunit.project.LOGGER")
    def test_warning_on_duplicate_entity(self, mock_logger):
        self.project.add_library("lib", "lib_path")
        self._test_warning_on_duplicate(
            mock_logger, """
entity ent is
开发者ID:go2sh,项目名称:vunit,代码行数:70,代码来源:test_project.py

示例7: TestProject

# 需要导入模块: from vunit.project import Project [as 别名]
# 或者: from vunit.project.Project import get_files_in_compile_order [as 别名]

#.........这里部分代码省略.........
        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):
        self.stub.write_file(file_name, contents)
        self.project.add_source_file(file_name, library_name)

    def get_source_file(self, file_name):
        return self.project._source_files[file_name]

    def update(self, file_name):
        self.project.update(self.project._source_files[file_name])

    def assert_should_recompile(self, file_names):
        self.assertCountEqual(file_names, [dep.name for dep in self.project.get_files_in_compile_order()])

    def assert_compiles_before(self, file_name, before):
        for src_file in self.project.get_files_in_compile_order():
            self.update(src_file.name)
        self.assert_should_recompile([])
        self.stub.tick()
        self.update(file_name)
        self.assertIn(before, [dep.name for dep in self.project.get_files_in_compile_order()])

    def assert_has_package_body(self, source_file_name, package_name):
        unit = self._find_design_unit(source_file_name,
                                      "package body",
                                      "package body for " + package_name,
                                      False, package_name)
        self.assertIsNotNone(unit)

    def assert_has_package(self, source_file_name, name):
        unit = self._find_design_unit(source_file_name,
                                      "package",
                                      name)
        self.assertIsNotNone(unit)

    def assert_has_entity(self, source_file_name, name, 
                          generic_names=None,
                          architecture_names=None):
        source_file = self.project._source_files[source_file_name]
        generic_names = [] if generic_names is None else generic_names
        architecture_names = [] if architecture_names is None else architecture_names

        for entity in source_file.library.get_entities():
            if entity.name == name:
                self.assertCountEqual(entity.generic_names, generic_names)
开发者ID:tomasnilefrost,项目名称:vunit,代码行数:70,代码来源:test_project.py


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