From 3e57f472f58344d13347850f4debaf0e9194e6e2 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sat, 2 Nov 2024 06:03:22 +0000 Subject: [PATCH] Meta: Add an option to `WPT.sh` to import WPT tests This invokes the existing `import-wpt-test.py` script, then uses `headless-browser` to create an expectation file. --- Meta/WPT.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/Meta/WPT.sh b/Meta/WPT.sh index cda2fdc0bfb..0724560ca2e 100755 --- a/Meta/WPT.sh +++ b/Meta/WPT.sh @@ -32,6 +32,7 @@ ladybird_git_hash() { LADYBIRD_BINARY=${LADYBIRD_BINARY:-"$(default_binary_path)/Ladybird"} WEBDRIVER_BINARY=${WEBDRIVER_BINARY:-"$(default_binary_path)/WebDriver"} +HEADLESS_BROWSER_BINARY=${HEADLESS_BROWSER_BINARY:-"$(default_binary_path)/headless-browser"} WPT_PROCESSES=${WPT_PROCESSES:-$(get_number_of_processing_units)} WPT_CERTIFICATES=( "tools/certs/cacert.pem" @@ -57,6 +58,8 @@ print_help() { Run the Web Platform Tests. compare: $NAME compare [OPTIONS...] LOG_FILE [TESTS...] Run the Web Platform Tests comparing the results to the expectations in LOG_FILE. + import: $NAME import [TESTS...] + Fetch the given test file(s) from https://wpt.live/ and create an in-tree test and expectation files. Examples: $NAME update @@ -71,6 +74,8 @@ print_help() { Run all of the Web Platform Tests comparing the results to the expectations in before.log. $NAME compare --log results.log expectations.log css/CSS2 Run the Web Platform Tests in the 'css/CSS2' directory, comparing the results to the expectations in expectations.log; output the results to results.log. + $NAME import html/dom/aria-attribute-reflection.html + Import the test from https://wpt.live/html/dom/aria-attribute-reflection.html into the Ladybird test suite. EOF } @@ -186,6 +191,18 @@ serve_wpt() popd > /dev/null } +import_wpt() +{ + pushd "${LADYBIRD_SOURCE_DIR}" > /dev/null + ./Meta/ladybird.sh build headless-browser + for path in "${INPUT_PATHS[@]}"; do + echo "Importing test from ${path}" + ./Meta/import-wpt-test.py https://wpt.live/"${path}" + "${HEADLESS_BROWSER_BINARY}" --run-tests ./Tests/LibWeb --rebaseline -f "$path" + done + popd > /dev/null +} + compare_wpt() { ensure_wpt_repository METADATA_DIR=$(mktemp -d) @@ -198,7 +215,7 @@ compare_wpt() { rm -rf "${METADATA_DIR}" } -if [[ "$CMD" =~ ^(update|run|serve|compare)$ ]]; then +if [[ "$CMD" =~ ^(update|run|serve|compare|import)$ ]]; then case "$CMD" in update) update_wpt @@ -209,6 +226,14 @@ if [[ "$CMD" =~ ^(update|run|serve|compare)$ ]]; then serve) serve_wpt ;; + import) + if [ $# -eq 0 ]; then + usage + fi + INPUT_PATHS=( "$@" ) + import_wpt + ;; + compare) INPUT_LOG_NAME="$(pwd -P)/$1" if [ ! -f "$INPUT_LOG_NAME" ]; then