vscode/scripts/test.sh

42 lines
1.1 KiB
Bash
Raw Normal View History

2016-01-04 12:35:25 +01:00
#!/bin/bash
if [[ "$OSTYPE" == "darwin"* ]]; then
realpath() { [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"; }
ROOT=$(dirname $(dirname $(realpath "$0")))
else
ROOT=$(dirname $(dirname $(readlink -f $0)))
fi
2016-05-10 16:42:47 +02:00
cd $ROOT
2016-05-10 16:15:48 +02:00
if [[ "$OSTYPE" == "darwin"* ]]; then
2016-08-09 17:56:05 +02:00
NAME=`node -p "require('./product.json').nameLong"`
CODE="./.build/electron/$NAME.app/Contents/MacOS/Electron"
else
NAME=`node -p "require('./product.json').applicationName"`
2016-08-09 17:57:09 +02:00
CODE=".build/electron/$NAME"
fi
INTENDED_VERSION="v`node -p "require('./package.json').electronVersion"`"
2017-02-15 11:16:38 +01:00
INSTALLED_VERSION=$(cat .build/electron/version 2> /dev/null)
# Node modules
test -d node_modules || ./scripts/npm.sh install
# Get electron
(test -f "$CODE" && [ $INTENDED_VERSION == $INSTALLED_VERSION ]) || ./node_modules/.bin/gulp electron
2016-01-04 12:35:25 +01:00
# Unit Tests
2017-04-13 12:44:37 +02:00
if [[ "$1" == "--xvfb" ]]; then
cd $ROOT ; \
xvfb-run -a "$CODE" test/electron/index.js "$@"
2017-04-13 12:44:37 +02:00
elif [[ "$OSTYPE" == "darwin"* ]]; then
cd $ROOT ; ulimit -n 4096 ; \
"$CODE" \
test/electron/index.js "$@"
2016-01-04 12:35:25 +01:00
else
cd $ROOT ; \
"$CODE" \
test/electron/index.js "$@"
2016-01-04 12:35:25 +01:00
fi