-
Notifications
You must be signed in to change notification settings - Fork 4
/
speculos-wrapper
executable file
·40 lines (34 loc) · 1.24 KB
/
speculos-wrapper
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
#!/usr/bin/env bash
echo "Speculos Wrapper called with $*"
# Specify args for mocha / 'yarn run test' like this
# cargo test --test ts-tests --target=nanos.json -- --mocha-args="--grep 'provides a public key'"
# cargo test --test ts-tests --target=nanos.json -- --mocha-args="--timeout 30000"
MOCHA_ARGS=""
API_PORT=5005
run_ts_tests() {
speculos --api-port "$API_PORT" "$@" --display headless &
SPECULOS=$!
until wget -O/dev/null -o/dev/null http://localhost:$API_PORT/; do sleep 0.1; done;
cd ../ts-tests;
if ! [ -d "node_modules" ] ; then yarn install; fi
echo $MOCHA_ARGS | xargs yarn run test --
kill $SPECULOS
}
last="${@:$#}"
case $last in
--mocha-args=*)
echo "Matched --mocha-args=*"
MOCHA_ARGS=${last:13} # strip --mocha-args=
echo "Passing following args to yarn run test: $MOCHA_ARGS"
# Pass all args, except the last, to the speculos
run_ts_tests "${@:1:$#-1}"
;;
*ts_tests*|*docker-outputs*)
echo "Matched *ts_tests* / *docker-outputs*"
run_ts_tests "$@"
;;
*/deps/*) # Assume anything in the deps directory is a test, not the full app.
echo "Matched *tests*"
speculos --api-port "$API_PORT" "$@" --display headless ;;
*) speculos --api-port "$API_PORT" "$@" ;;
esac