summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-09-10 09:14:27 +0300
committerLars Wirzenius <liw@liw.fi>2021-09-10 09:44:02 +0300
commitca762afcb46f42c6302b6a63b915d949e0bc8ade (patch)
tree218afe3db9b03fa8ef0798b51daadce3d67d2914
parent4035a94813da138f345be8f1e863e16d475eb668 (diff)
downloadobnam2-ca762afcb46f42c6302b6a63b915d949e0bc8ade.tar.gz
test: tell Subplot-generated test program where the binaries are
Previously, we blindly assumed that Cargo puts binaries in `target/debug` in the source tree. That is the default, but the user can change it. Now we get the Cargo target directory by parsing the output of "cargo metadata" and pass in the path to the test program via an environment variable. Also, reformat shell script. Sponsored-by: author
-rwxr-xr-xcheck40
1 files changed, 18 insertions, 22 deletions
diff --git a/check b/check
index 8ff40c1..7d5098c 100755
--- a/check
+++ b/check
@@ -5,28 +5,24 @@
set -eu
hideok=chronic
-if [ "$#" -gt 0 ]
-then
- case "$1" in
+if [ "$#" -gt 0 ]; then
+ case "$1" in
verbose | -v | --verbose)
- hideok=
- shift
- ;;
- esac
+ hideok=
+ shift
+ ;;
+ esac
fi
-require_cmd()
-{
- if ! command -v "$1" > /dev/null
- then
- echo "Need to have $1 installed, but can't find it" 1>&2
- return 1
- fi
+require_cmd() {
+ if ! command -v "$1" >/dev/null; then
+ echo "Need to have $1 installed, but can't find it" 1>&2
+ return 1
+ fi
}
-got_cargo_cmd()
-{
- cargo "$1" --help > /dev/null
+got_cargo_cmd() {
+ cargo "$1" --help >/dev/null
}
require_cmd rustc
@@ -43,7 +39,7 @@ require_cmd pdflatex
# daemonize installation location changed from Debian 10 to 11.
require_cmd daemonize || require_cmd /usr/sbin/daemonize
-got_cargo_cmd clippy && cargo clippy --all-targets -q
+got_cargo_cmd clippy && cargo clippy --all-targets -q
$hideok cargo build --all-targets
got_cargo_cmd fmt && $hideok cargo fmt -- --check
$hideok cargo test
@@ -51,13 +47,13 @@ $hideok cargo test
subplot docgen obnam.md -o obnam.html
subplot docgen obnam.md -o obnam.pdf
+target="$(cargo metadata --format-version=1 | python3 -c 'import sys, json; o = json.load(sys.stdin); print(o["target_directory"])')"
subplot codegen obnam.md -o test.py
rm -f test.log
-if [ "$(id -un)" = root ]
-then
- echo Not running tests as root.
+if [ "$(id -un)" = root ]; then
+ echo Not running tests as root.
else
- $hideok python3 test.py --log test.log "$@"
+ $hideok python3 test.py --log test.log --env "CARGO_TARGET_DIR=$target" "$@"
fi
echo "Everything seems to be in order."