-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathruntests.sh
More file actions
executable file
·60 lines (49 loc) · 1.05 KB
/
runtests.sh
File metadata and controls
executable file
·60 lines (49 loc) · 1.05 KB
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
#!/usr/bin/env bash
export genpass=./genpass.sh
export seed="test seed"
export masterpw="test masterpw"
tmp=$(mktemp -d)
homebak=$tmp/.genpass_bak
export homedir=$tmp/.genpass
timeout="10s"
passed=0
failed=0
skipped=0
$genpass --home $homebak --create <(echo -n $seed) < <(echo -e "${masterpw}\n${masterpw}") >/dev/null
for test in $(ls tests); do
echo -n "running test $test..."
# skip if the test is not executable
if [[ ! -x tests/$test ]]; then
echo "skip"
: $((skipped += 1))
continue
fi
# make a clean home
cp -r $homebak $homedir
# run the test
if msg=$(timeout $timeout tests/$test); then
echo "pass"
: $((passed += 1))
else
if [[ $? -eq 124 ]]; then
echo "fail (timeout)"
else
echo "fail"
fi
: $((failed += 1))
fi
if [[ -n "$msg" ]]; then
echo $msg
fi
# delete the used home
rm -rf $homedir
done
# delete temporary directory
rm -r $tmp
# report
echo "$passed tests passed"
echo "$failed tests failed"
echo "$skipped tests skipped"
if [[ $failed -ne 0 ]]; then
exit 1
fi