-
Notifications
You must be signed in to change notification settings - Fork 2
/
Test
executable file
·72 lines (54 loc) · 1.73 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
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
#!/usr/bin/env bash
set -eu -o pipefail
PASSED=false
trap 'ec=$?; $PASSED || { echo 1>&2 "*** FAILED (exitcode=$ec)"; }' 0
qecho() {
[[ -n $quiet ]] && return
echo "$@"
}
hexdiff() {
cmp "$1" "$2" && return 0
diff -U 0 \
--label "$1" --label "$2" \
<(xxd -c8 -g1 "$1") <(xxd -c8 -g1 "$2")
}
basedir=$(cd "$(dirname "$0")" && pwd -P)
cd "$basedir"
# -C/-c (clean) must be first argument if present
[[ ${#@} -gt 0 && $1 == -C ]] && { shift; rm -rf .build/; }
[[ ${#@} -gt 0 && $1 == -c ]] && { shift; rm -rf .build/; }
# -q anywhere in the command line (even with -v!) sets functests quiet.
quiet=
for arg in "$@"; do [[ $arg == -q ]] && quiet=-q; done
. ./pactivate -q
pip show r8format 2>/dev/null \
| grep -s 'Editable project location:' >/dev/null \
|| {
echo "Installing editable r8format..."
pip install -q -e .
}
####################################################################
# Unit Tests
pytest -q "$@" # use pyproject.toml for configuration
####################################################################
# Functional Tests
ftdata=.build/programs/
mkdir -p $ftdata/detok
echo "====== bastok"
qecho "------ basdump basdump.bas"
basdump programs/basdump.bas | diff - programs/basdump.dump
qecho "------ detok simple.bas"
detok programs/simple.bas >$ftdata/detok/simple.ba0
diff -u {$ftdata/detok,programs}/simple.ba0
qecho "------ detok -e simple.bas"
detok -e programs/simple.bas >$ftdata/detok/simple.ba1
diff -u {$ftdata/detok,programs}/simple.ba1
{
f="binchars"
qecho "------ detok --binary $f.bas"
detok --binary programs/$f.bas >$ftdata/detok/$f.baa
hexdiff {$ftdata/detok,programs}/$f.baa
}
echo "====== cmtconv"
psrc/cmtconv/Test "$@"
PASSED=true