mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 03:02:36 +01:00
Fix sed -e s@FOO@%/S@
and similar when there's @'s in the working directory
Jenkins sometimes starts a new working directory by appending @2 (or incrementing the number if the @n suffix is already there). This causes several clang tests to fail as: s@INPUT_DIR@%/S/Inputs@g gets expanded to the invalid: s@INPUT_DIR@/path/to/workdir@2/Inputs@g ~~~~~~~~~~ where the part marked with ~'s is interpreted as the flags. These are invalid and the test fails. Previous fixes simply exchanged the @ character for another like | but that's just moving the problem. Address it by adding an expansion that escapes the @ character we're using as a delimiter as well as other magic characters in the replacement of sed's s@@@. There's still room for expansions to cause trouble though. One I ran into while testing this was that having a directory called foo@bar causes lots of `CHECK-NOT: foo` directives to match. There's also things like directories containing `\1`
This commit is contained in:
parent
5005e2b70a
commit
36fe0c5f62
@ -1105,6 +1105,20 @@ def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False):
|
|||||||
('%/T', tmpDir.replace('\\', '/')),
|
('%/T', tmpDir.replace('\\', '/')),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
# "%{/[STpst]:regex_replacement}" should be normalized like "%/[STpst]" but we're
|
||||||
|
# also in a regex replacement context of a s@@@ regex.
|
||||||
|
def regex_escape(s):
|
||||||
|
s = s.replace('@', '\@')
|
||||||
|
s = s.replace('&', '\&')
|
||||||
|
return s
|
||||||
|
substitutions.extend([
|
||||||
|
('%{/s:regex_replacement}', regex_escape(sourcepath.replace('\\', '/'))),
|
||||||
|
('%{/S:regex_replacement}', regex_escape(sourcedir.replace('\\', '/'))),
|
||||||
|
('%{/p:regex_replacement}', regex_escape(sourcedir.replace('\\', '/'))),
|
||||||
|
('%{/t:regex_replacement}', regex_escape(tmpBase.replace('\\', '/')) + '.tmp'),
|
||||||
|
('%{/T:regex_replacement}', regex_escape(tmpDir.replace('\\', '/'))),
|
||||||
|
])
|
||||||
|
|
||||||
# "%:[STpst]" are normalized paths without colons and without a leading
|
# "%:[STpst]" are normalized paths without colons and without a leading
|
||||||
# slash.
|
# slash.
|
||||||
substitutions.extend([
|
substitutions.extend([
|
||||||
|
Loading…
Reference in New Issue
Block a user