예제 #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)
예제 #2
0
        def test():
            it.assertTrue(it.project.database.paths)

            filename = Path(p.join(TEST_PROJECT, "another_library", "foo.vhd"))
            original_content = open(filename.name, "r").read().split("\n")

            content = "\n".join(original_content[:28] +
                                ["signal another_signal : std_logic;"] +
                                original_content[28:])

            _logger.debug("File content")
            for lnum, line in enumerate(content.split("\n")):
                _logger.debug("%2d| %s", (lnum + 1), line)

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

            logIterable("Diagnostics", diagnostics, _logger.info)

            it.assertTrue(it.project.config_file)

            expected = [
                ObjectIsNeverUsed(
                    filename=filename,
                    line_number=29,
                    column_number=11,
                    object_type="signal",
                    object_name="neat_signal",
                ),
                ObjectIsNeverUsed(
                    filename=filename,
                    line_number=28,
                    column_number=7,
                    object_type="signal",
                    object_name="another_signal",
                ),
            ]

            it.assertCountEqual(diagnostics, expected)
예제 #3
0
        def test():
            filename = Path(
                p.join(TEST_PROJECT, "basic_library", "clock_divider.vhd"))

            it.assertCountEqual(
                it.project.getMessagesByPath(filename),
                [
                    ObjectIsNeverUsed(
                        filename=filename,
                        line_number=26,
                        column_number=11,
                        object_type="signal",
                        object_name="clk_enable_unused",
                    )
                ],
            )
예제 #4
0
        def test():
            filename = p.join(TEST_PROJECT, "another_library", "foo.vhd")

            diagnostics = it.project.getMessagesByPath(Path(filename))

            it.assertIn(
                ObjectIsNeverUsed(
                    filename=Path(filename),
                    line_number=28,
                    column_number=11,
                    object_type="signal",
                    object_name="neat_signal",
                ),
                diagnostics,
            )

            it.assertTrue(it.project.database.paths)
예제 #5
0
def getStaticMessages(lines):
    # type: (Tuple[str, ...]) -> List[StaticCheckerDiag]
    "VHDL static checking"
    objects = _getObjectsFromText(lines)

    result = []  # type: List[StaticCheckerDiag]

    for _object in _getUnusedObjects(lines, objects.keys()):
        obj_dict = objects[_object]
        result += [
            ObjectIsNeverUsed(
                line_number=obj_dict["lnum"],
                column_number=obj_dict["start"],
                object_type=obj_dict["type"],
                object_name=_object,
            )
        ]

    return result + _getCommentTags(lines) + list(_getMiscChecks(objects))
예제 #6
0
        def test():
            filename = p.relpath(
                p.join(TEST_PROJECT, "another_library", "foo.vhd"),
                str(it.project.root_dir),
            )

            it.assertFalse(p.isabs(filename))

            diagnostics = it.project.getMessagesByPath(Path(filename))

            it.assertIn(
                ObjectIsNeverUsed(
                    filename=Path(
                        p.join(TEST_PROJECT, "another_library", "foo.vhd")),
                    line_number=28,
                    column_number=11,
                    object_type="signal",
                    object_name="neat_signal",
                ),
                diagnostics,
            )