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
56 changes: 28 additions & 28 deletions clang/test/ClangScanDeps/cas-fs-prefix-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,40 @@
// REQUIRES: ondisk_cas
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: sed -e "s|DIR|%t|g" -e "s|CLANG|%clang|g" -e "s|SDK|%S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json
// RUN: sed -e "s|DIR|%/t|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json

// == Tree
// Ensure the filesystem has the mapped paths.

// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-tree -cas-path %t/cas \
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \
// RUN: | sed -E 's/tree ([^ ]+) for.*/\1/' > %t/tree_id.txt
// RUN: llvm-cas -cas %t/cas -ls-tree-recursive @%t/tree_id.txt > %t/tree_result.txt
// RUN: FileCheck %s -input-file %t/tree_result.txt -check-prefix=FILES
// RUN: FileCheck %s -input-file %t/tree_result.txt -DROOT=%{/roott} -check-prefix=FILES

// FILES: file llvmcas://{{.*}} /^sdk/usr/include/stdlib.h
// FILES: file llvmcas://{{.*}} /^src/t.c
// FILES: file llvmcas://{{.*}} /^src/top.h
// FILES: file llvmcas://{{.*}} /^tc/lib/clang/{{.*}}/include/stdarg.h
// FILES: file llvmcas://{{.*}} [[ROOT]]^sdk/usr/include/stdlib.h
// FILES: file llvmcas://{{.*}} [[ROOT]]^src/t.c
// FILES: file llvmcas://{{.*}} [[ROOT]]^src/top.h
// FILES: file llvmcas://{{.*}} [[ROOT]]^tc/lib/clang/{{.*}}/include/stdarg.h

// == Full Tree
// This should have the same filesystem as above, and we also check the command-
// line.

// RUN: cat %t/tree_id.txt > %t/full_tree_result.txt
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-tree-full -cas-path %t/cas \
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \
// RUN: >> %t/full_tree_result.txt
// RUN: FileCheck %s -input-file %t/full_tree_result.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK
// RUN: cat %t/full_tree_result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ --enable-yaml-compatibility %s

// == Full
// Same as full tree.

// RUN: cat %t/tree_id.txt > %t/full_result.txt
// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -cas-path %t/cas \
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \
// RUN: >> %t/full_result.txt
// RUN: FileCheck %s -input-file %t/full_result.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK
// RUN: cat %t/full_result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ --enable-yaml-compatibility %s

// CHECK: [[MAPPED_FS_ID:llvmcas://[[:xdigit:]]+]]
// CHECK: "modules": []
Expand All @@ -49,36 +49,36 @@
// CHECK: "clang-module-deps": []
// CHECK: "command-line": [
// CHECK: "-fcas-path"
// CHECK-NEXT: "[[PREFIX]]/cas"
// CHECK-NEXT: "PREFIX{{/|\\\\}}cas"
// CHECK: "-fcas-fs"
// CHECK-NEXT: "[[MAPPED_FS_ID]]"
// CHECK: "-fcas-fs-working-directory"
// CHECK-NEXT: "/^src"
// CHECK-NEXT: "ROOT^src"
// CHECK: "-x"
// CHECK-NEXT: "c"
// CHECK-NEXT: "/^src/t.c"
// CHECK-NEXT: "ROOT^src{{/|\\\\}}t.c"
// CHECK: "-isysroot"
// CHECK-NEXT: "/^sdk"
// CHECK-NEXT: "ROOT^sdk"
// CHECK: "-resource-dir"
// CHECK-NEXT: "/^tc/lib/clang/{{.*}}"
// CHECK-NEXT: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}"
// CHECK: "-isystem"
// CHECK-NEXT: "/^sdk/usr/local/include
// CHECK-NEXT: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}local{{/|\\\\}}include
// CHECK: "-isystem"
// CHECK-NEXT: "/^tc/lib/clang/{{.*}}/include"
// CHECK-NEXT: "ROOT^tc{{/|\\\\}}lib{{/|\\\\}}clang{{/|\\\\}}{{.*}}{{/|\\\\}}include"
// CHECK: "-internal-externc-isystem"
// CHECK-NEXT: "/^sdk/usr/include"
// CHECK: "-fdebug-compilation-dir=/^src"
// CHECK: "-fcoverage-compilation-dir=/^src"
// CHECK-NOT: [[PREFIX]]
// CHECK-NOT: [[SDK_PREFIX]]
// CHECK-NEXT: "ROOT^sdk{{/|\\\\}}usr{{/|\\\\}}include"
// CHECK: "-fdebug-compilation-dir=ROOT^src"
// CHECK: "-fcoverage-compilation-dir=ROOT^src"
// CHECK-NOT: PREFIX
// CHECK-NOT: SDK_PREFIX
// CHECK: ]
// CHECK: "file-deps": [
// CHECK: "[[PREFIX]]/t.c"
// CHECK: "[[PREFIX]]/top.h"
// CHECK: "{{.*}}include/stdarg.h"
// CHECK: "[[SDK_PREFIX]]/usr/include/stdlib.h"
// CHECK: "PREFIX{{/|\\\\}}t.c"
// CHECK: "PREFIX{{/|\\\\}}top.h"
// CHECK: "{{.*}}include{{/|\\\\}}stdarg.h"
// CHECK: "SDK_PREFIX{{/|\\\\}}usr{{/|\\\\}}include{{/|\\\\}}stdlib.h"
// CHECK: ]
// CHECK: "input-file": "[[PREFIX]]/t.c"
// CHECK: "input-file": "PREFIX{{/|\\\\}}t.c"

