@@ -62,17 +62,19 @@ def __str__(self):
62
62
63
63
@staticmethod
64
64
def get_target_dir (commands , test_path ):
65
+ # posix=True breaks Windows paths because \ is treated as an escaping character
65
66
for cmd in commands :
66
- split = shlex .split (cmd )
67
+ split = shlex .split (cmd , posix = False )
67
68
if "split-file" not in split :
68
69
continue
69
70
start_idx = split .index ("split-file" )
70
71
split = split [start_idx :]
71
72
if len (split ) < 3 :
72
73
continue
73
- if split [1 ].strip () != test_path :
74
+ p = unquote (split [1 ].strip ())
75
+ if not test_path .samefile (p ):
74
76
continue
75
- return split [2 ].strip ()
77
+ return unquote ( split [2 ].strip () )
76
78
return None
77
79
78
80
@staticmethod
@@ -104,6 +106,12 @@ def _get_split_line_path(l):
104
106
return l .rstrip ()
105
107
106
108
109
+ def unquote (s ):
110
+ if len (s ) > 1 and s [0 ] == s [- 1 ] and (s [0 ] == '"' or s [0 ] == "'" ):
111
+ return s [1 :- 1 ]
112
+ return s
113
+
114
+
107
115
def get_source_and_target (a , b , test_path , commands ):
108
116
"""
109
117
Try to figure out which file is the test output and which is the reference.
@@ -145,7 +153,7 @@ def diff_test_updater(result, test, commands):
145
153
[cmd , a , b ] = args
146
154
if cmd != "diff" :
147
155
return None
148
- res = get_source_and_target (a , b , test .getFilePath (), commands )
156
+ res = get_source_and_target (a , b , pathlib . Path ( test .getFilePath () ), commands )
149
157
if not res :
150
158
return f"update-diff-test: could not deduce source and target from { a } and { b } "
151
159
source , target = res
0 commit comments