llvm-project/clang/test/Driver/modules-cache-path.m
Colin Cross 7fe475756b Set HOME for tests that use module cache path
Getting the default module cache path calls llvm::sys::path::cache_directory,
which calls home_directory, which checks the HOME environment variable
before falling back to getpwuid.  When compiling against musl libc,
which does not support NSS, and running on a machine that doesn't have
the current user in /etc/passwd due to NSS, no home directory can
be found.  Set the HOME environment variable in the tests to avoid
depending on getpwuid.

Reviewed By: pirama, srhines

Differential Revision: https://reviews.llvm.org/D132984
2022-09-15 23:58:57 +00:00

11 lines
496 B
Matlab

// RUN: env HOME=%t.home %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=CHECK-DEFAULT
// CHECK-DEFAULT: -fmodules-cache-path={{.*}}clang{{[/\\]+}}ModuleCache
// RUN: env CLANG_MODULE_CACHE_PATH=/dev/null \
// RUN: %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=OVERRIDE
// OVERRIDE: -fmodules-cache-path=/dev/null
// RUN: env CLANG_MODULE_CACHE_PATH= \
// RUN: %clang -fmodules -### %s 2>&1 | FileCheck %s -check-prefix=DISABLE
// DISABLE-NOT: -fmodules-cache-path=