-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathrunWPT.sh
executable file
·145 lines (118 loc) · 3.7 KB
/
runWPT.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
# shellcheck disable=SC2155
set -uo pipefail
log() {
echo "($0) $*"
}
usage() {
log "Usage: [CHROMEDRIVER=<true | false>] [HEADLESS=<true | false>] [UPDATE_EXPECTATIONS=<true | false>] $0 [webdriver/tests/bidi/[...]]"
}
if [[ $# -gt 0 && ("$1" == "-h" || "$1" == "--help") ]]; then
usage
exit 0
fi
# The path to the browser binary.
if [[ "$(uname -s)" == "Linux" ]]; then
readonly BROWSER_BIN="${BROWSER_BIN:-/usr/bin/google-chrome-unstable}"
elif [[ "$(uname -s)" == "Darwin" ]]; then
readonly BROWSER_BIN="${BROWSER_BIN:-/Applications/Google Chrome Dev.app/Contents/MacOS/Google Chrome Dev}"
fi
# Whether to use Chromedriver with mapper.
readonly CHROMEDRIVER="${CHROMEDRIVER:-false}"
# Whether to start the server in headless or headful mode.
readonly HEADLESS="${HEADLESS:-true}"
# The path to the WPT manifest file.
readonly MANIFEST="${MANIFEST:-MANIFEST.json}"
# The browser product to test.
readonly PRODUCT="${PRODUCT:-chrome}"
# Multiplier relative to standard test timeout to use.
readonly TIMEOUT_MULTIPLIER="${TIMEOUT_MULTIPLIER:-8}"
# Whether to update the WPT expectations after running the tests.
readonly UPDATE_EXPECTATIONS="${UPDATE_EXPECTATIONS:-false}"
# Whether to enable verbose logging.
readonly VERBOSE="${VERBOSE:-false}"
# The path to the WPT report file.
readonly WPT_REPORT="${WPT_REPORT:-wptreport.json}"
# Only set WPT_METADATA if it's not already set.
if [ -z ${WPT_METADATA+x} ]; then
# The path to the WPT metadata directory.
if [[ "$CHROMEDRIVER" == "true" ]]; then
readonly WPT_METADATA="wpt-metadata/chromedriver/headless"
else
if [[ "$HEADLESS" == "true" ]]; then
readonly WPT_METADATA="wpt-metadata/mapper/headless"
else
readonly WPT_METADATA="wpt-metadata/mapper/headful"
fi
fi
fi
if [[ "$HEADLESS" == "true" ]]; then
log "Running WPT in headless mode..."
else
log "Running WPT in headful mode..."
fi
declare -a WPT_RUN_ARGS=(
--binary "$BROWSER_BIN"
--webdriver-binary runBiDiServer.sh
--webdriver-arg="--headless=$HEADLESS"
--log-wptreport "$WPT_REPORT"
--manifest "$MANIFEST"
--metadata "$WPT_METADATA"
--no-manifest-download
--skip-implementation-status backlog
--timeout-multiplier "$TIMEOUT_MULTIPLIER"
)
if [[ "$VERBOSE" == "true" ]]; then
WPT_RUN_ARGS+=(
--debug-test
--log-mach -
--log-mach-level info
)
elif [[ "$HEADLESS" == "true" ]]; then
# Parallelization is flaky in headful mode.
WPT_RUN_ARGS+=(
--processes "$(nproc)"
)
fi
if [[ "$CHROMEDRIVER" == "true" ]]; then
log "Using chromedriver with mapper..."
WPT_RUN_ARGS+=(
--binary-arg="--headless=new"
--install-webdriver
--webdriver-arg="--bidi-mapper-path=lib/iife/mapperTab.js"
--webdriver-arg="--log-path=out/chromedriver.log"
--webdriver-arg="--verbose"
--yes
)
else
log "Using pure mapper..."
fi
TEST="${*: -1}"
echo "Running \"$TEST\" with \"$BROWSER_BIN\"..."
WPT_RUN_ARGS+=(
# All arguments except the first one (the command) and the last one (the test) are the flags.
"${@: 1:$#-1}"
"$PRODUCT"
# The last argument is the test.
"$TEST"
)
(cd "$(dirname "$0")/" && ./wpt/wpt run "${WPT_RUN_ARGS[@]}")
status="$?"
if [[ "$UPDATE_EXPECTATIONS" == "true" ]]; then
log "Updating WPT expectations..."
./wpt/wpt update-expectations \
--product "$PRODUCT" \
--manifest "$MANIFEST" \
--metadata "$WPT_METADATA" \
"$WPT_REPORT"
fi
# Script status should match "wpt run" for CI.
exit "$status"
# Alternate usage:
#
# Run with locally built Chromium and Chromedriver, after
# `autoninja -C out/Default chrome chromedriver`:
#
# --binary "$BROWSER_BIN" \
# --webdriver-binary /path/to/chromium/src/out/Default/chromedriver \
# --webdriver-arg="--bidi-mapper-path=lib/iife/mapperTab.js" \