headless-browser: Add an option to log per-test durations

This adds a verbosity option to log the start and end of each test, with
the duration taken for the test. To be able to use this option with our
exisiting verbosity flag, without cluttering stdout with other data, we
add verbosity levels to headless-browser. The level is increased by
providing the -v flag on the command line multiple times.
This commit is contained in:
Timothy Flynn 2024-11-30 08:51:59 -05:00 committed by Tim Flynn
commit ad5de9d4e5
Notes: github-actions[bot] 2024-11-30 17:11:18 +00:00
4 changed files with 37 additions and 16 deletions

View file

@ -45,9 +45,23 @@ 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(per_test_timeout_in_seconds, "Per-test timeout (default: 30)", "per-test-timeout", 't', "seconds");
args_parser.add_option(verbose, "Log extra information about test results", "verbose", 'v');
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 = "Log extra information about test results (use multiple times for more information)",
.long_name = "verbose",
.short_name = 'v',
.accept_value = [&](StringView value) -> ErrorOr<bool> {
if (value.is_empty() && verbosity < NumericLimits<u8>::max()) {
++verbosity;
return true;
}
return false;
},
});
}
void Application::create_platform_options(WebView::ChromeOptions& chrome_options, WebView::WebContentOptions& web_content_options)