From c4df47c2465ffecc5efc10420b5b36fc8e36990f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Fri, 12 Nov 2021 23:51:51 +0100 Subject: [PATCH] Approvals normalize paths with both backward and forward slash --- tools/scripts/approvalTests.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/scripts/approvalTests.py b/tools/scripts/approvalTests.py index 1bef3e52..99b94152 100755 --- a/tools/scripts/approvalTests.py +++ b/tools/scripts/approvalTests.py @@ -99,9 +99,15 @@ def diffFiles(fileA, fileB): def normalizeFilepath(line): - if catchPath in line: - # make paths relative to Catch root - line = line.replace(catchPath + os.sep, '') + # Sometimes the path separators used by compiler and Python can differ, + # so we try to match the path with both forward and backward path + # separators, to make the paths relative to Catch2 repo root. + forwardSlashPath = catchPath.replace('\\', '/') + if forwardSlashPath in line: + line = line.replace(forwardSlashPath + '/', '') + backwardSlashPath = catchPath.replace('/', '\\') + if backwardSlashPath in line: + line = line.replace(backwardSlashPath + '\\', '') m = langFilenameParser.match(line) if m: