mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 07:21:04 +01:00
Make the file_test binary work without custom environment variables. (#5442)
Instead of crashing when run outside of `bazel`, make the toolchain's `file_test` binary work properly when no test-specific environment variables are set. This makes it a lot easier to run `file_test` under a debugger. There are two main changes here: - Don't crash if `$TEST_TMPDIR` is unset. Instead, fall back to LLVM's temporary directory (typically `$TMPDIR`). We already did this in some places in tests. We now do it in more places. - Don't fall back to a target label of `<target>` in the reproduction commands if `$TEST_TARGET` is unset, because this causes all the tests to fail because their output doesn't match the expected output due to a differing bazel run command. Instead explicitly specify the target from the `FileTestBase`-derived class. Infrastructure for this has been added generally, but only rolled out to the toolchain `file_test` binary for now. --------- Co-authored-by: Jon Ross-Perkins <jperkins@google.com>
This commit is contained in:
co-authored by
Jon Ross-Perkins
parent
f2a16d8742
commit
66caff2c26
@@ -14,6 +14,7 @@
|
||||
#include "llvm/ADT/StringMap.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/PrettyStackTrace.h"
|
||||
#include "testing/base/file_helpers.h"
|
||||
#include "testing/file_test/file_test_base.h"
|
||||
#include "testing/file_test/test_file.h"
|
||||
|
||||
@@ -62,8 +63,7 @@ static auto DoArgReplacements(llvm::SmallVector<std::string>& test_args,
|
||||
break;
|
||||
}
|
||||
case 't': {
|
||||
char* tmpdir = getenv("TEST_TMPDIR");
|
||||
CARBON_CHECK(tmpdir != nullptr);
|
||||
std::filesystem::path tmpdir = GetTempDirectory();
|
||||
it->replace(percent, 2, llvm::formatv("{0}/temp_file", tmpdir));
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user