Headless: Allow overriding the test timeout with a CLI parameter

Also bump the test timeout when running ctest to 120 seconds,
to accommodate the slow GCC CI.
This commit is contained in:
Andreas Kling 2024-10-26 18:22:18 +02:00 committed by Andreas Kling
parent ec0838b84e
commit be03002780
Notes: github-actions[bot] 2024-10-27 11:11:17 +00:00
6 changed files with 11 additions and 11 deletions

View file

@ -35,6 +35,7 @@ void Application::create_platform_arguments(Core::ArgsParser& args_parser)
args_parser.add_option(is_layout_test_mode, "Enable layout test mode", "layout-test-mode");
args_parser.add_option(rebaseline, "Rebaseline any executed layout or text tests", "rebaseline");
args_parser.add_option(log_slowest_tests, "Log the tests with the slowest run times", "log-slowest-tests");
args_parser.add_option(per_test_timeout_in_seconds, "Per-test timeout (default: 30)", "per-test-timeout", 't', "seconds");
}
void Application::create_platform_options(WebView::ChromeOptions& chrome_options, WebView::WebContentOptions& web_content_options)

View file

@ -61,6 +61,7 @@ public:
bool test_dry_run { false };
bool rebaseline { false };
bool log_slowest_tests { false };
int per_test_timeout_in_seconds { 30 };
private:
RefPtr<Requests::RequestClient> m_request_client;

View file

@ -14,6 +14,6 @@ target_link_libraries(headless-browser PRIVATE ${LADYBIRD_LIBS} LibDiff)
if (BUILD_TESTING)
add_test(
NAME LibWeb
COMMAND $<TARGET_FILE:headless-browser> --run-tests ${LADYBIRD_SOURCE_DIR}/Tests/LibWeb --dump-failed-ref-tests
COMMAND $<TARGET_FILE:headless-browser> --run-tests ${LADYBIRD_SOURCE_DIR}/Tests/LibWeb --dump-failed-ref-tests --per-test-timeout 120
)
endif()

View file

@ -218,7 +218,7 @@ void run_dump_test(HeadlessWebView& view, Test& test, URL::URL const& url, int t
timer->start();
}
static void run_ref_test(HeadlessWebView& view, Test& test, URL::URL const& url, int timeout_in_milliseconds = DEFAULT_TIMEOUT_MS)
static void run_ref_test(HeadlessWebView& view, Test& test, URL::URL const& url, int timeout_in_milliseconds)
{
auto timer = Core::Timer::create_single_shot(timeout_in_milliseconds, [&view, &test]() {
view.on_load_finish = {};
@ -287,7 +287,7 @@ static void run_ref_test(HeadlessWebView& view, Test& test, URL::URL const& url,
timer->start();
}
static void run_test(HeadlessWebView& view, Test& test)
static void run_test(HeadlessWebView& view, Test& test, Application& app)
{
// Clear the current document.
// FIXME: Implement a debug-request to do this more thoroughly.
@ -345,16 +345,16 @@ static void run_test(HeadlessWebView& view, Test& test)
view.file_picker_closed(move(selected_files));
};
promise->when_resolved([&view, &test](auto) {
promise->when_resolved([&view, &test, &app](auto) {
auto url = URL::create_with_file_scheme(MUST(FileSystem::real_path(test.input_path)));
switch (test.mode) {
case TestMode::Text:
case TestMode::Layout:
run_dump_test(view, test, url);
run_dump_test(view, test, url, app.per_test_timeout_in_seconds * 1000);
return;
case TestMode::Ref:
run_ref_test(view, test, url);
run_ref_test(view, test, url, app.per_test_timeout_in_seconds * 1000);
return;
}
@ -453,7 +453,7 @@ ErrorOr<void> run_tests(Core::AnonymousBuffer const& theme, Gfx::IntSize window_
if (s_skipped_tests.contains_slow(test.input_path))
view.on_test_complete({ test, TestResult::Skipped });
else
run_test(view, test);
run_test(view, test, app);
});
};

View file

@ -75,9 +75,7 @@ struct TestCompletion {
using TestPromise = Core::Promise<TestCompletion>;
constexpr inline int DEFAULT_TIMEOUT_MS = 60'000;
ErrorOr<void> run_tests(Core::AnonymousBuffer const& theme, Gfx::IntSize window_size);
void run_dump_test(HeadlessWebView&, Test&, URL::URL const&, int timeout_in_milliseconds = DEFAULT_TIMEOUT_MS);
void run_dump_test(HeadlessWebView&, Test&, URL::URL const&, int timeout_in_milliseconds);
}

View file

@ -92,7 +92,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (app->dump_layout_tree || app->dump_text) {
Ladybird::Test test { app->dump_layout_tree ? Ladybird::TestMode::Layout : Ladybird::TestMode::Text };
Ladybird::run_dump_test(view, test, url);
Ladybird::run_dump_test(view, test, url, app->per_test_timeout_in_seconds * 1000);
auto completion = MUST(view.test_promise().await());
return completion.result == Ladybird::TestResult::Pass ? 0 : 1;