Skip to content

Commit d96f526

Browse files
committed
[clang][test] Disallow using the default module cache path in lit tests
Make the default module cache path invalid when running lit tests so that tests are forced to provide a cache path. This avoids accidentally escaping to the system default location, and would have caught the failure recently found in ClangScanDeps/multiple-commands.c. Differential Revision: https://reviews.llvm.org/D133622
1 parent 2b882f8 commit d96f526

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

clang/test/Driver/modules-cache-path.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-DEFAULT
1+
// RUN: env -u CLANG_MODULE_CACHE_PATH %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-DEFAULT
22
// CHECK-DEFAULT: -fmodules-cache-path={{.*}}clang{{[/\\]+}}ModuleCache
33

44
// RUN: env CLANG_MODULE_CACHE_PATH=/dev/null \

clang/test/Modules/driver.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %clang -fmodules -fimplicit-module-maps %s -### 2>&1 | FileCheck -check-prefix CHECK-NO_MODULE_CACHE %s
1+
// RUN: env -u CLANG_MODULE_CACHE_PATH %clang -fmodules -fimplicit-module-maps %s -### 2>&1 | FileCheck -check-prefix CHECK-NO_MODULE_CACHE %s
22
// RUN: %clang -fmodules -fimplicit-module-maps -fmodules-cache-path=blarg %s -### 2>&1 | FileCheck -check-prefix CHECK-WITH_MODULE_CACHE %s
33

44
// CHECK-NO_MODULE_CACHE: {{clang.*"-fmodules-cache-path=.*ModuleCache"}}

llvm/utils/lit/lit/llvm/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,10 @@ def use_clang(self, additional_tool_dirs=[], additional_flags=[],
495495

496496
self.clear_environment(possibly_dangerous_env_vars)
497497

498+
# Make the default module cache path invalid so that tests are forced to
499+
# provide a cache path if they use implicit modules.
500+
self.with_environment('CLANG_MODULE_CACHE_PATH', '/dev/null')
501+
498502
# Tweak the PATH to include the tools dir and the scripts dir.
499503
# Put Clang first to avoid LLVM from overriding out-of-tree clang
500504
# builds.

0 commit comments

Comments
 (0)