Meta: Construct test list after parsing other arguments in WPT.sh

Previously, running `WPT.sh compare foo.log` would fail because the log
file name was included in the list of test paths.
This commit is contained in:
Tim Ledbetter 2024-12-18 20:37:43 +00:00 committed by Tim Ledbetter
commit b4751826c6
Notes: github-actions[bot] 2024-12-29 00:50:59 +00:00

View file

@ -142,18 +142,20 @@ else
WPT_ARGS+=( "--binary=${LADYBIRD_BINARY}" ) WPT_ARGS+=( "--binary=${LADYBIRD_BINARY}" )
fi fi
TEST_LIST=( "$@" ) exit_if_running_as_root "Do not run WPT.sh as root"
for i in "${!TEST_LIST[@]}"; do construct_test_list() {
TEST_LIST=( "$@" )
for i in "${!TEST_LIST[@]}"; do
item="${TEST_LIST[i]}" item="${TEST_LIST[i]}"
item="${item#"$WPT_SOURCE_DIR"/}" item="${item#"$WPT_SOURCE_DIR"/}"
item="${item#*Tests/LibWeb/WPT/wpt/}" item="${item#*Tests/LibWeb/WPT/wpt/}"
item="${item#http://wpt.live/}" item="${item#http://wpt.live/}"
item="${item#https://wpt.live/}" item="${item#https://wpt.live/}"
TEST_LIST[i]="$item" TEST_LIST[i]="$item"
done done
}
exit_if_running_as_root "Do not run WPT.sh as root"
ensure_wpt_repository() { ensure_wpt_repository() {
mkdir -p "${WPT_SOURCE_DIR}" mkdir -p "${WPT_SOURCE_DIR}"
@ -190,6 +192,7 @@ execute_wpt() {
fi fi
WPT_ARGS+=( "--webdriver-arg=--certificate=${certificate_path}" ) WPT_ARGS+=( "--webdriver-arg=--certificate=${certificate_path}" )
done done
construct_test_list "${@}"
echo LADYBIRD_GIT_VERSION="$(ladybird_git_hash)" ./wpt run "${WPT_ARGS[@]}" ladybird "${TEST_LIST[@]}" echo LADYBIRD_GIT_VERSION="$(ladybird_git_hash)" ./wpt run "${WPT_ARGS[@]}" ladybird "${TEST_LIST[@]}"
LADYBIRD_GIT_VERSION="$(ladybird_git_hash)" ./wpt run "${WPT_ARGS[@]}" ladybird "${TEST_LIST[@]}" LADYBIRD_GIT_VERSION="$(ladybird_git_hash)" ./wpt run "${WPT_ARGS[@]}" ladybird "${TEST_LIST[@]}"
popd > /dev/null popd > /dev/null
@ -198,7 +201,7 @@ execute_wpt() {
run_wpt() { run_wpt() {
ensure_wpt_repository ensure_wpt_repository
build_ladybird_and_webdriver build_ladybird_and_webdriver
execute_wpt execute_wpt "${@}"
} }
serve_wpt() serve_wpt()
@ -214,6 +217,8 @@ list_tests_wpt()
{ {
ensure_wpt_repository ensure_wpt_repository
construct_test_list "${@}"
pushd "${WPT_SOURCE_DIR}" > /dev/null pushd "${WPT_SOURCE_DIR}" > /dev/null
./wpt run --list-tests ladybird "${TEST_LIST[@]}" ./wpt run --list-tests ladybird "${TEST_LIST[@]}"
popd > /dev/null popd > /dev/null
@ -261,7 +266,7 @@ compare_wpt() {
popd > /dev/null popd > /dev/null
WPT_ARGS+=( "--metadata=${METADATA_DIR}" ) WPT_ARGS+=( "--metadata=${METADATA_DIR}" )
build_ladybird_and_webdriver build_ladybird_and_webdriver
execute_wpt execute_wpt "${@}"
rm -rf "${METADATA_DIR}" rm -rf "${METADATA_DIR}"
} }
@ -271,7 +276,7 @@ if [[ "$CMD" =~ ^(update|run|serve|compare|import|list-tests)$ ]]; then
update_wpt update_wpt
;; ;;
run) run)
run_wpt run_wpt "${@}"
;; ;;
serve) serve)
serve_wpt serve_wpt
@ -291,10 +296,10 @@ if [[ "$CMD" =~ ^(update|run|serve|compare|import|list-tests)$ ]]; then
usage; usage;
fi fi
shift shift
compare_wpt compare_wpt "${@}"
;; ;;
list-tests) list-tests)
list_tests_wpt list_tests_wpt "${@}"
;; ;;
esac esac
else else