//--- cdb.json.template
[
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// REQUIRES: ondisk_cas
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: sed -e "s|DIR|%t|g" %t/cdb.json.template > %t/cdb.json
// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json

// RUN: clang-scan-deps -compilation-database %t/cdb.json \
// RUN: -format experimental-include-tree-full -cas-path %t/cas \
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc > %t/deps.json
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc > %t/deps.json

//--- cdb.json.template
[{
Expand Down
42 changes: 21 additions & 21 deletions clang/test/ClangScanDeps/include-tree-prefix-mapping.c
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
// REQUIRES: ondisk_cas
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: sed -e "s|DIR|%t|g" -e "s|CLANG|%clang|g" -e "s|SDK|%S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json
// RUN: sed -e "s|DIR|%/t|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/cdb.json

// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-include-tree -cas-path %t/cas \
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc > %t/result.txt
// RUN: FileCheck %s -input-file %t/result.txt -DPREFIX=%t -DSDK_PREFIX=%S/Inputs/SDK
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc > %t/result.txt
// RUN: cat %t/result.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ %s

// CHECK: {{.*}} - [[PREFIX]]/t.c
// CHECK-NOT: [[PREFIX]]
// CHECK-NOT: [[SDK_PREFIX]]
// CHECK: /^src{{[/\\]}}t.c
// CHECK: /^src{{[/\\]}}top.h
// CHECK: /^tc{{[/\\]}}lib{{[/\\]}}clang{{[/\\]}}{{.*}}{{[/\\]}}include{{[/\\]}}stdarg.h
// CHECK: /^sdk{{[/\\]}}usr{{[/\\]}}include{{[/\\]}}stdlib.h
// CHECK: {{.*}} - PREFIX{{/|\\}}t.c
// CHECK-NOT: PREFIX
// CHECK-NOT: SDK_PREFIX
// CHECK: ROOT^src{{[/\\]}}t.c
// CHECK: ROOT^src{{[/\\]}}top.h
// CHECK: ROOT^tc{{[/\\]}}lib{{[/\\]}}clang{{[/\\]}}{{.*}}{{[/\\]}}include{{[/\\]}}stdarg.h
// CHECK: ROOT^sdk{{[/\\]}}usr{{[/\\]}}include{{[/\\]}}stdlib.h

// RUN: clang-scan-deps -compilation-database %t/cdb.json \
// RUN: -format experimental-include-tree-full -cas-path %t/cas \
// RUN: -prefix-map=%t=/^src -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc > %t/deps.json
// RUN: -prefix-map=%t=%/root^src -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc > %t/deps.json

// RUN: cat %t/result.txt > %t/full.txt
// RUN: echo "FULL DEPS START" >> %t/full.txt
// RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' >> %t/full.txt
// RUN: cat %t/deps.json >> %t/full.txt

// RUN: FileCheck %s -DPREFIX=%/t -DSDK_PREFIX=%S/Inputs/SDK -check-prefix=FULL -input-file %t/full.txt
// RUN: cat %t/full.txt | %PathSanitizingFileCheck --sanitize PREFIX=%/t --sanitize SDK_PREFIX=%/S/Inputs/SDK --sanitize ROOT^=%/root^ --enable-yaml-compatibility %s -check-prefix=FULL

// Capture the tree id from experimental-include-tree ; ensure that it matches
// the result from experimental-full.
// FULL: [[TREE_ID:llvmcas://[[:xdigit:]]+]] - [[PREFIX]]/t.c
// FULL: [[TREE_ID:llvmcas://[[:xdigit:]]+]] - PREFIX{{/|\\}}t.c
// FULL: FULL DEPS START

// FULL-NEXT: {
Expand All @@ -40,7 +40,7 @@
// FULL: "command-line": [
// FULL-NEXT: "-cc1"
// FULL: "-fcas-path"
// FULL-NEXT: "[[PREFIX]]/cas"
// FULL-NEXT: "PREFIX{{/|\\\\}}cas"
// FULL: "-disable-free"
// FULL: "-fcas-include-tree"
// FULL-NEXT: "[[TREE_ID]]"
Expand All @@ -49,15 +49,15 @@
// FULL: "-x"
// FULL-NEXT: "c"
// FULL: "-isysroot"
// FULL-NEXT: "/^sdk"
// FULL-NEXT: "ROOT^sdk"
// FULL: ]
// FULL: "file-deps": [
// FULL-DAG: "[[PREFIX]]/t.c"
// FULL-DAG: "[[PREFIX]]/top.h"
// FULL-DAG: "{{.*}}/stdarg.h"
// FULL-DAG: "[[SDK_PREFIX]]/usr/include/stdlib.h"
// FULL-DAG: "PREFIX{{/|\\\\}}t.c"
// FULL-DAG: "PREFIX{{/|\\\\}}top.h"
// FULL-DAG: "{{.*}}{{/|\\\\}}stdarg.h"
// FULL-DAG: "SDK_PREFIX{{/|\\\\}}usr{{/|\\\\}}include{{/|\\\\}}stdlib.h"
// FULL: ]
// FULL: "input-file": "[[PREFIX]]/t.c"
// FULL: "input-file": "PREFIX{{/|\\\\}}t.c"
// FULL: }
// FULL: ]
// FULL: }
Expand Down
30 changes: 18 additions & 12 deletions clang/test/ClangScanDeps/modules-cas-fs-prefix-mapping-caching.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
// RUN: rm -rf %t
// RUN: split-file %s %t
// RUN: cp -r %t/dir1 %t/dir2
// RUN: sed -e "s|DIR|%t/dir1|g" -e "s|CLANG|%clang|g" -e "s|SDK|%S/Inputs/SDK|g" %t/cdb.json.template > %t/dir1/cdb.json
// RUN: sed -e "s|DIR|%t/dir2|g" -e "s|CLANG|%clang|g" -e "s|SDK|%S/Inputs/SDK|g" %t/cdb.json.template > %t/dir2/cdb.json
// RUN: sed -e "s|DIR|%/t/dir1|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/dir1/cdb.json
// RUN: sed -e "s|DIR|%/t/dir2|g" -e "s|CLANG|%/ncclang|g" -e "s|SDK|%/S/Inputs/SDK|g" %t/cdb.json.template > %t/dir2/cdb.json

// RUN: clang-scan-deps -compilation-database %t/dir1/cdb.json -format experimental-full \
// RUN: -cas-path %t/cas -module-files-dir %t/dir1/modules \
// RUN: -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \
// RUN: -prefix-map=%t/dir1/modules=/^modules -prefix-map=%t/dir1=/^src -optimize-args=none \
// RUN: -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \
// RUN: -prefix-map=%t/dir1/modules=%/root^modules -prefix-map=%t/dir1=%/root^src -optimize-args=none \
// RUN: > %t/dir1.txt

// RUN: clang-scan-deps -compilation-database %t/dir2/cdb.json -format experimental-full \
// RUN: -cas-path %t/cas -module-files-dir %t/dir2/modules \
// RUN: -prefix-map-sdk=/^sdk -prefix-map-toolchain=/^tc \
// RUN: -prefix-map=%t/dir2/modules=/^modules -prefix-map=%t/dir2=/^src -optimize-args=none \
// RUN: -prefix-map-sdk=%/root^sdk -prefix-map-toolchain=%/root^tc \
// RUN: -prefix-map=%t/dir2/modules=%/root^modules -prefix-map=%t/dir2=%/root^src -optimize-args=none \
// RUN: > %t/dir2.txt

// Extract individual commands.
Expand All @@ -29,15 +29,21 @@
// RUN: %deps-to-rsp %t/dir2.txt --module-name=A > %t/dir2/A.cc1.rsp
// RUN: %deps-to-rsp %t/dir2.txt --tu-index 0 > %t/dir2/tu.cc1.rsp

// RUN: (cd %t/dir1; %clang @B.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-MISS
// RUN: (cd %t/dir1; %clang @A.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-MISS
// RUN: (cd %t/dir1; %clang @tu.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-MISS
// RUN: cd %t/dir1 && %clang @B.cc1.rsp > %t/miss-B.txt 2>&1
// RUN: cat %t/miss-B.txt | FileCheck %s -check-prefix=CACHE-MISS
// RUN: cd %t/dir1 && %clang @A.cc1.rsp > %t/miss-A.txt 2>&1
// RUN: cat %t/miss-A.txt | FileCheck %s -check-prefix=CACHE-MISS
// RUN: cd %t/dir1 && %clang @tu.cc1.rsp > %t/miss-tu.txt 2>&1
// RUN: cat %t/miss-tu.txt | FileCheck %s -check-prefix=CACHE-MISS

// CACHE-MISS: compile job cache miss

// RUN: (cd %t/dir2; %clang @B.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-HIT
// RUN: (cd %t/dir2; %clang @A.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-HIT
// RUN: (cd %t/dir2; %clang @tu.cc1.rsp) 2>&1 | FileCheck %s -check-prefix=CACHE-HIT
// RUN: cd %t/dir2 && %clang @B.cc1.rsp > %t/hit-B.txt 2>&1
// RUN: cat %t/hit-B.txt | FileCheck %s -check-prefix=CACHE-HIT
// RUN: cd %t/dir2 && %clang @A.cc1.rsp > %t/hit-A.txt 2>&1
// RUN: cat %t/hit-B.txt | FileCheck %s -check-prefix=CACHE-HIT
// RUN: cd %t/dir2 && %clang @tu.cc1.rsp > %t/hit-tu.txt 2>&1
// RUN: cat %t/hit-tu.txt | FileCheck %s -check-prefix=CACHE-HIT

// CACHE-HIT: compile job cache hit

Expand Down
Loading