File: resource_directory.c

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (46 lines) | stat: -rw-r--r-- 2,407 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// REQUIRES: shell

// RUN: rm -rf %t && mkdir %t
// RUN: cp %S/Inputs/resource_directory/* %t

// Deduce the resource directory from the compiler path.
//
// With `%clang-scan-deps --resource-dir-recipe modify-compiler-path`, the
// resource directory should be identical to `%clang -print-resource-dir`.
// (Assuming both binaries are built from the same Git checkout.)
// Here we get the expected path by running `%clang -print-resource-dir` and
// then verify `%clang-scan-deps` arrives at the same path by calling the
// `Driver::GetResourcesPath` function.
//
// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir`
// RUN: sed -e "s|CLANG|%clang|g" -e "s|DIR|%/t|g" \
// RUN:   %S/Inputs/resource_directory/cdb.json.template > %t/cdb_path.json
//
// RUN: clang-scan-deps -compilation-database %t/cdb_path.json --format experimental-full \
// RUN:   --resource-dir-recipe modify-compiler-path > %t/result_path.json
// RUN: cat %t/result_path.json | sed 's:\\\\\?:/:g' \
// RUN:   | FileCheck %s --check-prefix=CHECK-PATH -DEXPECTED_RESOURCE_DIR="$EXPECTED_RESOURCE_DIR"
// CHECK-PATH:      "-resource-dir"
// CHECK-PATH-NEXT: "[[EXPECTED_RESOURCE_DIR]]"

// Run the compiler and ask it for the resource directory.
//
// With `%clang-scan-deps --resource-dir-recipe invoke-compiler`, the resource
// directory should be identical to `<clang> -print-resource-dir`, where <clang>
// is an arbitrary version of Clang. (This configuration is not really supported.)
// Here we hard-code the expected path into `%t/compiler` and then verify
// `%clang-scan-deps` arrives at the path by actually running the executable.
//
// RUN: EXPECTED_RESOURCE_DIR="/custom/compiler/resources"
// RUN: echo "#!/bin/sh"                      > %t/compiler
// RUN: echo "echo '$EXPECTED_RESOURCE_DIR'" >> %t/compiler
// RUN: chmod +x %t/compiler
// RUN: sed -e "s|CLANG|%/t/compiler|g" -e "s|DIR|%/t|g" \
// RUN:   %S/Inputs/resource_directory/cdb.json.template > %t/cdb_invocation.json
//
// RUN: clang-scan-deps -compilation-database %t/cdb_invocation.json --format experimental-full \
// RUN:   --resource-dir-recipe invoke-compiler > %t/result_invocation.json
// RUN: cat %t/result_invocation.json | sed 's:\\\\\?:/:g' \
// RUN:   | FileCheck %s --check-prefix=CHECK-PATH -DEXPECTED_RESOURCE_DIR="$EXPECTED_RESOURCE_DIR"
// CHECK-INVOCATION:      "-resource-dir"
// CHECK-INVOCATION-NEXT: "[[EXPECTED_RESOURCE_DIR]]"