mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 22:02:55 +01:00
When running FileTests, verify that autoupdate wouldn't make changes. (#3232)
Trying to more proactively catch when autoupdate is missed. Most of the execution time of these tests should be in running the program under test, not processing output, so this should have marginal overhead in order to produce a useful reminder.
This commit is contained in:
@@ -258,7 +258,7 @@ auto FileTestAutoupdater::StartSplitFile() -> void {
|
||||
++non_check_line_;
|
||||
}
|
||||
|
||||
auto FileTestAutoupdater::Run() -> bool {
|
||||
auto FileTestAutoupdater::Run(bool dry_run) -> bool {
|
||||
bool any_attached_stdout_lines = std::any_of(
|
||||
stdout_.lines.begin(), stdout_.lines.end(),
|
||||
[&](const CheckLine& line) { return line.line_number() != -1; });
|
||||
@@ -330,8 +330,10 @@ auto FileTestAutoupdater::Run() -> bool {
|
||||
if (new_content == input_content_) {
|
||||
return false;
|
||||
}
|
||||
std::ofstream out(file_test_path_);
|
||||
out << new_content;
|
||||
if (!dry_run) {
|
||||
std::ofstream out(file_test_path_);
|
||||
out << new_content;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user