66c6e5466b
package.json is an NPM manifest file that allows a project to declare its depedencies. We already ask people to use npm in our readme [1], listing the packages they need to install. This easily gets out of date. The standard for NPM is to list deps in and their versions in package.json instead. This change only adds the deps needed to run the tests, and configures the `npm test` command to run all Gerrit frontend tests. In future iterations we should also add other devDependencies and simplify our docs. If the general approach is accepted, I can send follow up changes to do that. This change further makes run_test.sh and friends work for locally installed WCT. That is generally preferrable since it does not require root, does not clutter global system paths etc. The global version is still used when installed though (for backward compatibility - we might decide to change that in future). [1] https://gerrit.googlesource.com/gerrit/+/master/polygerrit-ui/ Change-Id: I9982827f5098e71ce3e59bc9cc1427b3bd55d425
68 lines
1.8 KiB
Bash
Executable File
68 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -ex
|
|
|
|
t=$(mktemp -d || mktemp -d -t wct-XXXXXXXXXX)
|
|
components=$TEST_SRCDIR/gerrit/polygerrit-ui/app/test_components.zip
|
|
code=$TEST_SRCDIR/gerrit/polygerrit-ui/app/pg_code.zip
|
|
|
|
echo $t
|
|
unzip -qd $t $components
|
|
unzip -qd $t $code
|
|
mkdir -p $t/test
|
|
cp $TEST_SRCDIR/gerrit/polygerrit-ui/app/test/index.html $t/test/
|
|
|
|
if [ "${WCT_HEADLESS_MODE:-0}" != "0" ]; then
|
|
CHROME_OPTIONS=[\'start-maximized\',\'headless\',\'disable-gpu\',\'no-sandbox\']
|
|
FIREFOX_OPTIONS=[\'-headless\']
|
|
else
|
|
CHROME_OPTIONS=[\'start-maximized\']
|
|
FIREFOX_OPTIONS=[\'\']
|
|
fi
|
|
|
|
# For some reason wct tries to install selenium into its node_modules
|
|
# directory on first run. If you've installed into /usr/local and
|
|
# aren't running wct as root, you're screwed. Turning this option off
|
|
# through skipSeleniumInstall seems to still work, so there's that.
|
|
|
|
# Sauce tests are disabled by default in order to run local tests
|
|
# only. Run it with (saucelabs.com account required; free for open
|
|
# source): WCT_ARGS='--plugin sauce' ./polygerrit-ui/app/run_test.sh
|
|
|
|
cat <<EOF > $t/wct.conf.js
|
|
module.exports = {
|
|
'suites': ['test'],
|
|
'webserver': {
|
|
'pathMappings': [
|
|
{'/components/bower_components': 'bower_components'}
|
|
]
|
|
},
|
|
'plugins': {
|
|
'local': {
|
|
'skipSeleniumInstall': true,
|
|
'browserOptions': {
|
|
'chrome': ${CHROME_OPTIONS},
|
|
'firefox': ${FIREFOX_OPTIONS}
|
|
}
|
|
},
|
|
'sauce': {
|
|
'disabled': true,
|
|
'browsers': [
|
|
'OS X 10.12/chrome',
|
|
'Windows 10/chrome',
|
|
'Linux/firefox',
|
|
'OS X 10.12/safari',
|
|
'Windows 10/microsoftedge'
|
|
]
|
|
}
|
|
}
|
|
};
|
|
EOF
|
|
|
|
export PATH="$(dirname $NPM):$PATH"
|
|
|
|
cd $t
|
|
test -n "${WCT}"
|
|
|
|
${WCT} ${WCT_ARGS}
|