Adjust ordering of EXTRA-ARGS to allow tests to override includes (#5870)

This commit is contained in:
Jon Ross-Perkins
2025-07-29 20:22:51 +00:00
committed by GitHub
parent 3d6395b75a
commit 64c31a6b9f
3 changed files with 11 additions and 2 deletions
+2
View File
@@ -217,6 +217,8 @@ Supported comment markers are:
- `// ARGS`
- `// EXTRA-ARGS`
- Included `EXTRA-ARGS` will come before `EXTRA-ARGS` in the main test
file.
- `// INCLUDE-FILE`
- `// --- <filename>`
+8 -1
View File
@@ -797,10 +797,14 @@ auto ProcessTestFile(llvm::StringRef test_name, bool running_autoupdate)
// (recursively).
llvm::SmallVector<std::string> include_files;
// Store the main file's `EXTRA-ARGS` so that they can be put after any that
// come from `INCLUDE-FILE`.
llvm::SmallVector<std::string> main_extra_args;
// Process the main file.
CARBON_RETURN_IF_ERROR(ProcessFileContent(
test_name, test_file.input_content, running_autoupdate, &test_file,
&found_autoupdate, test_file.test_args, test_file.extra_args,
&found_autoupdate, test_file.test_args, main_extra_args,
test_file.file_splits, include_files));
if (!found_autoupdate) {
@@ -859,6 +863,9 @@ auto ProcessTestFile(llvm::StringRef test_name, bool running_autoupdate)
}
}
// Copy over `EXTRA-ARGS` from the main file (after includes).
test_file.extra_args.append(main_extra_args);
return std::move(test_file);
}
+1 -1
View File
@@ -11,4 +11,4 @@
// TIP: To dump output, run:
// TIP: bazel run //testing/file_test:file_test_base_test -- --dump_output --file_tests=testing/file_test/testdata/include_extra_args.carbon
// CHECK:STDOUT: 6 args: `default_args`, `include_extra_args.carbon`, `include_files/extra_args.carbon`, `foo`, `bar`, `baz`
// CHECK:STDOUT: 6 args: `default_args`, `include_extra_args.carbon`, `include_files/extra_args.carbon`, `bar`, `baz`, `foo`