HomePhabricator

Fix `sed -e s@FOO@%/S@` and similar when there's @'s in the working directory

Authored by dsanders on Dec 3 2019, 3:22 PM.

Description

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

Details

Committed
dsandersDec 3 2019, 3:44 PM
Parents
rG878a24ee244a: Reapply "Fix crash on switch conditions of non-integer types in templates"
Branches
Unknown
Tags
Unknown

Event Timeline

Could you also update https://llvm.org/docs/CommandGuide/lit.html#pre-defined-substitutions to mention this new extension?

Also this doesn't look like a trivial change, why was this submitted without any review?

Could you also update https://llvm.org/docs/CommandGuide/lit.html#pre-defined-substitutions to mention this new extension?

Sure

Also this doesn't look like a trivial change, why was this submitted without any review?

I thought it was a trivial change. What makes you think it's non-trivial?
I'm happy to do any follow ups if anyone has post-commit comments.

Documented these and several other undocumented substitutions in rG82f3c5d4a66.