https://github.com/Harini0924 updated https://github.com/llvm/llvm-project/pull/102647
>From 658af04b25dfdb00d418936d576d13f301ffe0e6 Mon Sep 17 00:00:00 2001 From: Harini <harinidonth...@google.com> Date: Tue, 6 Aug 2024 04:40:30 +0000 Subject: [PATCH 1/4] [llvm-lit] Replace Shell Substitutions with lit Syntax for Environment Variables This patch updates the llvm-lit 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. The changes ensure that environment variables are properly set and accessed within the lit environment. This update applies to both the handling of the `DEFAULT_TRIPLE` variable `EXPECTED_RESOURCE_DIR` variable. This change will allow the tests to pass and ensure the compatibilty with the lit internal shell framework. --- clang/test/ClangScanDeps/pr61006.cppm | 12 ++++++------ clang/test/Driver/coverage.c | 4 ++-- clang/test/Driver/program-path-priority.c | 13 +++++++------ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/clang/test/ClangScanDeps/pr61006.cppm b/clang/test/ClangScanDeps/pr61006.cppm index f75edd38c81ba9..8e1a7a4997165f 100644 --- a/clang/test/ClangScanDeps/pr61006.cppm +++ b/clang/test/ClangScanDeps/pr61006.cppm @@ -6,13 +6,13 @@ // RUN: mkdir -p %t // RUN: split-file %s %t // -// RUN: EXPECTED_RESOURCE_DIR=`%clang -print-resource-dir` && \ +// RUN: %clang -print-resource-dir > %t/resource-dir.txt && \ // RUN: ln -s %clang++ %t/clang++ && \ -// RUN: sed "s|EXPECTED_RESOURCE_DIR|$EXPECTED_RESOURCE_DIR|g; s|DIR|%/t|g" %t/P1689.json.in > %t/P1689.json && \ -// RUN: clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | FileCheck %t/a.cpp -DPREFIX=%/t && \ -// RUN: clang-scan-deps -format=p1689 \ -// RUN: -- %t/clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/a.cpp -o %t/a.o \ -// RUN: -resource-dir $EXPECTED_RESOURCE_DIR | FileCheck %t/a.cpp -DPREFIX=%/t +// RUN: sed "s|EXPECTED_RESOURCE_DIR|%{readfile:%t/resource-dir.txt}|g; s|DIR|%/t|g" %t/P1689.json.in > %t/P1689.json && \ +// RUN: env EXPECTED_RESOURCE_DIR=%{readfile:%t/resource-dir.txt} clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | FileCheck %t/a.cpp -DPREFIX=%/t && \ +// RUN: env EXPECTED_RESOURCE_DIR=%{readfile:%t/resource-dir.txt} clang-scan-deps -format=p1689 \ +// RUN: -- %t/clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/a.cpp -o %t/a.o \ +// RUN: -resource-dir %{env:EXPECTED_RESOURCE_DIR} | FileCheck %t/a.cpp -DPREFIX=%/t //--- P1689.json.in [ diff --git a/clang/test/Driver/coverage.c b/clang/test/Driver/coverage.c index e5ed064aab457c..ab791ada2d351a 100644 --- a/clang/test/Driver/coverage.c +++ b/clang/test/Driver/coverage.c @@ -18,7 +18,7 @@ // GCNO-LOCATION-REL: "-coverage-notes-file={{.*}}{{/|\\\\}}foo/bar.gcno" /// GCC allows PWD to change the paths. -// RUN: %if system-linux %{ PWD=/proc/self/cwd %clang -### -c --coverage %s -o foo/bar.o 2>&1 | FileCheck --check-prefix=PWD %s %} +// RUN: %if system-linux %{ env PWD=/proc/self/cwd %clang -### -c --coverage %s -o foo/bar.o 2>&1 | FileCheck --check-prefix=PWD %s %} // PWD: "-coverage-notes-file=/proc/self/cwd/foo/bar.gcno" "-coverage-data-file=/proc/self/cwd/foo/bar.gcda" /// Don't warn -Wunused-command-line-argument. @@ -50,6 +50,6 @@ // LINK2: -cc1{{.*}} "-coverage-notes-file={{.*}}{{/|\\\\}}f/gb.gcno" "-coverage-data-file={{.*}}{{/|\\\\}}f/gb.gcda" /// GCC allows PWD to change the paths. -// RUN: %if system-linux %{ PWD=/proc/self/cwd %clang -### --coverage d/a.c d/b.c -o e/x -fprofile-dir=f 2>&1 | FileCheck %s --check-prefix=LINK3 %} +// RUN: %if system-linux %{ env PWD=/proc/self/cwd %clang -### --coverage d/a.c d/b.c -o e/x -fprofile-dir=f 2>&1 | FileCheck %s --check-prefix=LINK3 %} // LINK3: -cc1{{.*}} "-coverage-notes-file=/proc/self/cwd/e/x-a.gcno" "-coverage-data-file=f/proc/self/cwd/e/x-a.gcda" // LINK3: -cc1{{.*}} "-coverage-notes-file=/proc/self/cwd/e/x-b.gcno" "-coverage-data-file=f/proc/self/cwd/e/x-b.gcda" diff --git a/clang/test/Driver/program-path-priority.c b/clang/test/Driver/program-path-priority.c index c940c4ced94420..2b25cad9f30538 100644 --- a/clang/test/Driver/program-path-priority.c +++ b/clang/test/Driver/program-path-priority.c @@ -87,12 +87,13 @@ /// <default-triple>-gcc has lowest priority so <triple>-gcc /// on PATH beats default triple in program path -// RUN: DEFAULT_TRIPLE=`%t/clang --version | grep "Target:" | cut -d ' ' -f2` -// RUN: touch %t/$DEFAULT_TRIPLE-gcc && chmod +x %t/$DEFAULT_TRIPLE-gcc -// RUN: touch %t/%target_triple-gcc && chmod +x %t/%target_triple-gcc -// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \ -// RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_GCC %s -// DEFAULT_TRIPLE_GCC: env/notreal-none-elf-gcc" +// RUN: %clang --version | grep "Target:" | cut -d ' ' -f2 > %t/default-triple.txt +// RUN: env DEFAULT_TRIPLE=%{readfile:%t/default-triple.txt} +// RUN: touch %t/%{env:DEFAULT_TRIPLE}-gcc && chmod +x %t/%{env:DEFAULT_TRIPLE}-gcc +// RUN: touch %t/%target_triple-gcc && chmod +x %t/%target_triple-gcc && +// RUN: env "PATH=%t:$PATH" %t/clang -### -target notreal-none-elf %s 2>&1 | \ +// RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_GCC %s +// DEFAULT_TRIPLE_GCC: "gcc" "-o" "a.out" /// plain gcc on PATH beats default triple in program path // RUN: rm %t/env/notreal-none-elf-gcc >From ef540341122c2f870bd719d6563a62aa10108111 Mon Sep 17 00:00:00 2001 From: Harini <harinidonth...@google.com> Date: Fri, 9 Aug 2024 17:13:44 +0000 Subject: [PATCH 2/4] [llvm-lit] Update to Use lit Syntax for Environment Variables This patch updates the llvm-lit clang tests by replacing shell command substitutions with lit-compatible syntax for setting and referencing environment variables. Shell-style variable substitution (e.g., DEFAULT_TRIPLE=\`` and EXPECTED_RESOURCE_DIR=`) has been replaced with env and%{env}to ensure compatibility with lit's internal shell. This change fixes issues encountered when running tests with LIT_USE_INTERNAL_SHELL=1 ninja check-clang, where shell commands failed due to improper handling of environment variables. Additionally, env has been added to the PWD variable setting to ensure it is correctly established within the lit internal shell. These updates ensure that the tests pass and function as expected within the lit framework. --- clang/test/ClangScanDeps/pr61006.cppm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/test/ClangScanDeps/pr61006.cppm b/clang/test/ClangScanDeps/pr61006.cppm index 8e1a7a4997165f..9ce6edaf2010e1 100644 --- a/clang/test/ClangScanDeps/pr61006.cppm +++ b/clang/test/ClangScanDeps/pr61006.cppm @@ -11,8 +11,8 @@ // RUN: sed "s|EXPECTED_RESOURCE_DIR|%{readfile:%t/resource-dir.txt}|g; s|DIR|%/t|g" %t/P1689.json.in > %t/P1689.json && \ // RUN: env EXPECTED_RESOURCE_DIR=%{readfile:%t/resource-dir.txt} clang-scan-deps -compilation-database %t/P1689.json -format=p1689 | FileCheck %t/a.cpp -DPREFIX=%/t && \ // RUN: env EXPECTED_RESOURCE_DIR=%{readfile:%t/resource-dir.txt} clang-scan-deps -format=p1689 \ -// RUN: -- %t/clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/a.cpp -o %t/a.o \ -// RUN: -resource-dir %{env:EXPECTED_RESOURCE_DIR} | FileCheck %t/a.cpp -DPREFIX=%/t +// RUN: -- %t/clang++ -std=c++20 -c -fprebuilt-module-path=%t %t/a.cpp -o %t/a.o \ +// RUN: -resource-dir %{env:EXPECTED_RESOURCE_DIR} | FileCheck %t/a.cpp -DPREFIX=%/t //--- P1689.json.in [ >From e2e5e2b2c53c90b14f2acbb3f0ca5bd9ecb621c1 Mon Sep 17 00:00:00 2001 From: Harini <harinidonth...@google.com> Date: Fri, 9 Aug 2024 20:55:34 +0000 Subject: [PATCH 3/4] [llvm-lit] Changed the PATH and FileCheck lines to original state i accidentally changed the PATH and FileCheck lines in my last commit. This patch changes it back to its original state --- clang/test/Driver/program-path-priority.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/clang/test/Driver/program-path-priority.c b/clang/test/Driver/program-path-priority.c index 2b25cad9f30538..da2b5d6b596d14 100644 --- a/clang/test/Driver/program-path-priority.c +++ b/clang/test/Driver/program-path-priority.c @@ -87,13 +87,12 @@ /// <default-triple>-gcc has lowest priority so <triple>-gcc /// on PATH beats default triple in program path -// RUN: %clang --version | grep "Target:" | cut -d ' ' -f2 > %t/default-triple.txt -// RUN: env DEFAULT_TRIPLE=%{readfile:%t/default-triple.txt} -// RUN: touch %t/%{env:DEFAULT_TRIPLE}-gcc && chmod +x %t/%{env:DEFAULT_TRIPLE}-gcc -// RUN: touch %t/%target_triple-gcc && chmod +x %t/%target_triple-gcc && -// RUN: env "PATH=%t:$PATH" %t/clang -### -target notreal-none-elf %s 2>&1 | \ -// RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_GCC %s -// DEFAULT_TRIPLE_GCC: "gcc" "-o" "a.out" +// RUN: %clang --version | grep "Target:" | cut -d ' ' -f2 > %t/default-triple.txt +// RUN: env DEFAULT_TRIPLE=%{readfile:%t/default-triple.txt} touch %t/%{env:DEFAULT_TRIPLE}-gcc && chmod +x %t/%{env:DEFAULT_TRIPLE}-gcc +// RUN: touch %t/%target_triple-gcc && chmod +x %t/%target_triple-gcc +// RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \ +// RUN: FileCheck --check-prefix=DEFAULT_TRIPLE_GCC %s +// DEFAULT_TRIPLE_GCC: env/notreal-none-elf-gcc" /// plain gcc on PATH beats default triple in program path // RUN: rm %t/env/notreal-none-elf-gcc >From 2fd03cfede28337e233f710b310f322e51f87b78 Mon Sep 17 00:00:00 2001 From: Harini <harinidonth...@google.com> Date: Tue, 13 Aug 2024 06:22:31 +0000 Subject: [PATCH 4/4] [llvm-lit] added %t/clang --- clang/test/Driver/program-path-priority.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Driver/program-path-priority.c b/clang/test/Driver/program-path-priority.c index da2b5d6b596d14..358a06d7c6d1b5 100644 --- a/clang/test/Driver/program-path-priority.c +++ b/clang/test/Driver/program-path-priority.c @@ -87,7 +87,7 @@ /// <default-triple>-gcc has lowest priority so <triple>-gcc /// on PATH beats default triple in program path -// RUN: %clang --version | grep "Target:" | cut -d ' ' -f2 > %t/default-triple.txt +// RUN: %t/clang --version | grep "Target:" | cut -d ' ' -f2 > %t/default-triple.txt // RUN: env DEFAULT_TRIPLE=%{readfile:%t/default-triple.txt} touch %t/%{env:DEFAULT_TRIPLE}-gcc && chmod +x %t/%{env:DEFAULT_TRIPLE}-gcc // RUN: touch %t/%target_triple-gcc && chmod +x %t/%target_triple-gcc // RUN: env "PATH=%t/env/" %t/clang -### -target notreal-none-elf %s 2>&1 | \ _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits