diff --git a/README.rst b/README.rst index 77dd723f..49286506 100644 --- a/README.rst +++ b/README.rst @@ -324,6 +324,17 @@ For example, "run-time check" is the family of Code Prover and "defect" is the f The value of that key is a list, which contains the name of the column to check as a key and the value of that column to check together with ``min`` and ``max`` values. +All results with one of the following statuses are discarded altogether: + +- Justified +- Not a Defect + +These statuses indicate that you have given due consideration and justified that result, as described +in `Polyspace's documentation about results`_. +The status "No Action Planned" is not treated differently because this is the default status for annotations. + +.. _`Polyspace's documentation about results`: https://nl.mathworks.com/help/polyspace_access/ug/fix-or-comment-polyspace-results-web-browser.html + Example Checks ^^^^^^^^^^^^^^ diff --git a/src/mlx/warnings/polyspace_checker.py b/src/mlx/warnings/polyspace_checker.py index d7ec3c97..f7e37b86 100644 --- a/src/mlx/warnings/polyspace_checker.py +++ b/src/mlx/warnings/polyspace_checker.py @@ -154,7 +154,7 @@ def parse_config(self, config): "'Family' column. These dicts need to consist 3 key-value pairs (Note: if 'min' or " "'max' is not defined, it will get the default value of 0):\n" "{\n : ,\n min: ,\n max: \n};" - f"got {column_name} as column_name and {check_value} as value_to_check" + f"got {column_name!r} as column_name and {check_value!r} as value_to_check" ) for checker in self.checkers: checker.cq_enabled = self.cq_enabled @@ -179,8 +179,6 @@ def __init__(self, family_value, column_name, check_value, **kwargs): family_value (str): The value to search for in the 'Family' column column_name (str): The name of the column check_value (str): The value to check in the column - minimum (int): The minimum amount the check_value can occur - maximum (int): The maximum amount the check_value can occur """ super().__init__(**kwargs) self.family_value = family_value @@ -243,7 +241,7 @@ def add_code_quality_finding(self, row): if "line" in row: finding["location"]["positions"]["begin"]["line"] = row["line"] if "col" in row: - finding["location"]["positions"]["begin"]["column"] = row["line"] + finding["location"]["positions"]["begin"]["column"] = row["col"] finding["description"] = description exclude = ("new", "status", "severity", "comment", "key") row_without_key = [value for key, value in row.items() if key not in exclude] @@ -258,13 +256,17 @@ def check(self, content): content (dict): The row of the TSV file ''' if content[self.column_name].lower() == self.check_value: - tab_sep_string = "\t".join(content.values()) - if not self._is_excluded(tab_sep_string): - self.count = self.count + 1 - self.counted_warnings.append('family: {} -> {}: {}'.format( - self.family_value, - self.column_name, - self.check_value - )) - if self.cq_enabled and content["color"].lower() != "green": - self.add_code_quality_finding(content) + if content["status"].lower() in ["not a defect", "justified"]: + self.print_when_verbose("Excluded row {!r} because the status is 'Not a defect' or 'Justified'" + .format(content)) + else: + tab_sep_string = "\t".join(content.values()) + if not self._is_excluded(tab_sep_string): + self.count = self.count + 1 + self.counted_warnings.append('family: {} -> {}: {}'.format( + self.family_value, + self.column_name, + self.check_value + )) + if self.cq_enabled and content["color"].lower() != "green": + self.add_code_quality_finding(content) diff --git a/src/mlx/warnings/warnings.py b/src/mlx/warnings/warnings.py index 948c5c2d..634fd56e 100644 --- a/src/mlx/warnings/warnings.py +++ b/src/mlx/warnings/warnings.py @@ -5,12 +5,10 @@ import errno import glob import json -import os import subprocess import sys from importlib.metadata import distribution from pathlib import Path -from string import Template from ruamel.yaml import YAML @@ -23,26 +21,6 @@ __version__ = distribution('mlx.warnings').version -def substitute_envvar(checker_config, keys): - """Modifies configuration for checker in-place, resolving any environment variables for ``keys`` - - Args: - checker_config (dict): Configuration for a specific WarningsChecker - keys (set): Set of keys to process the value of - - Raises: - WarningsConfigError: Failed to find an environment variable - """ - for key in keys: - if key in checker_config and isinstance(checker_config[key], str): - template_obj = Template(checker_config[key]) - try: - checker_config[key] = template_obj.substitute(os.environ) - except KeyError as err: - raise WarningsConfigError(f"Failed to find environment variable {err} for configuration value {key!r}")\ - from None - - class WarningsPlugin: def __init__(self, verbose=False, config_file=None, cq_enabled=False): @@ -229,7 +207,6 @@ def config_parser(self, config): try: checker_config = config[checker.name] if bool(checker_config['enabled']): - substitute_envvar(checker_config, {'min', 'max'}) self.activate_checker(checker) checker.parse_config(checker_config) print("Config parsing for {name} completed".format(name=checker.name)) diff --git a/src/mlx/warnings/warnings_checker.py b/src/mlx/warnings/warnings_checker.py index 8a655031..23d87e70 100644 --- a/src/mlx/warnings/warnings_checker.py +++ b/src/mlx/warnings/warnings_checker.py @@ -6,6 +6,26 @@ from .exceptions import WarningsConfigError +def substitute_envvar(checker_config, keys): + """Modifies configuration for checker inplace, resolving any environment variables for ``keys`` + + Args: + checker_config (dict): Configuration for a specific WarningsChecker + keys (set): Set of keys to process the value of + + Raises: + WarningsConfigError: Failed to find an environment variable + """ + for key in keys: + if key in checker_config and isinstance(checker_config[key], str): + template_obj = Template(checker_config[key]) + try: + checker_config[key] = template_obj.substitute(os.environ) + except KeyError as err: + raise WarningsConfigError(f"Failed to find environment variable {err} for configuration value {key!r}")\ + from None + + class WarningsChecker: name = 'checker' @@ -156,6 +176,7 @@ def print_when_verbose(self, message): print(message) def parse_config(self, config): + substitute_envvar(config, {'min', 'max'}) self.maximum = int(config['max']) self.minimum = int(config['min']) self.add_patterns(config.get("exclude"), self.exclude_patterns) diff --git a/tests/test_in/config_example_polyspace_exclude.json b/tests/test_in/config_example_polyspace_exclude.json index 2707d066..27ac3fae 100644 --- a/tests/test_in/config_example_polyspace_exclude.json +++ b/tests/test_in/config_example_polyspace_exclude.json @@ -36,8 +36,8 @@ "run-time check": [ { "color": "red", - "min": 0, - "max": 0 + "min": "$MIN_POLY_WARNINGS", + "max": "${MAX_POLY_WARNINGS}" }, { "color": "orange", diff --git a/tests/test_in/config_example_robot.json b/tests/test_in/config_example_robot.json index 86f74c5a..1bc6ef96 100644 --- a/tests/test_in/config_example_robot.json +++ b/tests/test_in/config_example_robot.json @@ -45,8 +45,8 @@ }, { "name": "b4d su1te name", - "min": 0, - "max": 0 + "min": "$MIN_ROBOT_WARNINGS", + "max": "${MAX_ROBOT_WARNINGS}" } ] }, diff --git a/tests/test_in/polyspace.tsv b/tests/test_in/polyspace.tsv index a7c04cbf..b90473b0 100644 --- a/tests/test_in/polyspace.tsv +++ b/tests/test_in/polyspace.tsv @@ -25,20 +25,20 @@ ID Family Group Color New Check Information Function File Status Severity Commen 22036 Run-time Check Numerical Green no Overflow dummy_function() dummy_file_name.c Unreviewed Unset C4992326D32B4698C491 6 4 22065 Run-time Check Data flow Green no Non-initialized local variable dummy_function() dummy_file_name.c Unreviewed Unset C49953E693A45698C489 5 5 22035 Run-time Check Data flow Green no Non-initialized local variable dummy_function() dummy_file_name.c Unreviewed Unset C499232693A45698C491 5 6 -21989 Run-time Check Numerical Green no Overflow dummy_function() dummy_file_name.c Unreviewed Unset C4997327D32B4698C881 6 7 +21989 Run-time Check Numerical Green no Overflow dummy_function() dummy_file_name.c Not a defect Unset C4997327D32B4698C881 6 7 19928 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 62C8B1F4CA9126336A 6 8 -19962 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 62D8A9F4CA91263472 7 9 +19962 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Not a defect Unset 62D8A9F4CA91263472 7 9 19526 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66C899F4CA9126316A 7 10 19424 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.h Unreviewed Unset 62E489F4CA91263262 6 11 -19429 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.h Unreviewed Unset 62E4A1F4CA91263162 6 2 +19429 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.h Justified Unset 62E4A1F4CA91263162 6 2 19442 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.h Unreviewed Unset 62C091F4CA91263170 7 3 -19450 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.h Unreviewed Unset 62C091F4CA91263170 7 3 +19450 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.h Justified Unset 62C091F4CA91263170 7 3 19375 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66C089F4CA9126326C 8 4 19378 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66C091F4CA9126316E 8 5 19377 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66C091F4CA9126336A 7 6 19357 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66C8A9F4CA91263368 7 7 19352 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66C8A9F4CA91263760 8 8 -19351 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66C8A9F4CA91263862 8 9 +19351 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Justified Unset 66C8A9F4CA91263862 8 9 19355 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66C8A9F4CA91263962 9 10 19354 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset CC9153E995234C62C091 9 11 19358 Run-time Check Numerical Orange no Overflow Origin: Path related issue dummy_function() dummy_file_name.c Unreviewed Unset CC9153E995234C62C0C1 8 3 @@ -46,7 +46,7 @@ ID Family Group Color New Check Information Function File Status Severity Commen 19349 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66C8C1F4CA91263262 9 5 19345 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66C8C1F4CA91263470 9 6 19344 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66C8C1F4CA91263572 10 7 -19339 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66CC91F4CA91263464 10 8 +19339 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Not a defect Unset 66CC91F4CA91263464 10 8 19338 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66CC91F4CA91263468 9 9 19336 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset 66CC91F4CA91263970 9 10 19335 Run-time Check Numerical Orange no Overflow dummy_function() dummy_file_name.c Unreviewed Unset CC9923E995234C62C0C9 10 11 diff --git a/tests/test_in/polyspace_code_quality.json b/tests/test_in/polyspace_code_quality.json index a3635430..652d9ee0 100644 --- a/tests/test_in/polyspace_code_quality.json +++ b/tests/test_in/polyspace_code_quality.json @@ -6,7 +6,7 @@ "positions": { "begin": { "line": "6", - "column": "6" + "column": "8" } } }, @@ -20,21 +20,7 @@ "positions": { "begin": { "line": "7", - "column": "7" - } - } - }, - "description": "Polyspace: Overflow", - "fingerprint": "29a5e4588709eb7271a30605d4fd3bd3" - }, - { - "severity": "major", - "location": { - "path": "dummy_file_name.c", - "positions": { - "begin": { - "line": "7", - "column": "7" + "column": "10" } } }, @@ -48,27 +34,13 @@ "positions": { "begin": { "line": "6", - "column": "6" + "column": "11" } } }, "description": "Polyspace: Overflow", "fingerprint": "839e418eda6b091c2413aa0722796fb9" }, - { - "severity": "major", - "location": { - "path": "dummy_file_name.h", - "positions": { - "begin": { - "line": "6", - "column": "6" - } - } - }, - "description": "Polyspace: Overflow", - "fingerprint": "cabd96c885bd6d9ed3fe867b227e8128" - }, { "severity": "major", "location": { @@ -76,27 +48,13 @@ "positions": { "begin": { "line": "7", - "column": "7" + "column": "3" } } }, "description": "Polyspace: Overflow", "fingerprint": "1961351c7f028d02202f915a6d36c658" }, - { - "severity": "major", - "location": { - "path": "dummy_file_name.h", - "positions": { - "begin": { - "line": "7", - "column": "7" - } - } - }, - "description": "Polyspace: Overflow", - "fingerprint": "fb6455c4794157cb304be4106e115e35" - }, { "severity": "major", "location": { @@ -104,7 +62,7 @@ "positions": { "begin": { "line": "8", - "column": "8" + "column": "4" } } }, @@ -118,7 +76,7 @@ "positions": { "begin": { "line": "8", - "column": "8" + "column": "5" } } }, @@ -132,7 +90,7 @@ "positions": { "begin": { "line": "7", - "column": "7" + "column": "6" } } }, @@ -167,20 +125,6 @@ "description": "Polyspace: Overflow", "fingerprint": "e790d2d7f4e8fc2fb244ab0f74beca64" }, - { - "severity": "major", - "location": { - "path": "dummy_file_name.c", - "positions": { - "begin": { - "line": "8", - "column": "8" - } - } - }, - "description": "Polyspace: Overflow", - "fingerprint": "2848e52a5925a6e7d35aacf6cbf5afed" - }, { "severity": "major", "location": { @@ -188,7 +132,7 @@ "positions": { "begin": { "line": "9", - "column": "9" + "column": "10" } } }, @@ -202,7 +146,7 @@ "positions": { "begin": { "line": "9", - "column": "9" + "column": "11" } } }, @@ -216,7 +160,7 @@ "positions": { "begin": { "line": "8", - "column": "8" + "column": "3" } } }, @@ -230,7 +174,7 @@ "positions": { "begin": { "line": "8", - "column": "8" + "column": "4" } } }, @@ -244,7 +188,7 @@ "positions": { "begin": { "line": "9", - "column": "9" + "column": "5" } } }, @@ -258,7 +202,7 @@ "positions": { "begin": { "line": "9", - "column": "9" + "column": "6" } } }, @@ -272,27 +216,13 @@ "positions": { "begin": { "line": "10", - "column": "10" + "column": "7" } } }, "description": "Polyspace: Overflow", "fingerprint": "591d152475bd60b07e0e7f00ec000229" }, - { - "severity": "major", - "location": { - "path": "dummy_file_name.c", - "positions": { - "begin": { - "line": "10", - "column": "10" - } - } - }, - "description": "Polyspace: Overflow", - "fingerprint": "c1886be8c04e07b85f86f2571f0fa03d" - }, { "severity": "major", "location": { @@ -314,7 +244,7 @@ "positions": { "begin": { "line": "9", - "column": "9" + "column": "10" } } }, @@ -328,7 +258,7 @@ "positions": { "begin": { "line": "10", - "column": "10" + "column": "11" } } }, @@ -342,7 +272,7 @@ "positions": { "begin": { "line": "15", - "column": "15" + "column": "5" } } }, @@ -356,7 +286,7 @@ "positions": { "begin": { "line": "15", - "column": "15" + "column": "6" } } }, @@ -370,7 +300,7 @@ "positions": { "begin": { "line": "16", - "column": "16" + "column": "7" } } }, @@ -384,7 +314,7 @@ "positions": { "begin": { "line": "16", - "column": "16" + "column": "8" } } }, @@ -398,7 +328,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "9" } } }, @@ -412,7 +342,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "10" } } }, @@ -426,7 +356,7 @@ "positions": { "begin": { "line": "16", - "column": "16" + "column": "11" } } }, @@ -440,7 +370,7 @@ "positions": { "begin": { "line": "16", - "column": "16" + "column": "12" } } }, @@ -454,7 +384,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "13" } } }, @@ -468,7 +398,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "14" } } }, @@ -482,7 +412,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "5" } } }, @@ -496,7 +426,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "6" } } }, @@ -510,7 +440,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "6" } } }, @@ -524,7 +454,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "7" } } }, @@ -538,7 +468,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "8" } } }, @@ -552,7 +482,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "9" } } }, @@ -566,7 +496,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "10" } } }, @@ -580,7 +510,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "11" } } }, @@ -594,7 +524,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "12" } } }, @@ -608,7 +538,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "13" } } }, @@ -622,7 +552,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "14" } } }, @@ -636,7 +566,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "6" } } }, @@ -650,7 +580,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "7" } } }, @@ -664,7 +594,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "8" } } }, @@ -678,7 +608,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "9" } } }, @@ -692,7 +622,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "10" } } }, @@ -706,7 +636,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "11" } } }, @@ -720,7 +650,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "12" } } }, @@ -734,7 +664,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "13" } } }, @@ -748,7 +678,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "14" } } }, @@ -762,7 +692,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "15" } } }, @@ -776,7 +706,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "6" } } }, @@ -790,7 +720,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "7" } } }, @@ -804,7 +734,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "7" } } }, @@ -818,7 +748,7 @@ "positions": { "begin": { "line": "22", - "column": "22" + "column": "8" } } }, @@ -832,7 +762,7 @@ "positions": { "begin": { "line": "22", - "column": "22" + "column": "9" } } }, @@ -846,7 +776,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "10" } } }, @@ -860,7 +790,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "11" } } }, @@ -874,7 +804,7 @@ "positions": { "begin": { "line": "22", - "column": "22" + "column": "12" } } }, @@ -888,7 +818,7 @@ "positions": { "begin": { "line": "22", - "column": "22" + "column": "13" } } }, @@ -902,7 +832,7 @@ "positions": { "begin": { "line": "23", - "column": "23" + "column": "14" } } }, @@ -916,7 +846,7 @@ "positions": { "begin": { "line": "23", - "column": "23" + "column": "15" } } }, @@ -930,7 +860,7 @@ "positions": { "begin": { "line": "22", - "column": "22" + "column": "7" } } }, @@ -944,7 +874,7 @@ "positions": { "begin": { "line": "22", - "column": "22" + "column": "8" } } }, @@ -958,7 +888,7 @@ "positions": { "begin": { "line": "23", - "column": "23" + "column": "9" } } }, @@ -972,7 +902,7 @@ "positions": { "begin": { "line": "23", - "column": "23" + "column": "10" } } }, @@ -986,7 +916,7 @@ "positions": { "begin": { "line": "24", - "column": "24" + "column": "11" } } }, @@ -1000,7 +930,7 @@ "positions": { "begin": { "line": "24", - "column": "24" + "column": "12" } } }, @@ -1014,7 +944,7 @@ "positions": { "begin": { "line": "23", - "column": "23" + "column": "13" } } }, @@ -1028,7 +958,7 @@ "positions": { "begin": { "line": "23", - "column": "23" + "column": "14" } } }, @@ -1042,7 +972,7 @@ "positions": { "begin": { "line": "24", - "column": "24" + "column": "15" } } }, @@ -1056,7 +986,7 @@ "positions": { "begin": { "line": "24", - "column": "24" + "column": "16" } } }, @@ -1070,7 +1000,7 @@ "positions": { "begin": { "line": "25", - "column": "25" + "column": "7" } } }, @@ -1084,7 +1014,7 @@ "positions": { "begin": { "line": "25", - "column": "25" + "column": "8" } } }, @@ -1098,7 +1028,7 @@ "positions": { "begin": { "line": "24", - "column": "24" + "column": "8" } } }, diff --git a/tests/test_in/polyspace_code_quality_exclude.json b/tests/test_in/polyspace_code_quality_exclude.json index 401a7e49..36b76a21 100644 --- a/tests/test_in/polyspace_code_quality_exclude.json +++ b/tests/test_in/polyspace_code_quality_exclude.json @@ -6,27 +6,13 @@ "positions": { "begin": { "line": "6", - "column": "6" + "column": "11" } } }, "description": "12345 Run-time Check: Overflow", "fingerprint": "839e418eda6b091c2413aa0722796fb9" }, - { - "severity": "major", - "location": { - "path": "dummy_file_name.h", - "positions": { - "begin": { - "line": "6", - "column": "6" - } - } - }, - "description": "12345 Run-time Check: Overflow", - "fingerprint": "cabd96c885bd6d9ed3fe867b227e8128" - }, { "severity": "major", "location": { @@ -34,27 +20,13 @@ "positions": { "begin": { "line": "7", - "column": "7" + "column": "3" } } }, "description": "12345 Run-time Check: Overflow", "fingerprint": "1961351c7f028d02202f915a6d36c658" }, - { - "severity": "major", - "location": { - "path": "dummy_file_name.h", - "positions": { - "begin": { - "line": "7", - "column": "7" - } - } - }, - "description": "12345 Run-time Check: Overflow", - "fingerprint": "fb6455c4794157cb304be4106e115e35" - }, { "severity": "critical", "location": { @@ -62,7 +34,7 @@ "positions": { "begin": { "line": "15", - "column": "15" + "column": "5" } } }, @@ -76,7 +48,7 @@ "positions": { "begin": { "line": "15", - "column": "15" + "column": "6" } } }, @@ -90,7 +62,7 @@ "positions": { "begin": { "line": "16", - "column": "16" + "column": "7" } } }, @@ -104,7 +76,7 @@ "positions": { "begin": { "line": "16", - "column": "16" + "column": "8" } } }, @@ -118,7 +90,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "9" } } }, @@ -132,7 +104,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "10" } } }, @@ -146,7 +118,7 @@ "positions": { "begin": { "line": "16", - "column": "16" + "column": "11" } } }, @@ -160,7 +132,7 @@ "positions": { "begin": { "line": "16", - "column": "16" + "column": "12" } } }, @@ -174,7 +146,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "13" } } }, @@ -188,7 +160,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "14" } } }, @@ -202,7 +174,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "5" } } }, @@ -216,7 +188,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "6" } } }, @@ -230,7 +202,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "6" } } }, @@ -244,7 +216,7 @@ "positions": { "begin": { "line": "17", - "column": "17" + "column": "7" } } }, @@ -258,7 +230,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "8" } } }, @@ -272,7 +244,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "9" } } }, @@ -286,7 +258,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "10" } } }, @@ -300,7 +272,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "11" } } }, @@ -314,7 +286,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "12" } } }, @@ -328,7 +300,7 @@ "positions": { "begin": { "line": "18", - "column": "18" + "column": "13" } } }, @@ -342,7 +314,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "14" } } }, @@ -356,7 +328,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "6" } } }, @@ -370,7 +342,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "7" } } }, @@ -384,7 +356,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "8" } } }, @@ -398,7 +370,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "9" } } }, @@ -412,7 +384,7 @@ "positions": { "begin": { "line": "19", - "column": "19" + "column": "10" } } }, @@ -426,7 +398,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "11" } } }, @@ -440,7 +412,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "12" } } }, @@ -454,7 +426,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "13" } } }, @@ -468,7 +440,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "14" } } }, @@ -482,7 +454,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "15" } } }, @@ -496,7 +468,7 @@ "positions": { "begin": { "line": "20", - "column": "20" + "column": "6" } } }, @@ -510,7 +482,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "7" } } }, @@ -524,7 +496,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "7" } } }, @@ -538,7 +510,7 @@ "positions": { "begin": { "line": "22", - "column": "22" + "column": "8" } } }, @@ -552,7 +524,7 @@ "positions": { "begin": { "line": "22", - "column": "22" + "column": "9" } } }, @@ -566,7 +538,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "10" } } }, @@ -580,7 +552,7 @@ "positions": { "begin": { "line": "21", - "column": "21" + "column": "11" } } }, @@ -594,7 +566,7 @@ "positions": { "begin": { "line": "22", - "column": "22" + "column": "12" } } }, @@ -608,7 +580,7 @@ "positions": { "begin": { "line": "22", - "column": "22" + "column": "13" } } }, @@ -622,7 +594,7 @@ "positions": { "begin": { "line": "23", - "column": "23" + "column": "14" } } }, @@ -636,7 +608,7 @@ "positions": { "begin": { "line": "23", - "column": "23" + "column": "15" } } }, diff --git a/tests/test_integration.py b/tests/test_integration.py index 02341238..926400bf 100644 --- a/tests/test_integration.py +++ b/tests/test_integration.py @@ -198,6 +198,8 @@ def test_robot_verbose(self): ) def test_robot_config(self): + os.environ['MIN_ROBOT_WARNINGS'] = '0' + os.environ['MAX_ROBOT_WARNINGS'] = '0' with patch('sys.stdout', new=StringIO()) as fake_out: retval = warnings_wrapper([ '--config', @@ -225,6 +227,9 @@ def test_robot_config(self): stdout_log ) self.assertEqual(2, retval) + for var in ('MIN_ROBOT_WARNINGS', 'MAX_ROBOT_WARNINGS'): + if var in os.environ: + del os.environ[var] def test_robot_config_check_names(self): self.maxDiff = None @@ -281,6 +286,8 @@ def test_output_file_robot_basic(self): self.assertTrue(filecmp.cmp(out_file, ref_file), '{} differs from {}'.format(out_file, ref_file)) def test_output_file_robot_config(self): + os.environ['MIN_ROBOT_WARNINGS'] = '0' + os.environ['MAX_ROBOT_WARNINGS'] = '0' filename = 'robot_double_fail_config_summary.txt' out_file = str(TEST_OUT_DIR / filename) ref_file = str(TEST_IN_DIR / filename) @@ -291,6 +298,9 @@ def test_output_file_robot_config(self): ]) self.assertEqual(2, retval) self.assertTrue(filecmp.cmp(out_file, ref_file), '{} differs from {}'.format(out_file, ref_file)) + for var in ('MIN_ROBOT_WARNINGS', 'MAX_ROBOT_WARNINGS'): + if var in os.environ: + del os.environ[var] def test_output_file_junit(self): filename = 'junit_double_fail_summary.txt' diff --git a/tests/test_polyspace.py b/tests/test_polyspace.py index 793e3566..090a0c2b 100644 --- a/tests/test_polyspace.py +++ b/tests/test_polyspace.py @@ -36,7 +36,7 @@ def test_code_prover_tsv_file(self): stdout_log ) self.assertEqual(count, count_sum) - self.assertEqual(count, 24) + self.assertEqual(count, 19) class TestBugFinderWarnings(unittest.TestCase): @@ -66,11 +66,11 @@ def test_bug_finder_tsv_file(self): class TestPolyspaceWarnings(unittest.TestCase): def setUp(self): - os.environ['MIN_SPHINX_WARNINGS'] = '0' - os.environ['MAX_SPHINX_WARNINGS'] = '0' + os.environ['MIN_POLY_WARNINGS'] = '0' + os.environ['MAX_POLY_WARNINGS'] = '0' def tearDown(self): - for var in ('MIN_SPHINX_WARNINGS', 'MAX_SPHINX_WARNINGS'): + for var in ('MIN_POLY_WARNINGS', 'MAX_POLY_WARNINGS'): if var in os.environ: del os.environ[var] @@ -79,7 +79,7 @@ def test_config_file(self): '--config', str(TEST_IN_DIR / 'config_example_polyspace.yml'), str(TEST_IN_DIR / 'polyspace.tsv') ]) - self.assertEqual(66, retval) + self.assertEqual(61, retval) def test_code_quality(self): filename = 'polyspace_code_quality.json' @@ -90,7 +90,7 @@ def test_code_quality(self): '--config', str(TEST_IN_DIR / 'config_example_polyspace.yml'), str(TEST_IN_DIR / 'polyspace.tsv'), ]) - self.assertEqual(66, retval) + self.assertEqual(61, retval) self.assertTrue(filecmp.cmp(out_file, ref_file)) def test_code_quality_no_green(self): @@ -101,7 +101,7 @@ def test_code_quality_no_green(self): '--config', str(TEST_IN_DIR / 'config_example_polyspace_green.yml'), str(TEST_IN_DIR / 'polyspace.tsv'), ]) - self.assertEqual(66, retval) + self.assertEqual(61, retval) self.assertTrue(filecmp.cmp(out_file, ref_file)) def test_exclude_yaml_config(self):