From 3a5ef031300dac45759f6847ac999918842a4fad Mon Sep 17 00:00:00 2001 From: southerntofu Date: Sun, 20 Feb 2022 20:16:53 +0100 Subject: [PATCH] Support a ./cli script which provides a full-path to the freshly-compiled whck --- cli | 22 ++++++++++++++++++++++ spec | 2 +- test.sh | 17 +++++++++++------ 3 files changed, 34 insertions(+), 7 deletions(-) create mode 100755 cli diff --git a/cli b/cli new file mode 100755 index 0000000..ca66844 --- /dev/null +++ b/cli @@ -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 diff --git a/spec b/spec index 71804c4..9b18c0e 160000 --- a/spec +++ b/spec @@ -1 +1 @@ -Subproject commit 71804c4b3a5f19bb53fdab0bbcecb39ed0919aca +Subproject commit 9b18c0e162a904f6760fb8ce6516f71c883f75d8 diff --git a/test.sh b/test.sh index e7edb4f..c2bb6af 100755 --- a/test.sh +++ b/test.sh @@ -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