diff options
| author | Martin Hořeňovský | 2022-12-31 21:17:54 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2023-01-01 20:27:59 +0100 |
| commit | ac93f1943762f6fc92f0dc5bac0d720a33a27530 (patch) | |
| tree | 30e0fe49bfe44f66be7c98588856b15ba1288c3e /tools | |
| parent | 72b60dfd28b403f3aef55465c0a29a9aa95b1cc7 (diff) | |
| download | catch3-ac93f1943762f6fc92f0dc5bac0d720a33a27530.tar.gz | |
Improved path normalization in approvalTests.py
Instead of redoing the whole line where path was found, only the
directory part of the path is removed, instead of removing all
of the line before the path starts.
This results in slight change in how junit and sonarqube approvals
come out, and significant change in how TeamCity reporter approvals
come out. This latter difference is the reason for the change,
as now the lines with `testFailed` and `testIgnored` messages
are not completely butchered.
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/scripts/approvalTests.py | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/tools/scripts/approvalTests.py b/tools/scripts/approvalTests.py index 592be36e..4146b646 100755 --- a/tools/scripts/approvalTests.py +++ b/tools/scripts/approvalTests.py @@ -48,11 +48,11 @@ def get_unapprovedResultsPath(baseName): langFilenameParser = re.compile(r'(.+\.[ch]pp)') filelocParser = re.compile(r''' - .*/ - (.+\.[ch]pp) # filename - (?::|\() # : is starting separator between filename and line number on Linux, ( on Windows - ([0-9]*) # line number - \)? # Windows also has an ending separator, ) + (?P<path_prefix>tests/SelfTest/(?:\w+/)*) # We separate prefix and fname, so that + (?P<filename>\w+\.tests\.[ch]pp) # we can keep only filename + (?::|\() # Linux has : as separator between fname and line number, Windows uses ( + (\d*) # line number + \)? # Windows also uses an ending separator, ) ''', re.VERBOSE) lineNumberParser = re.compile(r' line="[0-9]*"') hexParser = re.compile(r'\b(0[xX][0-9a-fA-F]+)\b') @@ -119,14 +119,11 @@ def filterLine(line, isCompact): line = normalizeFilepath(line) # strip source line numbers - m = filelocParser.match(line) - if m: - # note that this also strips directories, leaving only the filename - filename, lnum = m.groups() - lnum = ":<line number>" if lnum else "" - line = filename + lnum + line[m.end():] - else: - line = lineNumberParser.sub(" ", line) + # Note that this parser assumes an already normalized filepath from above, + # and might break terribly if it is moved around before the normalization. + line = filelocParser.sub('\g<filename>:<line number>', line) + + line = lineNumberParser.sub(" ", line) if isCompact: line = line.replace(': FAILED', ': failed') |