Support a ./cli script which provides a full-path to the freshly-compiled whck

This commit is contained in:
southerntofu 2022-02-20 20:16:53 +01:00
parent e02cea8762
commit 3a5ef03130
3 changed files with 34 additions and 7 deletions

22
cli Executable file
View File

@ -0,0 +1,22 @@
#! /usr/bin/env bash
SCRIPTDIR="$(dirname "$0")"
if [ -f "$SCRIPTDIR"/target/release/whck ]; then
output="$(cargo build --release 2>&1)"
if [ $? -eq 0 ]; then
# Build succeeded echo path to binary
echo "$SCRIPTDIR"/target/release/whck
else
echo "$output"
exit 1
fi
else
output="$(cargo build 2>&1)"
if [ $? -eq 0 ]; then
echo "$SCRIPTDIR"/target/debug/whck
else
echo "$output"
exit 1
fi
fi

2
spec

@ -1 +1 @@
Subproject commit 71804c4b3a5f19bb53fdab0bbcecb39ed0919aca
Subproject commit 9b18c0e162a904f6760fb8ce6516f71c883f75d8

17
test.sh
View File

@ -5,7 +5,7 @@ ORIGDIR="$(pwd)"
if [ ! -f "$SCRIPTDIR"/spec/test_cli.sh ]; then
echo "Submodule not cloned yet. Doing it now"
cd $SCRIPTDIR
cd "$SCRIPTDIR"
git submodule init
if ! git submodule update; then
echo "Failed to download submodules. Are you connected to the internet?"
@ -13,12 +13,17 @@ if [ ! -f "$SCRIPTDIR"/spec/test_cli.sh ]; then
fi
fi
if [ -f "$SCRIPTDIR"/target/release/whck ]; then
cargo build --release
"$SCRIPTDIR"/spec/test_cli.sh "$SCRIPTDIR"/target/release/whck
# If ./cli succeeds, it contains a path to the executable
# Otherwise it may contain build error messages
executable="$("$SCRIPTDIR"/cli)"
if [ $? -eq 0 ]; then
"$SCRIPTDIR"/spec/test_cli.sh "$executable"
status=$?
else
cargo build
"$SCRIPTDIR"/spec/test_cli.sh "$SCRIPTDIR"/target/debug/whck
status=1
echo "Build failed. OUTPUT:"
echo "$output"
fi
cd "$ORIGDIR"
exit $status