Commit a9d1106e authored by Lawson Kurtz's avatar Lawson Kurtz Committed by Christopher Chedeau
Browse files

Improve error handling within e2e.sh (#244)

* Improve error handling in E2E script

* Expose e2e.sh as npm test script
parent 7040b713
Showing with 26 additions and 7 deletions
+26 -7
...@@ -13,7 +13,8 @@ ...@@ -13,7 +13,8 @@
"scripts": { "scripts": {
"start": "node scripts/start.js --debug-template", "start": "node scripts/start.js --debug-template",
"build": "node scripts/build.js --debug-template", "build": "node scripts/build.js --debug-template",
"create-react-app": "node global-cli/index.js --scripts-version \"$PWD/`npm pack`\"" "create-react-app": "node global-cli/index.js --scripts-version \"$PWD/`npm pack`\"",
"test": "tasks/e2e.sh"
}, },
"files": [ "files": [
"LICENSE", "LICENSE",
......
...@@ -8,10 +8,29 @@ ...@@ -8,10 +8,29 @@
# Start in tests/ even if run from root directory # Start in tests/ even if run from root directory
cd "$(dirname "$0")" cd "$(dirname "$0")"
# Exit the script on any command with non 0 return code function cleanup {
# We assume that all the commands in the pipeline set their return code echo 'Cleaning up.'
# properly and that we do not need to validate that the output is correct cd $initial_path
set -e rm -rf $temp_cli_path $temp_app_path
}
function handle_error {
echo "$(basename $0): \033[31mERROR!\033[m An error was encountered executing \033[36mline $1\033[m."
handle_exit
exit 1
}
function handle_exit {
cleanup
echo 'Exiting.'
exit
}
# Exit the script with a helpful error message when any error is encountered
trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR
# Cleanup before exit on any termination signal
trap 'set +x; handle_exit' SIGQUIT SIGTERM SIGINT SIGKILL SIGHUP
# Echo every command being executed # Echo every command being executed
set -x set -x
...@@ -81,5 +100,4 @@ test -e build/*.js ...@@ -81,5 +100,4 @@ test -e build/*.js
npm start -- --smoke-test npm start -- --smoke-test
# Cleanup # Cleanup
cd $initial_path cleanup
rm -rf $temp_cli_path $temp_app_path
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment