
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
47 lines
1.2 KiB
Bash
Executable File
47 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
npm_bin=$(which npm)
|
|
if [[ -z "$npm_bin" ]]; then
|
|
echo "NPM must be on the path. (https://www.npmjs.com/)"
|
|
exit 1
|
|
fi
|
|
|
|
# From https://www.linuxquestions.org/questions/programming-9/bash-script-return-full-path-and-filename-680368/page3.html
|
|
function abs_path {
|
|
if [[ -d "$1" ]]
|
|
then
|
|
pushd "$1" >/dev/null
|
|
pwd
|
|
popd >/dev/null
|
|
elif [[ -e $1 ]]
|
|
then
|
|
pushd "$(dirname "$1")" >/dev/null
|
|
echo "$(pwd)/$(basename "$1")"
|
|
popd >/dev/null
|
|
else
|
|
echo "$1" does not exist! >&2
|
|
return 127
|
|
fi
|
|
}
|
|
wct_bin=$(which wct)
|
|
if [[ -z "$wct_bin" ]]; then
|
|
wct_bin=$(abs_path ./node_modules/web-component-tester/bin/wct);
|
|
fi
|
|
if [[ -z "$wct_bin" ]]; then
|
|
echo "wct_bin must be set or WCT locally installed (npm install wct)."
|
|
exit 1
|
|
fi
|
|
|
|
# WCT tests are not hermetic, and need extra environment variables.
|
|
# TODO(hanwen): does $DISPLAY even work on OSX?
|
|
bazel test \
|
|
--test_env="HOME=$HOME" \
|
|
--test_env="WCT=${wct_bin}" \
|
|
--test_env="WCT_ARGS=${WCT_ARGS}" \
|
|
--test_env="NPM=${npm_bin}" \
|
|
--test_env="DISPLAY=${DISPLAY}" \
|
|
--test_env="WCT_HEADLESS_MODE=${WCT_HEADLESS_MODE}" \
|
|
"$@" \
|
|
//polygerrit-ui/app:embed_test \
|
|
//polygerrit-ui/app:wct_test
|