mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-09-24 19:50:14 +01:00
Adjust ordering of EXTRA-ARGS to allow tests to override includes (#5870)
This commit is contained in:
@@ -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>`
|
||||
|
||||
|
||||
@@ -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
@@ -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`
|
||||
|
||||
Reference in New Issue
Block a user