Switch test manifests to embedded C++ (#5036)

Inconsistent execution environments make using a path-as-define
difficult, so switch to an embedded file.

Also fixes the lldb launch so that passing tests run cleanly, and adds
TEST_TARGET to gdb (but without testing there). I'm dropping `sourceMap`
because it's not handled quite correctly (also not great to be trying to
pass source mappings in two different ways), and `env` didn't seem to be
working as intended either; maybe specifying `initCommands` causes other
things to not be evaluated. But the straight `initCommands` looks like
it's working. I used lldb to validate execution of these changes.

```
Running initCommands:
(lldb) command script import external/+llvm_project+llvm-project/llvm/utils/lldbDataFormatters.py
(lldb) settings set target.source-map "." "/usr/local/google/home/jperkins/dev/carbon-lang"
(lldb) settings set target.source-map "/proc/self/cwd" "/usr/local/google/home/jperkins/dev/carbon-lang"
(lldb) env TEST_TARGET=//toolchain/testing:file_test
(lldb) env TEST_TMPDIR=/tmp
Running tests with 128 thread(s)
.
Done!
Note: Google Test filter = ToolchainFileTest.toolchain/check/testdata/const/collapse.carbon
[==========] Running 1 test from 1 test suite.
[----------] Global test environment set-up.
[----------] 1 test from ToolchainFileTest
[ RUN      ] ToolchainFileTest.toolchain/check/testdata/const/collapse.carbon
[       OK ] ToolchainFileTest.toolchain/check/testdata/const/collapse.carbon (0 ms)
[----------] 1 test from ToolchainFileTest (0 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (1 ms total)
[  PASSED  ] 1 test.
Process 3869310 exited with status = 0 (0x00000000) 
```
This commit is contained in:
Jon Ross-Perkins
2025-02-27 23:31:13 +00:00
committed by GitHub
parent 80e1a6ef61
commit 536bfd9cbf
13 changed files with 154 additions and 60 deletions
+10 -2
View File
@@ -3,10 +3,13 @@
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#include "absl/flags/flag.h"
#include "absl/strings/str_split.h"
#include "common/raw_string_ostream.h"
#include "explorer/main.h"
#include "re2/re2.h"
#include "testing/base/file_helpers.h"
#include "testing/file_test/file_test_base.h"
#include "testing/file_test/manifest.h"
ABSL_FLAG(bool, trace, false,
"Set to true to run tests with tracing enabled, even if they don't "
@@ -115,8 +118,13 @@ class ExplorerFileTest : public FileTestBase {
} // namespace
// Explorer uses a non-standard approach to getting the manifest path.
auto GetFileTestManifestPath() -> std::filesystem::path {
return absl::GetFlag(FLAGS_explorer_test_targets_file);
auto GetFileTestManifest() -> llvm::SmallVector<std::string> {
llvm::SmallVector<std::string> manifest;
auto content = ReadFile(absl::GetFlag(FLAGS_explorer_test_targets_file));
for (const auto& line : absl::StrSplit(*content, "\n", absl::SkipEmpty())) {
manifest.push_back(std::string(line));
}
return manifest;
}
CARBON_FILE_TEST_FACTORY(ExplorerFileTest)