mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-12 20:42:21 +00:00
headless-browser: Only rebaseline tests that would have failed
We have a bit of forgiveness around allowing tests to pass with varying trailing newlines. Only write a rebaselined test to disk if it would not have passed under those conditions.
This commit is contained in:
parent
b9e7c6a2f6
commit
6eca60504e
Notes:
github-actions[bot]
2024-10-08 23:46:54 +00:00
Author: https://github.com/trflynn89
Commit: 6eca60504e
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1686
1 changed files with 20 additions and 14 deletions
|
@ -339,26 +339,32 @@ static void run_dump_test(HeadlessWebContentView& view, Test& test, URL::URL con
|
|||
return TestResult::Pass;
|
||||
}
|
||||
|
||||
auto expectation_file_or_error = Core::File::open(test.expectation_path, Application::the().rebaseline ? Core::File::OpenMode::Write : Core::File::OpenMode::Read);
|
||||
if (expectation_file_or_error.is_error()) {
|
||||
auto open_expectation_file = [&](auto mode) {
|
||||
auto expectation_file_or_error = Core::File::open(test.expectation_path, mode);
|
||||
if (expectation_file_or_error.is_error())
|
||||
warnln("Failed opening '{}': {}", test.expectation_path, expectation_file_or_error.error());
|
||||
return expectation_file_or_error.release_error();
|
||||
}
|
||||
|
||||
auto expectation_file = expectation_file_or_error.release_value();
|
||||
return expectation_file_or_error;
|
||||
};
|
||||
|
||||
if (Application::the().rebaseline) {
|
||||
TRY(expectation_file->write_until_depleted(test.text));
|
||||
return TestResult::Pass;
|
||||
}
|
||||
|
||||
auto expectation = TRY(expectation_file->read_until_eof());
|
||||
ByteBuffer expectation;
|
||||
{
|
||||
auto expectation_file = TRY(open_expectation_file(Core::File::OpenMode::Read));
|
||||
expectation = TRY(expectation_file->read_until_eof());
|
||||
|
||||
auto result_trimmed = StringView { test.text }.trim("\n"sv, TrimMode::Right);
|
||||
auto expectation_trimmed = StringView { expectation }.trim("\n"sv, TrimMode::Right);
|
||||
|
||||
if (result_trimmed == expectation_trimmed)
|
||||
return TestResult::Pass;
|
||||
}
|
||||
|
||||
if (Application::the().rebaseline) {
|
||||
auto expectation_file = TRY(open_expectation_file(Core::File::OpenMode::Write));
|
||||
TRY(expectation_file->write_until_depleted(test.text));
|
||||
|
||||
return TestResult::Pass;
|
||||
}
|
||||
|
||||
auto const color_output = isatty(STDOUT_FILENO) ? Diff::ColorOutput::Yes : Diff::ColorOutput::No;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue