Allow args, includes, and splits in file_test includes (#5610)

This builds a mechanism for the toolchain to construct more complex
min_prelude files, which in turn should allow the toolchain to stop
special-casing the min_prelude directory. For example, instead of:

```
      args.insert(args.end(), {"--custom-core",
                               "--exclude-dump-file-prefix=include_files/"});
```

This should allow (in a `min_prelude` file):

```
// EXTRA-ARGS: --custom-core --exclude-dump-file-prefix=include_files/
```

Then when that min_prelude is included, it'd be used.

But also, this should allow sharing between min_prelude files with use
of `INCLUDE-FILE`, which as we make progressively more complex
min_preludes might become useful.
This commit is contained in:
Jon Ross-Perkins
2025-06-05 16:23:15 +00:00
committed by GitHub
parent a508b00883
commit 51b4abec20
18 changed files with 396 additions and 152 deletions
+18 -16
View File
@@ -126,6 +126,19 @@ static auto TestCaptureConsoleOutput(TestParams& params)
return {{.success = true}};
}
// Prints and returns expected results for escaping.carbon.
static auto TestEscaping(TestParams& params)
-> ErrorOr<FileTestBaseTest::RunResult> {
params.error_stream << "carriage return\r\n"
"{one brace}\n"
"{{two braces}}\n"
"[one bracket]\n"
"[[two brackets]]\n"
"end of line whitespace \n"
"\ttabs\t\n";
return {{.success = true}};
}
// Prints and returns expected results for example.carbon.
static auto TestExample(TestParams& params)
-> ErrorOr<FileTestBaseTest::RunResult> {
@@ -189,19 +202,6 @@ static auto TestNoLineNumber(TestParams& params)
return {{.success = true}};
}
// Prints and returns expected results for escaping.carbon.
static auto TestEscaping(TestParams& params)
-> ErrorOr<FileTestBaseTest::RunResult> {
params.error_stream << "carriage return\r\n"
"{one brace}\n"
"{{two braces}}\n"
"[one bracket]\n"
"[[two brackets]]\n"
"end of line whitespace \n"
"\ttabs\t\n";
return {{.success = true}};
}
// Prints and returns expected results for unattached_multi_file.carbon.
static auto TestUnattachedMultiFile(TestParams& params)
-> ErrorOr<FileTestBaseTest::RunResult> {
@@ -269,9 +269,11 @@ auto FileTestBaseTest::Run(
PrintArgs(test_args, output_stream);
auto filename = std::filesystem::path(test_name().str()).filename();
if (filename == "args.carbon" || filename == "include_file.carbon") {
// 'args.carbon' and 'include_file.carbon' have custom arguments, so don't
// do regular argument validation for them.
if (filename == "args.carbon" || filename == "include_args.carbon" ||
filename == "include_extra_args.carbon" ||
filename == "include_args_and_extra_args.carbon") {
// These files are testing argument behavior, which doesn't work with the
// default test logic.
return {{.success = true}};
}