-
Notifications
You must be signed in to change notification settings - Fork 81
Expand file tree
/
Copy pathprecheck.bash
More file actions
executable file
·139 lines (125 loc) · 3.78 KB
/
precheck.bash
File metadata and controls
executable file
·139 lines (125 loc) · 3.78 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
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
#!/usr/bin/env bash
set -euo pipefail
HELP="Usage: $0 [TARGET]...
Run pre-check tests for the given targets.
--all Run all tests
--dfir Run DFIR tests
--wasm Run WASM tests (requires --dfir)
--hydro Run Hydro tests
--docker Run Docker tests (requires --hydro)
--ecs Run ECS tests (requires --hydro)
--website Run Website tests
--help Display this help message
"
TEST_DFIR=false
TEST_HYDRO=false
TEST_DOCKER=false
TEST_ECS=false
TEST_WEBSITE=false
TEST_WASM=false
TEST_ALL=false
while (( $# )); do
case $1 in
--dfir)
TEST_DFIR=true
;;
--hydro)
TEST_HYDRO=true
;;
--docker)
TEST_DOCKER=true
;;
--ecs)
TEST_ECS=true
;;
--website)
TEST_WEBSITE=true
;;
--wasm)
TEST_WASM=true
;;
--all)
TEST_DFIR=true
TEST_HYDRO=true
TEST_DOCKER=true
TEST_ECS=true
TEST_WEBSITE=true
TEST_WASM=true
TEST_ALL=true
;;
--help)
echo "$HELP"
exit 0
;;
*)
echo "$0: Unknown option: $1
Try '$0 --help' for more information.
"
exit 1
;;
esac
shift
done
# If either `--docker` or `--ecs`, ensure `--hydro` was also included.
if ( [ "$TEST_DOCKER" = true ] || [ "$TEST_ECS" = true ] ) && [ "$TEST_HYDRO" = false ]; then
echo "$0: --docker and --ecs require --hydro.
Try '$0 --help' for more information.
"
exit 3
fi
# If `--wasm`, ensure `--dfir` was also included.
if [ "$TEST_WASM" = true ] && [ "$TEST_DFIR" = false ]; then
echo "$0: --wasm requires --dfir.
Try '$0 --help' for more information.
"
exit 4
fi
TARGETS=""
FEATURES=""
if [ "$TEST_DFIR" = true ]; then
TARGETS="$TARGETS -p dfir_lang -p dfir_pipes -p dfir_rs -p dfir_macro"
fi
if [ "$TEST_HYDRO" = true ]; then
TARGETS="$TARGETS -p hydro_lang -p hydro_std -p hydro_test -p hydro_deploy -p hydro_deploy_integration"
FEATURES="$FEATURES --features deploy,sim"
if [ "$TEST_DOCKER" = true ]; then
FEATURES="$FEATURES --features docker"
fi
if [ "$TEST_ECS" = true ]; then
FEATURES="$FEATURES --features ecs"
fi
fi
if [ "$TEST_WEBSITE" = true ]; then
TARGETS="$TARGETS -p website_playground"
fi
if [ "$TEST_ALL" = true ]; then
TARGETS="--workspace"
elif [ "" = "$TARGETS" ]; then
echo "$0: No targets specified.
Try '$0 --help' for more information.
"
exit 2
fi
# Run the tests, echoing the commands as they are run
set -x
cargo +nightly fmt --all
cargo clippy $TARGETS --all-targets --no-default-features -- -D warnings
cargo clippy $TARGETS --all-targets --all-features -- -D warnings
cargo clippy $TARGETS --all-targets $FEATURES -- -D warnings
[ "$TEST_ALL" = false ] || cargo check --all-targets --no-default-features
# `--all-targets` is everything except `--doc`: https://github.com/rust-lang/cargo/issues/6669.
INSTA_FORCE_PASS=1 INSTA_UPDATE=always TRYBUILD=overwrite cargo nextest run $TARGETS --all-targets --no-fail-fast $FEATURES
cargo test $TARGETS --doc
# Test website_playground wasm build.
if [ "$TEST_WEBSITE" = true ]; then
pushd website_playground
rustup toolchain install nightly
RUSTUP_TOOLCHAIN="nightly" RUSTFLAGS="--cfg procmacro2_semver_exempt --cfg super_unstable" wasm-pack build
popd
fi
if [ "$TEST_DFIR" = true ] && [ "$TEST_WASM" = true ]; then
rustup toolchain install nightly
RUSTUP_TOOLCHAIN="nightly" CARGO_TARGET_WASM32_UNKNOWN_UNKNOWN_RUNNER=wasm-bindgen-test-runner cargo test -p dfir_rs --target wasm32-unknown-unknown --tests --no-fail-fast
fi
# Test that docs build.
RUSTDOCFLAGS="--cfg docsrs -Dwarnings" cargo +nightly doc --no-deps --all-features