headless-browser: Allow running LibWeb tests without specifying a path
Some checks are pending
CI / Lagom (arm64, Sanitizer_CI, false, macOS, macos-15, Clang) (push) Waiting to run
CI / Lagom (x86_64, Fuzzers_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, false, Linux, blacksmith-16vcpu-ubuntu-2404, GNU) (push) Waiting to run
CI / Lagom (x86_64, Sanitizer_CI, true, Linux, blacksmith-16vcpu-ubuntu-2404, Clang) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (arm64, macOS, macOS-arm64, macos-15) (push) Waiting to run
Package the js repl as a binary artifact / build-and-package (x86_64, Linux, Linux-x86_64, blacksmith-8vcpu-ubuntu-2404) (push) Waiting to run
Run test262 and test-wasm / run_and_update_results (push) Waiting to run
Lint Code / lint (push) Waiting to run
Label PRs with merge conflicts / auto-labeler (push) Waiting to run
Push notes / build (push) Waiting to run

Especially on new setups, it is handy for `headless-browser --run-tests`
to "just work". Anyone using ladybird.py will have LADYBIRD_SOURCE_DIR
set in their environment already.
This commit is contained in:
Timothy Flynn 2025-05-31 09:43:06 -04:00 committed by Shannon Booth
commit 985434ea10
Notes: github-actions[bot] 2025-05-31 22:35:33 +00:00

View file

@ -6,6 +6,7 @@
#include <LibCore/AnonymousBuffer.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/Environment.h>
#include <LibCore/System.h>
#include <LibWebView/HelperProcess.h>
#include <LibWebView/Utilities.h>
@ -37,7 +38,6 @@ void Application::create_platform_arguments(Core::ArgsParser& args_parser)
args_parser.add_option(dump_text, "Dump text and exit", "dump-text", 'T');
args_parser.add_option(test_concurrency, "Maximum number of tests to run at once", "test-concurrency", 'j', "jobs");
args_parser.add_option(python_executable_path, "Path to python3", "python-executable", 'P', "path");
args_parser.add_option(test_root_path, "Run tests in path", "run-tests", 'R', "test-root-path");
args_parser.add_option(test_globs, "Only run tests matching the given glob", "filter", 'f', "glob");
args_parser.add_option(test_dry_run, "List the tests that would be run, without running them", "dry-run");
args_parser.add_option(dump_failed_ref_tests, "Dump screenshots of failing ref tests", "dump-failed-ref-tests", 'D');
@ -49,6 +49,27 @@ void Application::create_platform_arguments(Core::ArgsParser& args_parser)
args_parser.add_option(width, "Set viewport width in pixels (default: 800)", "width", 'W', "pixels");
args_parser.add_option(height, "Set viewport height in pixels (default: 600)", "height", 'H', "pixels");
args_parser.add_option(Core::ArgsParser::Option {
.argument_mode = Core::ArgsParser::OptionArgumentMode::Optional,
.help_string = "Run tests. If a path is provided, tests are loaded from that path. Otherwise, LADYBIRD_SOURCE_DIR must be set.",
.long_name = "run-tests",
.short_name = 'R',
.value_name = "test-root-path",
.accept_value = [&](StringView value) -> ErrorOr<bool> {
if (!value.is_empty()) {
test_root_path = value;
return true;
}
if (auto ladybird_source_dir = Core::Environment::get("LADYBIRD_SOURCE_DIR"sv); ladybird_source_dir.has_value()) {
test_root_path = LexicalPath::join(*ladybird_source_dir, "Tests"sv, "LibWeb"sv).string();
return true;
}
return false;
},
});
args_parser.add_option(Core::ArgsParser::Option {
.argument_mode = Core::ArgsParser::OptionArgumentMode::Optional,
.help_string = "Log extra information about test results (use multiple times for more information)",