1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 09:27:35 +00:00

Tests: Convert WebDriver patch to a git patch and clean up assumptions

Instead of assuming that the WebDriver binary is in PATH or the two
most common build directories for our scripts, add a command line
argument to the script to pass a WebDriver binary.
This commit is contained in:
Andrew Kaster 2023-08-19 17:15:54 -06:00 committed by Alexander Kalenik
parent 9c3b0b367a
commit 4c26b0b047
2 changed files with 80 additions and 35 deletions

View file

@ -10,14 +10,38 @@ then
export SERENITY_SOURCE_DIR
fi
if [[ "$1" == "--update-expectations-metadata" ]]; then
update_expectations_metadata=true
else
update_expectations_metadata=false
fi
# NOTE: WPT runner assumes Ladybird, WebContent and WebDriver are available in $PATH.
export PATH="${SERENITY_SOURCE_DIR}/Build/lagom/bin:${SERENITY_SOURCE_DIR}/Meta/Lagom/Build/bin:${PATH}"
WEBDRIVER_BINARY=$(env PATH="${SERENITY_SOURCE_DIR}/Build/lagom/bin:${SERENITY_SOURCE_DIR}/Meta/Lagom/Build/bin:${PATH}" \
which WebDriver)
update_expectations_metadata=false
dev=0
for arg in "$@"; do
case $arg in
--webdriver-binary=*)
WEBDRIVER_BINARY="$(realpath "${arg#*=}")"
shift
;;
--update-expectations-metadata)
update_expectations_metadata=true
shift
;;
--dev)
dev=1
shift
;;
*)
echo "Unknown argument ${arg}"
exit 1
;;
esac
done
if [ -z "$WEBDRIVER_BINARY" ]; then
echo "Unable to find WebDriver binary, did you build Ladybird?"
exit 1
fi
pushd "${SCRIPT_DIR}"
@ -26,10 +50,14 @@ if [ ! -d "${SCRIPT_DIR}/wpt" ]; then
git clone --depth 10000 https://github.com/web-platform-tests/wpt.git
# Switch to the commit that was used to generate tests expectations. Requires periodic updates.
(cd wpt; git checkout 4434e91bd0801dfefff044b5b9a9744e30d255d3)
git -C wpt checkout 4434e91bd0801dfefff044b5b9a9744e30d255d3
# Apply WPT patch with Ladybird runner
(cd wpt; git apply ../ladybird_runner.patch)
if [ "$dev" = "1" ]; then
git -C wpt am ../Add-Ladybird-WebDriver-runner.patch > /dev/null
else
patch -d wpt -p1 < Add-Ladybird-WebDriver-runner.patch > /dev/null
fi
# Update hosts file if needed
if [ "$(comm -13 <(sort -u /etc/hosts) <(python3 ./wpt/wpt make-hosts-file | sort -u) | wc -l)" -gt 0 ]; then
@ -45,7 +73,15 @@ python3 ./concat-extract-metadata.py --extract metadata.txt metadata
wpt_run_log_filename="$(mktemp).txt"
# Run tests.
python3 ./wpt/wpt run ladybird --no-fail-on-unexpected --no-fail-on-unexpected-pass --skip-timeout --include-manifest include.ini --metadata ./metadata --manifest ./MANIFEST.json --log-raw "${wpt_run_log_filename}"
python3 ./wpt/wpt run ladybird \
--webdriver-binary "${WEBDRIVER_BINARY}" \
--no-fail-on-unexpected \
--no-fail-on-unexpected-pass \
--skip-timeout \
--include-manifest include.ini \
--metadata ./metadata \
--manifest ./MANIFEST.json \
--log-raw "${wpt_run_log_filename}"
# Update expectations metadata files if requested
if [[ $update_expectations_metadata == true ]]; then