-
Notifications
You must be signed in to change notification settings - Fork 0
/
test
executable file
·45 lines (37 loc) · 1.01 KB
/
test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#! /bin/bash
# run vellum tests and jshint the source
export PATH=`npm bin`:$PATH
if [[ "$1" == "--help" ]]; then
echo "USAGE: $0 [TEST_GREP] [--no-jshint] [mocha-phantomjs-options]"
exit
fi
qs=""
if [[ "$1" != "" && "$1" != -* ]]; then
qs="$1"
shift
fi
run_jshint="true"
if [[ "$1" == "--no-jshint" ]]; then
run_jshint="false"
shift
fi
temp="/tmp/test-$$.tmp"
# run the tests
phantomjs node_modules/mocha-phantomjs-core/mocha-phantomjs-core.js 'index.html' spec "{\"grep\":\"$qs\",\"useColors\":true}" | tee $temp
RESULT="${PIPESTATUS[0]}"
if grep -q "Parse error" $temp; then
rm $temp
else
rm $temp
if [ "$RESULT" -ne 0 ]; then
# stop on mocha-phantomjs non-zero exit status (except parse error)
# NOTE there may be edge cases where grep exits with non-zero
# causing this script to exit prematurely
exit 1
fi
fi
if [[ "$run_jshint" == "true" ]]; then
jshint src \
&& jshint --config tests/.jshintrc tests \
&& echo "jshint passed"
fi