summaryrefslogtreecommitdiff
path: root/check
blob: 486fe569272f217676be9ecd45357f7a0f29970e (plain)
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
#!/bin/sh
#
# Run the automated tests for the project.

set -eu

hideok=chronic
if [ "$#" -gt 0 ]; then
	case "$1" in
	verbose | -v | --verbose)
		hideok=
		shift
		;;
	esac
fi

got_cargo_cmd() {
	cargo "$1" --help >/dev/null
}

got_cargo_cmd clippy && cargo clippy -q --all-targets
$hideok cargo build --all-targets
got_cargo_cmd fmt && $hideok cargo fmt -- --check
$hideok cargo test

subplot docgen clab.subplot -o clab.html

target="$(cargo metadata --format-version=1 | python3 -c 'import sys, json; o = json.load(sys.stdin); print(o["target_directory"])')"
subplot codegen clab.subplot -o test.py
rm -f test.log
if [ "$(id -un)" = root ]; then
	echo Not running tests as root.
else
	$hideok python3 test.py --log test.log --env "CARGO_TARGET_DIR=$target" "$@"
fi

echo "Everything seems to be in order."