From 10853898fc481f83c70ccfe47c33b687d4a7dbe5 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Wed, 9 Oct 2024 07:04:27 -0400 Subject: [PATCH] headless-browser: Restore ability to rebaseline new tests This regressed in commit 6eca60504e9c6c687dc03ffc448d75ccc2f9baac. If we are rebaslining tests, do not fail if we are unable to open the expectation file for reading. --- Userland/Utilities/headless-browser.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Utilities/headless-browser.cpp b/Userland/Utilities/headless-browser.cpp index 609250b2aec..4610f7db533 100644 --- a/Userland/Utilities/headless-browser.cpp +++ b/Userland/Utilities/headless-browser.cpp @@ -348,15 +348,17 @@ static void run_dump_test(HeadlessWebContentView& view, Test& test, URL::URL con }; ByteBuffer expectation; - { - auto expectation_file = TRY(open_expectation_file(Core::File::OpenMode::Read)); - expectation = TRY(expectation_file->read_until_eof()); + + if (auto expectation_file = open_expectation_file(Core::File::OpenMode::Read); !expectation_file.is_error()) { + expectation = TRY(expectation_file.value()->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; + } else if (!Application::the().rebaseline) { + return expectation_file.release_error(); } if (Application::the().rebaseline) {