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:
Jon Ross-Perkins authored and GitHub committed 2023-09-14 19:48:29 +00:00
1 parent e72226f31c
commit d0b2b7bc41
4 files changed
+48 -18

No files matched your search

+5 -3
View File
@@ -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;
}