mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
Do not load prelude files to the test file system in no-prelude tests (#4697)
These tests do not import prelude so the files do not need to exist, and only make the tests more complex, as they include extra unnecessary inputs.
This commit is contained in:
@@ -38,8 +38,10 @@ class ToolchainFileTest : public FileTestBase {
|
||||
llvm::raw_pwrite_stream& stdout, llvm::raw_pwrite_stream& stderr)
|
||||
-> ErrorOr<RunResult> override {
|
||||
CARBON_ASSIGN_OR_RETURN(auto prelude, installation_.ReadPreludeManifest());
|
||||
for (const auto& file : prelude) {
|
||||
CARBON_RETURN_IF_ERROR(AddFile(*fs, file));
|
||||
if (!is_no_prelude()) {
|
||||
for (const auto& file : prelude) {
|
||||
CARBON_RETURN_IF_ERROR(AddFile(*fs, file));
|
||||
}
|
||||
}
|
||||
|
||||
Driver driver(fs, &installation_, stdout, stderr);
|
||||
@@ -83,8 +85,7 @@ class ToolchainFileTest : public FileTestBase {
|
||||
// For `lex` and `parse`, we don't need to import the prelude; exclude it to
|
||||
// focus errors. In other phases we only do this for explicit "no_prelude"
|
||||
// tests.
|
||||
if (component_ == "lex" || component_ == "parse" ||
|
||||
test_name().find("/no_prelude/") != llvm::StringRef::npos) {
|
||||
if (component_ == "lex" || component_ == "parse" || is_no_prelude()) {
|
||||
args.push_back("--no-prelude-import");
|
||||
}
|
||||
|
||||
@@ -161,6 +162,10 @@ class ToolchainFileTest : public FileTestBase {
|
||||
return test_name;
|
||||
}
|
||||
|
||||
auto is_no_prelude() const -> bool {
|
||||
return test_name().find("/no_prelude/") != llvm::StringRef::npos;
|
||||
}
|
||||
|
||||
const llvm::StringRef component_;
|
||||
const InstallPaths installation_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user