From 21082f5002e8d051d3def39747c6dd2eb6c655a2 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Sun, 7 Sep 2025 09:19:04 +0100 Subject: [PATCH] Meta: Only update hosts file when necessary in `WPT.sh` Previously, the hosts file was updated at the same time the WPT repo was cloned, but updating the hosts file is only necessary for commands that start the WPT test runner. --- Meta/WPT.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Meta/WPT.sh b/Meta/WPT.sh index a7798e92908..1ee4cfcbf9a 100755 --- a/Meta/WPT.sh +++ b/Meta/WPT.sh @@ -240,11 +240,6 @@ ensure_wpt_repository() { if [ ! -d .git ]; then git clone --depth 1 "${WPT_REPOSITORY_URL}" "${WPT_SOURCE_DIR}" fi - - # Update hosts file if needed - if [ "$(comm -13 <(sort -u /etc/hosts) <(./wpt make-hosts-file | sort -u) | wc -l)" -gt 0 ]; then - ./wpt make-hosts-file | sudo_and_ask "Appending wpt hosts to /etc/hosts" tee -a /etc/hosts - fi popd > /dev/null } @@ -533,6 +528,14 @@ absolutize_log_args() { done } +update_hosts_file_if_needed() { + pushd "${WPT_SOURCE_DIR}" > /dev/null + if [ "$(comm -13 <(sort -u /etc/hosts) <(./wpt make-hosts-file | sort -u) | wc -l)" -gt 0 ]; then + ./wpt make-hosts-file | sudo_and_ask "Appending wpt hosts to /etc/hosts" tee -a /etc/hosts + fi + popd > /dev/null +} + execute_wpt() { local procs @@ -557,12 +560,14 @@ execute_wpt() { run_wpt() { ensure_wpt_repository build_ladybird_and_webdriver + update_hosts_file_if_needed execute_wpt "${@}" } serve_wpt() { ensure_wpt_repository + update_hosts_file_if_needed pushd "${WPT_SOURCE_DIR}" > /dev/null ./wpt serve @@ -735,6 +740,7 @@ compare_wpt() { popd > /dev/null WPT_ARGS+=( "--metadata=${METADATA_DIR}" ) build_ladybird_and_webdriver + update_hosts_file_if_needed execute_wpt "${@}" rm -rf "${METADATA_DIR}" }