-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwatch-test.sh
More file actions
executable file
·105 lines (91 loc) · 2.19 KB
/
watch-test.sh
File metadata and controls
executable file
·105 lines (91 loc) · 2.19 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
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
#!/usr/bin/env bash
set -euo pipefail
IGNORE_SPECS=(
# "Hasskell.Language.DiagnosticSpec"
# "Hasskell.Language.ProvenanceSpec"
)
SEED_ARG=""
SPEC_NAMES=()
ALLOW_WARNINGS=false
# parse args
for arg in "$@"; do
case "$arg" in
--seed=*)
SEED_ARG="$arg"
;;
--spec=*)
SPEC_NAMES+=("${arg#--spec=}")
;;
--warnings)
ALLOW_WARNINGS=true
;;
*)
echo "unknown arg: $arg" >&2
exit 1
;;
esac
done
# seed handling
if [[ -n "${SEED_ARG}" ]]; then
n="${SEED_ARG#--seed=}"
SEED_EXPR="(Test.Syd.Run.FixedSeed ${n})"
else
SEED_EXPR="Test.Syd.Run.RandomSeed"
fi
# auto-discover specs if none provided
if [[ ${#SPEC_NAMES[@]} -eq 0 ]]; then
mapfile -t SPEC_NAMES < <(
fd 'Spec\.hs$' |
grep '/test/' |
grep -v '/Spec\.hs$' |
sed -E 's|^.*?/test/||; s|\.hs$||; s|/|.|g'
)
fi
# apply ignore list
for ignore in "${IGNORE_SPECS[@]}"; do
SPEC_NAMES=("${SPEC_NAMES[@]/$ignore/}")
done
# drop empty entries
tmp=()
for s in "${SPEC_NAMES[@]}"; do
if [[ -n "$s" ]]; then
tmp+=("$s")
fi
done
SPEC_NAMES=("${tmp[@]}")
if [[ ${#SPEC_NAMES[@]} -eq 0 ]]; then
echo "no specs to run after filtering ignore list" >&2
exit 1
fi
# build expression:
# Test.Syd.sydTestWith settings (spec1.spec >> spec2.spec >> ...)
# NOTE: sydTestWith expects a single combined TestDef; (>>) sequences them.
SPEC_EXPR=""
for s in "${SPEC_NAMES[@]}"; do
if [[ -z "$SPEC_EXPR" ]]; then
SPEC_EXPR="${s}.spec"
else
SPEC_EXPR="${SPEC_EXPR} Prelude.>> ${s}.spec"
fi
done
echo "${SPEC_EXPR}"
EXPR="Test.Syd.sydTestWith \
(Test.Syd.OptParse.defaultSettings \
{ Test.Syd.OptParse.settingGoldenStart = Prelude.True \
, Test.Syd.OptParse.settingSeed = ${SEED_EXPR} \
, Test.Syd.OptParse.settingSkipPassed = Prelude.True \
, Test.Syd.OptParse.settingRetries = 0 \
, Test.Syd.OptParse.settingReportProgress = Test.Syd.OptParse.ReportProgress \
}) \
(${SPEC_EXPR})"
STACK="stack --work-dir .watch-stack-work \
ghci hasskell-lib:lib hasskell-lib:test:hasskell-lib-test"
WARNINGS=""
if [ "${ALLOW_WARNINGS}" = true ]; then
WARNINGS="--warnings"
fi
ghcid \
--command "${STACK}" \
--test "${EXPR}" \
${WARNINGS} \
--color=always