-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathlocal_test_helper.sh
executable file
·119 lines (100 loc) · 2.64 KB
/
local_test_helper.sh
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env bash
function build_all() {
# docker command to build
cat <<"EOF" | docker run --rm -i --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath ./):/app" ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder:latest
rm -rf target
cargo ledger build nanos
cargo ledger build nanosplus
cargo ledger build nanox
cargo ledger build stax
cargo ledger build flex
exit
EOF
}
function test() {
if [[ -n "$GOLDEN" ]] ;
then
golden_suffix="--golden_run"
else
golden_suffix=""
fi
if [[ -n "$2" ]] ;
then
filter="-k $2"
else
filter=""
fi
docker run --rm -i --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" --name app-near-container ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest /bin/bash -s <<EOF
[ -f ./tests/requirements.txt ] && pip install -r ./tests/requirements.txt
pytest ./tests --tb=short --log-cli-level=$PYTEST_LOG_LEVEL $filter -v --device $1 $golden_suffix
EOF
}
function test_all_nano() {
echo $1
if [[ -n "$1" ]] ;
then
filter="-k $1"
else
filter=""
fi
echo "$filter"
# docker commands to test with Ragger (for ALL)
docker run --rm -i --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" --name app-near-container ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest /bin/bash -s <<EOF
set -e
[ -f ./tests/requirements.txt ] && pip install -r ./tests/requirements.txt
pytest ./tests --log-cli-level=$PYTEST_LOG_LEVEL --tb=short $filter -v --device all_nano
EOF
}
function test_all() {
echo $1
if [[ -n "$1" ]] ;
then
filter="-k $1"
else
filter=""
fi
echo "$filter"
# docker commands to test with Ragger (for ALL)
docker run --rm -i --privileged -v "/dev/bus/usb:/dev/bus/usb" -v "$(realpath .):/app" --name app-near-container ghcr.io/ledgerhq/ledger-app-builder/ledger-app-dev-tools:latest /bin/bash -s <<EOF
set -e
[ -f ./tests/requirements.txt ] && pip install -r ./tests/requirements.txt
pytest ./tests --log-cli-level=$PYTEST_LOG_LEVEL --tb=short $filter -v --device all
EOF
}
while getopts ":c:t:f:g" opt; do
case $opt in
c) command="$OPTARG"
;;
t) target="$OPTARG"
;;
f) filter="$OPTARG"
;;
g)
echo "Golden run was triggered"
export GOLDEN=run
;;
\?) echo "Invalid option -$OPTARG" >&2
exit 1
;;
esac
case $OPTARG in
-*) echo "Option $opt needs a valid argument"
exit 1
;;
esac
done
case $command in
build_all)
build_all
;;
test)
test $target $filter
;;
test_all)
test_all $filter
;;
*)
echo -n "unknown command" $command
exit 2
;;
esac