Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions clang/test/ClangScanDeps/include-tree-working-directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,18 @@
// CACHE-HIT: remark: compile job cache hit

// RUN: cat %t/tu.rsp | sed -E 's|.*"-fcas-include-tree" "(llvmcas://[[:xdigit:]]+)".*|\1|' > %t/tu.casid
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | FileCheck %s -DPREFIX=%/t
// RUN: clang-cas-test -cas %t/cas -print-include-tree @%t/tu.casid | %PathSanitizingFileCheck --sanitize PREFIX=%/t %s

// CHECK: [[PREFIX]]/t.c llvmcas://
// CHECK: PREFIX{{/|\\}}t.c llvmcas://

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a number of tests that do something like pipe the output through sed 's:\\\\\?:/:g' to avoid needing regex for every CHECK line. Does that work here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that would probably work but I had had a review comment that using PathSanitizingFileCheck and doing this way would be more precise so I'm following that style.

// CHECK: 1:1 <built-in> llvmcas://
// CHECK: 2:1 [[PREFIX]]/relative/h1.h llvmcas://
// CHECK: 2:1 PREFIX{{/|\\}}relative{{/|\\}}h1.h llvmcas://
// CHECK: Files:
// CHECK: [[PREFIX]]/t.c llvmcas://
// CHECK: [[PREFIX]]/relative/h1.h llvmcas://
// CHECK: PREFIX{{/|\\}}t.c llvmcas://
// CHECK: PREFIX{{/|\\}}relative{{/|\\}}h1.h llvmcas://

/// Using a different working directory should cache hit as well.
/// FIXME: Working directory affects some codegen options added by clang driver, preserve them to make sure the cache hit.
// RUN: sed -e "s|DIR|%/t|g" %t/cdb2.json.template > %t/cdb2.json
// RUN: sed -e "s|DIR|%/t|g" %t/cdb2.json.template | sed -e "s|SEP|%{fs-sep-yaml}|g" > %t/cdb2.json
// RUN: clang-scan-deps -compilation-database %t/cdb2.json -format experimental-include-tree-full -cas-path %t/cas \
// RUN: > %t/deps2.json
// RUN: %deps-to-rsp %t/deps2.json --tu-index 0 > %t/tu2.rsp
Expand All @@ -48,7 +48,7 @@
//--- cdb2.json.template
[{
"directory": "DIR/other",
"command": "clang -c DIR/t.c -I DIR/relative -working-directory DIR/other -o DIR/t2.o -MD -serialize-diagnostics DIR/t2.dia -fdebug-compilation-dir=DIR -fcoverage-compilation-dir=DIR",
"command": "clang -c DIRSEPt.c -I DIRSEPrelative -working-directory DIR/other -o DIR/t2.o -MD -serialize-diagnostics DIR/t2.dia -fdebug-compilation-dir=DIR -fcoverage-compilation-dir=DIR",
"file": "DIR/t.c"
}]

Expand Down
1 change: 1 addition & 0 deletions llvm/utils/lit/lit/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,7 @@ def getDefaultSubstitutions(test, tmpDir, tmpBase, normalize_slashes=False):
("%{fs-src-root}", pathlib.Path(sourcedir).anchor),
("%{fs-tmp-root}", pathlib.Path(tmpBase).anchor),
("%{fs-sep}", os.path.sep),
("%{fs-sep-yaml}", "\\\\\\\\\\\\\\\\" if kIsWindows else "/"),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did we get from 1 \ to 16 \s?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Four levels of backslash escaping - one for this python string, two for being quoted and being a replacement pattern in sed and one for being a json string.

]
)

Expand Down