Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[clang] [test] Use lit Syntax for Environment Variables in Clang subp…
…roject (llvm#102647) This patch updates the clang tests by replacing shell command substitutions with lit-compatible syntax for setting and referencing environment variables. Specifically, the use of shell-style variable substitution (e.g., `DEFAULT_TRIPLE=`and `EXPECTED_RESOURCE_DIR=`) has been replaced with `env` and `%{env}` to align with lit's internal shell requirements. These changes ensure that environment variables are properly set and accessed within the lit environment. When using the lit internal shell with the command `LIT_USE_INTERNAL_SHELL=1 ninja check-clang`, one common error encountered is: ``` FAIL: Clang :: Driver/program-path-priority.c (19 of 20640) ******************** TEST 'Clang :: Driver/program-path-priority.c' FAILED ******************** Exit Code: 127 Command Output (stdout): -- # RUN: at line 90 DEFAULT_TRIPLE=`/usr/local/google/home/harinidonthula/llvm-project/build/tools/clang/test/Driver/Output/program-path-priority.c.tmp/clang --version | grep "Target:" | cut -d ' ' -f2` # executed command: 'DEFAULT_TRIPLE=`/usr/local/google/home/harinidonthula/llvm-project/build/tools/clang/test/Driver/Output/program-path-priority.c.tmp/clang' --version # .---command stderr------------ # | 'DEFAULT_TRIPLE=`/usr/local/google/home/harinidonthula/llvm-project/build/tools/clang/test/Driver/Output/program-path-priority.c.tmp/clang': command not found # `----------------------------- # error: command failed with exit status: 127 ``` To fix this issue, the patch replaces traditional shell substitutions with lit's environment variable handling, ensuring compatibility with the lit internal shell framework. This update applies to both the handling of the `DEFAULT_TRIPLE` and `EXPECTED_RESOURCE_DIR` variables, allowing the tests to pass when using the lit internal shell. The patch also adds `env` to the `PWD` variable setting in the following command to ensure the environment variable is correctly set within the lit internal shell: ``` // RUN: %if system-linux %{ env PWD=/proc/self/cwd %clang -### -c --coverage %s -o foo/bar.o 2>&1 | FileCheck --check-prefix=PWD %s %} ``` fixes: llvm#102395 [link to RFC](https://discourse.llvm.org/t/rfc-enabling-the-lit-internal-shell-by-default/80179)
- Loading branch information