llvm-project/clang/test/Index/index-module-with-vfs.m
Daniel Sanders 327894859c 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`
2019-12-03 15:44:01 -08:00

26 lines
1.1 KiB
Objective-C

@import ModuleNeedsVFS;
void foo() {
module_needs_vfs();
base_module_needs_vfs();
}
// RUN: rm -rf %t.cache
// RUN: sed -e "s@INPUT_DIR@%{/S:regex_replacement}/Inputs@g" -e "s@OUT_DIR@%{/t:regex_replacement}@g" %S/Inputs/vfsoverlay.yaml > %t.yaml
// RUN: c-index-test -index-file %s -fmodules-cache-path=%t.cache -fmodules -F %t -I %t \
// RUN: -ivfsoverlay %t.yaml -Xclang -fdisable-module-hash | FileCheck %s
// CHECK: [importedASTFile]: {{.*}}ModuleNeedsVFS.pcm | loc: 1:1 | name: "ModuleNeedsVFS" | isImplicit: 0
// CHECK: [indexEntityReference]: kind: function | name: module_needs_vfs
// CHECK: [indexEntityReference]: kind: function | name: base_module_needs_vfs
// RUN: c-index-test -index-tu %t.cache/ModuleNeedsVFS.pcm | FileCheck %s -check-prefix=CHECK-MOD
// CHECK-MOD: [ppIncludedFile]: {{.*}}module_needs_vfs.h
// CHECK-MOD: [importedASTFile]: {{.*}}BaseModuleNeedsVFS.pcm
// CHECK-MOD: [indexEntityReference]: kind: function | name: base_module_needs_vfs
// RUN: c-index-test -index-tu %t.cache/BaseModuleNeedsVFS.pcm | FileCheck %s -check-prefix=CHECK-MOD2
// CHECK-MOD2: [ppIncludedFile]: {{.*}}base_module_needs_vfs.h