Commit bd6698b2 authored by Jan Kiene's avatar Jan Kiene
Browse files

handle absolute paths in location

parent 2936ec6e
Loading
Loading
Loading
Loading
+9 −4
Original line number Diff line number Diff line
@@ -13,11 +13,13 @@ from pathlib import Path
class SanitizerError:
    SUMMARY_ID = ""

    def __init__(self, traceback: str, commandlines: dict, testcase: str) -> None:
    def __init__(
        self, traceback: str, commandlines: dict, testcase: str, cwd: Path = Path(".")
    ) -> None:
        self.traceback = traceback
        self.commandlines = commandlines
        self.testcase = testcase
        self.type, self.location = self.parse_type_and_location(traceback)
        self.type, self.location = self.parse_type_and_location(traceback, cwd)

    def __hash__(self):
        return hash(self.location)
@@ -41,7 +43,7 @@ class SanitizerError:
            **self.commandlines,
        }

    def parse_type_and_location(self, traceback) -> Tuple[str, str]:
    def parse_type_and_location(self, traceback, cwd) -> Tuple[str, str]:
        last_line = traceback.split("\n")[-1].strip()
        assert last_line.startswith(f"SUMMARY: {self.SUMMARY_ID}")
        m = re.match(
@@ -51,6 +53,9 @@ class SanitizerError:
        assert m is not None

        type, location = m.groups()

        if Path(location).is_absolute():
            location = str(Path(location).relative_to(cwd))
        return type, location


@@ -152,7 +157,7 @@ def parse_errors_from_sysout(
        if line.startswith("SUMMARY:"):
            assert state == ParserState.IN

            errors.append(err_cls("\n".join(accu), commandlines, testcase_name))
            errors.append(err_cls("\n".join(accu), commandlines, testcase_name, cwd))
            state = ParserState.OUT

    return errors