Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Approvals normalize paths with both backward and forward slash

Commit
c4df47c2465ffecc5efc10420b5b36fc8e36990f
Author
Martin Hořeňovský ·
Parents
9200b4078bce

Files · Download .tar.gz

Changes

 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: