@@ -62,17 +62,19 @@ def __str__(self):
6262
6363 @staticmethod
6464 def get_target_dir (commands , test_path ):
65+ # posix=True breaks Windows paths because \ is treated as an escaping character
6566 for cmd in commands :
66- split = shlex .split (cmd )
67+ split = shlex .split (cmd , posix = False )
6768 if "split-file" not in split :
6869 continue
6970 start_idx = split .index ("split-file" )
7071 split = split [start_idx :]
7172 if len (split ) < 3 :
7273 continue
73- if split [1 ].strip () != test_path :
74+ p = unquote (split [1 ].strip ())
75+ if not test_path .samefile (p ):
7476 continue
75- return split [2 ].strip ()
77+ return unquote ( split [2 ].strip () )
7678 return None
7779
7880 @staticmethod
@@ -104,6 +106,12 @@ def _get_split_line_path(l):
104106 return l .rstrip ()
105107
106108
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+
107115def get_source_and_target (a , b , test_path , commands ):
108116 """
109117 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):
145153 [cmd , a , b ] = args
146154 if cmd != "diff" :
147155 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 )
149157 if not res :
150158 return f"update-diff-test: could not deduce source and target from { a } and { b } "
151159 source , target = res
0 commit comments