示例#1
0
        def test():
            filename = Path(p.join(TEST_PROJECT, "another_library", "foo.vhd"))

            code = open(str(filename), "r").read().split("\n")

            code[28] = "-- " + code[28]

            writeListToFile(str(filename), code)

            diagnostics = it.project.getMessagesByPath(filename)

            try:
                it.assertNotIn(
                    ObjectIsNeverUsed(
                        object_type="constant",
                        object_name="ADDR_WIDTH",
                        line_number=28,
                        column_number=13,
                    ),
                    diagnostics,
                )
            finally:
                # Remove the comment we added
                code[28] = code[28][3:]
                writeListToFile(str(filename), code)
    def setUpClass(cls):
        cls.filename = NamedTemporaryFile(suffix="." + cls.filetype).name

        writeListToFile(
            cls.filename,
            [
                '`include "some/include"',
                "",
                "import some_package::*;",
                "import  another_package :: some_name ;",
                "",
                "module clock_divider",
                "    #(parameter DIVISION = 5)",
                "    (// Usual ports",
                "    input clk,",
                "    input rst,",
                "    // Output clock divided",
                "    output       clk_div);",
                "   localparam foo::bar = std::randomize(cycles);",
                "endmodule",
                "",
                "package \\m$gPkg! ;",
                "  integer  errCnt  = 0;",
                "  integer  warnCnt = 0;",
                "endpackage",
                "",
            ],
        )

        cls.source = VerilogParser(Path(cls.filename))
示例#3
0
        def test():
            filename = Path(p.join(TEST_TEMP_PATH, "some_file.vhd"))
            writeListToFile(str(filename), ["library some_lib;"])

            diagnostics = it.project.getMessagesByPath(filename)

            _logger.info("Records found:")
            for diagnostic in diagnostics:
                _logger.info(diagnostic)

            it.assertIn(PathNotInProjectFile(filename), diagnostics)

            # The builder should find other issues as well...
            it.assertTrue(
                len(diagnostics) > 1,
                "It was expected that the builder added some "
                "message here indicating an error",
            )
示例#4
0
        def test():
            filename = Path(p.join(TEST_TEMP_PATH, "some_file.vhd"))
            writeListToFile(str(filename), ["entity some_entity is end;"])

            content = "\n".join([
                "library work;", "use work.all;", "entity some_entity is end;"
            ])

            diagnostics = it.project.getMessagesWithText(filename, content)

            _logger.debug("Records received:")
            for diagnostic in diagnostics:
                _logger.debug("- %s", diagnostic)

            it.assertIn(
                LibraryShouldBeOmited(library="work",
                                      filename=filename,
                                      column_number=8,
                                      line_number=0),
                diagnostics,
            )

            it.assertIn(PathNotInProjectFile(filename), diagnostics)