-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-checks
executable file
·141 lines (114 loc) · 3.22 KB
/
run-checks
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#!/usr/bin/env bash
set -o nounset -o errexit # -o xtrace # Old Bash has buggy `errexit` - comment-out for such.
# This runs the tests, examples, and docs-gen with all possibilities of the crate's features.
readonly CARGO_OPTS=${1:-} # Can give a +toolchain argument, e.g.
# shellcheck disable=SC2086 # Want word-splitting of `$CARGO_OPTS`.
function cargo { command cargo $CARGO_OPTS "$@" ;}
readonly FEATURES=("premade" "channel_notify_facility")
FEATURES_COMBOS=()
function features_combos {
local N=$1 PREFIX=${2:-}
for I in $(seq "$N" 1 $((${#FEATURES[@]} - 1)) 2> /dev/null); do
local X=${PREFIX}${FEATURES[I]}
FEATURES_COMBOS+=("$X")
features_combos $((I + 1)) "$X," # (Note the trailing comma.)
done
}
features_combos 0
readonly FEATURES_COMBOS
# for F in "${FEATURES_COMBOS[@]}"; do echo "$F"; done
readonly COMMANDS=(
"test --tests"
"test --doc"
"run --example child_reset_mask"
"run --example dedicated_thread"
"run --example exercise"
"run --example minimal"
doc
)
FAILURES=()
SUCCESSES=()
function run {
local C
for C in "${COMMANDS[@]}"; do
# shellcheck disable=SC2206 # Want word-splitting.
local CMD=(cargo $C "$@")
echo "Running: ${CMD[*]}"
if quiet_unless_example "${CMD[@]}"; then
SUCCESSES+=("${CMD[*]}")
else
FAILURES+=("${CMD[*]}")
fi
done
}
function quiet_unless_example {
if [[ "$*" =~ ^cargo\ +run\ +--example\ + ]]; then
"$@"
else
"$@" > /dev/null 2>&1
fi
}
OS=$(uname)
readonly OS
echo "On: $OS. Using: $(cargo --version)."
run # First, run them with default features.
for F in "${FEATURES_COMBOS[@]}"; do
run --no-default-features --features "$F" # Run with all combinations of features.
done
run --no-default-features # Lastly, run with no features.
readonly FAILURES
EXPECTED_FAILURES=(
# Without the "premade" feature, these examples can't build.
"cargo run --example dedicated_thread --no-default-features"
"cargo run --example exercise --no-default-features"
"cargo run --example minimal --no-default-features"
)
readonly EXPECTED_FAILURES
SURPRISE_FAILURES=()
SURPRISE_SUCCESSES=()
for F in "${FAILURES[@]}"; do
IS_SURPRISE=true
for E in "${EXPECTED_FAILURES[@]}"; do
if [ "$F" = "$E" ]; then
IS_SURPRISE=false
break
fi
done
if [ "$IS_SURPRISE" = true ]; then
SURPRISE_FAILURES+=("$F")
fi
done
readonly SURPRISE_FAILURES
for E in "${EXPECTED_FAILURES[@]}"; do
IS_SURPRISE=false
for S in "${SUCCESSES[@]}"; do
if [ "$E" = "$S" ]; then
IS_SURPRISE=true
break
fi
done
if [ "$IS_SURPRISE" = true ]; then
SURPRISE_SUCCESSES+=("$E")
fi
done
readonly SURPRISE_SUCCESSES
if (( ${#SURPRISE_SUCCESSES[@]} >= 1 ))
then
echo
echo "SURPRISE SUCCESSES (${#SURPRISE_SUCCESSES[@]}):"
for S in "${SURPRISE_SUCCESSES[@]}"; do
echo "$S"
done
fi
if (( ${#SURPRISE_FAILURES[@]} == 0 ))
then
echo
echo "Success - no unexpected failures."
else
echo
echo "FAILURES (${#SURPRISE_FAILURES[@]}):"
for F in "${SURPRISE_FAILURES[@]}"; do
echo "$F"
done
exit 1
fi