mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 18:51:11 +01:00
Fix toolchain file_test_base multi-file integration. (#3780)
test_args will never contain %s; switch to filtering arguments, and handle the edge cases.
This commit is contained in:
@@ -73,11 +73,12 @@ static auto CompareFailPrefix(llvm::StringRef filename, bool success) -> void {
|
||||
if (success) {
|
||||
EXPECT_FALSE(filename.starts_with("fail_"))
|
||||
<< "`" << filename
|
||||
<< "` succeeded; if this is correct, add a `fail_` prefix.";
|
||||
<< "` succeeded; if success is expected, remove the `fail_` "
|
||||
"prefix.";
|
||||
} else {
|
||||
EXPECT_TRUE(filename.starts_with("fail_"))
|
||||
<< "`" << filename
|
||||
<< "` failed; if this is correct, remove the `fail_` prefix.";
|
||||
<< "` failed; if failure is expected, add the `fail_` prefix.";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -2,7 +2,7 @@
|
||||
// Exceptions. See /LICENSE for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
// ARGS: compile nonexistent.carbon
|
||||
// ARGS: compile not_file.carbon
|
||||
//
|
||||
// AUTOUPDATE
|
||||
// CHECK:STDERR: nonexistent.carbon: ERROR: Error opening file for read: No such file or directory
|
||||
// CHECK:STDERR: not_file.carbon: ERROR: Error opening file for read: No such file or directory
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringRef.h"
|
||||
#include "llvm/Support/FormatVariadic.h"
|
||||
@@ -29,16 +30,18 @@ class ToolchainFileTest : public FileTestBase {
|
||||
llvm::raw_pwrite_stream& stderr) -> ErrorOr<RunResult> override {
|
||||
Driver driver(fs, stdout, stderr);
|
||||
auto driver_result = driver.RunCommand(test_args);
|
||||
if (std::find(test_args.begin(), test_args.end(), "%s") ==
|
||||
test_args.end()) {
|
||||
// Files weren't forwarded as an argument, so don't use per_file_success.
|
||||
// This primarily occurs in driver tests with invalid filename arguments,
|
||||
// which we wouldn't want to try validating.
|
||||
return {{.success = driver_result.success}};
|
||||
} else {
|
||||
return {{.success = driver_result.success,
|
||||
.per_file_success = std::move(driver_result.per_file_success)}};
|
||||
}
|
||||
|
||||
RunResult result{
|
||||
.success = driver_result.success,
|
||||
.per_file_success = std::move(driver_result.per_file_success)};
|
||||
// Drop entries that don't look like a file. Note this can empty out the
|
||||
// list.
|
||||
llvm::erase_if(result.per_file_success,
|
||||
[](std::pair<llvm::StringRef, bool> entry) {
|
||||
return entry.first == "." || entry.first == "-" ||
|
||||
entry.first.starts_with("not_file");
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
||||
auto GetDefaultArgs() -> llvm::SmallVector<std::string> override {
|
||||
|
||||
Reference in New Issue
Block a user