summarylogtreecommitdiffstats
path: root/0002-ApprovalTests-fix-path-rewriting-for-debug-builds.patch
blob: 75848c5b5a4895e177b588f572e324b8c2a2d647 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
From 74edb0c633892f14943342976b3e8ff0ba7a76fa Mon Sep 17 00:00:00 2001
From: Xiretza <xiretza@xiretza.xyz>
Date: Sun, 13 Mar 2022 15:12:37 +0100
Subject: [PATCH 2/2] ApprovalTests: fix path rewriting for debug builds

---
 tools/scripts/approvalTests.py | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/tools/scripts/approvalTests.py b/tools/scripts/approvalTests.py
index 592be36e..8e8f9285 100755
--- a/tools/scripts/approvalTests.py
+++ b/tools/scripts/approvalTests.py
@@ -94,14 +94,20 @@ def diffFiles(fileA, fileB):
 
 
 def normalizeFilepath(line):
-    # 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:
+    # makepkg applies -ffile-prefix-map=, which rewrites all occurences of $srcdir to $dbgsrcdir
+    basePaths = [catchPath]
+    dbgsrcdir = os.getenv('dbgsrcdir')
+    if dbgsrcdir is not None:
+        basePaths.append(dbgsrcdir + '/Catch2')
+
+    for basePath in basePaths:
+        # 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 = basePath.replace('\\', '/')
         line = line.replace(forwardSlashPath + '/', '')
-    backwardSlashPath = catchPath.replace('/', '\\')
-    if backwardSlashPath in line:
+
+        backwardSlashPath = basePath.replace('/', '\\')
         line = line.replace(backwardSlashPath + '\\', '')
 
     m = langFilenameParser.match(line)
-- 
2.38.1