1b8b14b68SJan Svoboda // REQUIRES: shell 2b8b14b68SJan Svoboda 3b8b14b68SJan Svoboda // RUN: rm -rf %t && mkdir %t 4b8b14b68SJan Svoboda // RUN: cp %S/Inputs/resource_directory/* %t 5b8b14b68SJan Svoboda 6b8b14b68SJan Svoboda // Deduce the resource directory from the compiler path. 7b8b14b68SJan Svoboda // 8*47eec789SJan Svoboda // With `%clang-scan-deps --resource-dir-recipe modify-compiler-path`, the 9*47eec789SJan Svoboda // resource directory should be identical to `%clang -print-resource-dir`. 10*47eec789SJan Svoboda // (Assuming both binaries are built from the same Git checkout.) 11*47eec789SJan Svoboda // Here we get the expected path by running `%clang -print-resource-dir` and 12*47eec789SJan Svoboda // then verify `%clang-scan-deps` arrives at the same path by calling the 13*47eec789SJan Svoboda // `Driver::GetResourcesPath` function. 14*47eec789SJan Svoboda // 15*47eec789SJan Svoboda // RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir` 16*47eec789SJan Svoboda // RUN: sed -e "s|CLANG|%clang|g" -e "s|DIR|%/t|g" \ 17b8b14b68SJan Svoboda // RUN: %S/Inputs/resource_directory/cdb.json.template > %t/cdb_path.json 18*47eec789SJan Svoboda // 19b8b14b68SJan Svoboda // RUN: clang-scan-deps -compilation-database %t/cdb_path.json --format experimental-full \ 20b8b14b68SJan Svoboda // RUN: --resource-dir-recipe modify-compiler-path > %t/result_path.json 21*47eec789SJan Svoboda // RUN: cat %t/result_path.json | sed 's:\\\\\?:/:g' \ 22*47eec789SJan Svoboda // RUN: | FileCheck %s --check-prefix=CHECK-PATH -DEXPECTED_RESOURCE_DIR="$EXPECTED_RESOURCE_DIR" 23b8b14b68SJan Svoboda // CHECK-PATH: "-resource-dir" 24*47eec789SJan Svoboda // CHECK-PATH-NEXT: "[[EXPECTED_RESOURCE_DIR]]" 25b8b14b68SJan Svoboda 26b8b14b68SJan Svoboda // Run the compiler and ask it for the resource directory. 27b8b14b68SJan Svoboda // 28*47eec789SJan Svoboda // With `%clang-scan-deps --resource-dir-recipe invoke-compiler`, the resource 29*47eec789SJan Svoboda // directory should be identical to `<clang> -print-resource-dir`, where <clang> 30*47eec789SJan Svoboda // is an arbitrary version of Clang. (This configuration is not really supported.) 31*47eec789SJan Svoboda // Here we hard-code the expected path into `%t/compiler` and then verify 32*47eec789SJan Svoboda // `%clang-scan-deps` arrives at the path by actually running the executable. 33*47eec789SJan Svoboda // 34*47eec789SJan Svoboda // RUN: EXPECTED_RESOURCE_DIR="/custom/compiler/resources" 35*47eec789SJan Svoboda // RUN: echo "#!/bin/sh" > %t/compiler 36*47eec789SJan Svoboda // RUN: echo "echo '$EXPECTED_RESOURCE_DIR'" >> %t/compiler 37b8b14b68SJan Svoboda // RUN: chmod +x %t/compiler 38b8b14b68SJan Svoboda // RUN: sed -e "s|CLANG|%/t/compiler|g" -e "s|DIR|%/t|g" \ 39b8b14b68SJan Svoboda // RUN: %S/Inputs/resource_directory/cdb.json.template > %t/cdb_invocation.json 40*47eec789SJan Svoboda // 41b8b14b68SJan Svoboda // RUN: clang-scan-deps -compilation-database %t/cdb_invocation.json --format experimental-full \ 42b8b14b68SJan Svoboda // RUN: --resource-dir-recipe invoke-compiler > %t/result_invocation.json 43*47eec789SJan Svoboda // RUN: cat %t/result_invocation.json | sed 's:\\\\\?:/:g' \ 44*47eec789SJan Svoboda // RUN: | FileCheck %s --check-prefix=CHECK-PATH -DEXPECTED_RESOURCE_DIR="$EXPECTED_RESOURCE_DIR" 45b8b14b68SJan Svoboda // CHECK-INVOCATION: "-resource-dir" 46*47eec789SJan Svoboda // CHECK-INVOCATION-NEXT: "[[EXPECTED_RESOURCE_DIR]]" 47