-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: use test-ui.sh to run the tests
Use one single script called `./tools/test-ui.sh` to trigger all the different UI tests: - `COVERAGE=1` or `-c` to enable the code coverage - `COVE_VERSION` to set the vscode-extension-tester parameter (e.g `max` or `min`) - `MOCK_LIGHTSPEED_API` (`1` or ``): set it to `1` to dynamically start the mocked server and set `TEST_LIGHTSPEED_URL`
- Loading branch information
Showing
7 changed files
with
103 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,27 @@ | ||
#!/bin/bash | ||
|
||
# If TEST_LIGHTSPEED_URL is not defined, set a URL with the ipv6 callback hostname, | ||
# which is available in the GitHub Actions Linux environment. | ||
if [[ -z "${TEST_LIGHTSPEED_URL}" ]]; then | ||
TEST_LIGHTSPEED_URL="http://ip6-localhost:3000" | ||
fi | ||
set -eux | ||
set -o pipefail | ||
|
||
cleanup() | ||
{ | ||
pkill -P $$ | ||
wait | ||
} | ||
|
||
|
||
# Create log dir for express.log | ||
if [ ! -d out/log ]; then | ||
mkdir out/log | ||
|
||
if [[ -n "${TEST_LIGHTSPEED_URL}" ]]; then | ||
echo "the existing TEST_LIGHTSPEED_URL envvar will be ignored!" | ||
fi | ||
mkdir -p out/log | ||
TEST_LIGHTSPEED_ACCESS_TOKEN=dummy | ||
(DEBUG='express:*' node ./out/client/test/mockLightspeedServer/server.js >>out/log/express.log 2>&1 ) & | ||
sleep 3 | ||
TEST_LIGHTSPEED_URL=$(sed -n 's,.*Listening on port \([0-9]\+\) at \([.0-9]\+\).*,http://\2:\1,p' out/log/express.log|tail -n1) | ||
|
||
export TEST_LIGHTSPEED_URL | ||
export TEST_LIGHTSPEED_ACCESS_TOKEN | ||
export COVERAGE=1 | ||
|
||
# Start the mock Lightspeed server and run e2e tests with code coverage enabled. | ||
npx start-server-and-test \ | ||
"TEST_LIGHTSPEED_URL=${TEST_LIGHTSPEED_URL} yarn mock-lightspeed-server" \ | ||
"${TEST_LIGHTSPEED_URL}" \ | ||
"TEST_LIGHTSPEED_ACCESS_TOKEN=dummy TEST_LIGHTSPEED_URL=${TEST_LIGHTSPEED_URL} yarn coverage-e2e" | ||
yarn test-e2e |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
set -o pipefail | ||
|
||
cleanup() | ||
{ | ||
pkill -P $$ | ||
wait | ||
} | ||
|
||
trap "cleanup" HUP INT ABRT BUS TERM EXIT | ||
|
||
|
||
CODE_VERSION="${CODE_VERSION:-max}" | ||
TEST_LIGHTSPEED_URL="${TEST_LIGHTSPEED_URL:-}" | ||
COVERAGE="${COVERAGE:-}" | ||
EXTEST=./node_modules/.bin/extest | ||
MOCK_LIGHTSPEED_API="${MOCK_LIGHTSPEED_API:-}" | ||
|
||
|
||
|
||
OPTSTRING=":c" | ||
|
||
while getopts ${OPTSTRING} opt; do | ||
case ${opt} in | ||
c) | ||
echo "Coverage enabled" | ||
COVERAGE="1" | ||
;; | ||
?) | ||
echo "Invalid option: -${OPTARG}." | ||
exit 1 | ||
;; | ||
esac | ||
done | ||
|
||
if [[ -n $COVERAGE ]]; then | ||
COVERAGE_ARG="--coverage" | ||
fi | ||
|
||
|
||
if [[ "$MOCK_LIGHTSPEED_API" != "" ]]; then | ||
if [[ -n "${TEST_LIGHTSPEED_URL}" ]]; then | ||
echo "MOCK_LIGHTSPEED_API is true, the existing TEST_LIGHTSPEED_URL envvar will be ignored!" | ||
fi | ||
mkdir -p out/log | ||
TEST_LIGHTSPEED_ACCESS_TOKEN=dummy | ||
(DEBUG='express:*' node ./out/client/test/mockLightspeedServer/server.js >>out/log/express.log 2>&1 ) & | ||
sleep 3 | ||
TEST_LIGHTSPEED_URL=$(sed -n 's,.*Listening on port \([0-9]\+\) at \([.0-9]\+\).*,http://\2:\1,p' out/log/express.log|tail -n1) | ||
fi | ||
|
||
|
||
# Start the mock Lightspeed server and run UI tests with the new VS Code | ||
|
||
${EXTEST} get-vscode -c "${CODE_VERSION}" -s out/test-resources | ||
${EXTEST} get-chromedriver -c "${CODE_VERSION}" -s out/test-resources | ||
if [[ "$COVERAGE" == "" ]]; then | ||
${EXTEST} install-vsix -f ansible-*.vsix -e out/ext -s out/test-resources | ||
fi | ||
${EXTEST} install-from-marketplace redhat.vscode-yaml ms-python.python -e out/ext -s out/test-resources | ||
|
||
|
||
export TEST_LIGHTSPEED_URL | ||
export TEST_LIGHTSPEED_ACCESS_TOKEN | ||
|
||
${EXTEST} run-tests "${COVERAGE_ARG}" -s out/test-resources -e out/ext --code_settings test/testFixtures/settings.json out/client/test/ui-test/allTestsSuite.js |