diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index a750ba66b..fa641826d 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -107,7 +107,7 @@ jobs: - name: Stage 2 - Integration Test run: find tests -maxdepth 1 -name '[0-9]*.sh' -print0 | xargs -0 -I {} sh -c 'sh {} -v' env: - CABIN_BIN: ${{ github.workspace }}/cabin-out/debug/cabin + CABIN: ${{ github.workspace }}/cabin-out/debug/cabin CABIN_TERM_COLOR: auto # - name: Print coverage diff --git a/tests/01-cabin-exists.sh b/tests/01-cabin-exists.sh index cdbc425c6..0dfc8144d 100644 --- a/tests/01-cabin-exists.sh +++ b/tests/01-cabin-exists.sh @@ -6,7 +6,7 @@ WHEREAMI=$(dirname "$(realpath "$0")") . $WHEREAMI/setup.sh test_expect_success 'The cabin binary exists' ' - test -x "$CABIN_BIN" + test -x "$CABIN" ' test_done diff --git a/tests/02-new.sh b/tests/02-new.sh index ec9930785..3a30e177b 100644 --- a/tests/02-new.sh +++ b/tests/02-new.sh @@ -7,7 +7,7 @@ WHEREAMI=$(dirname "$(realpath "$0")") test_expect_success 'cabin new bin hello_world' ' test_when_finished "rm -rf hello_world" && - "$CABIN_BIN" new hello_world 2>actual && + "$CABIN" new hello_world 2>actual && ( test -d hello_world && cd hello_world && @@ -25,7 +25,7 @@ EOF test_expect_success 'cabin new lib hello_world' ' test_when_finished "rm -rf hello_world" && - "$CABIN_BIN" new --lib hello_world 2>actual && + "$CABIN" new --lib hello_world 2>actual && ( test -d hello_world && cd hello_world && @@ -41,7 +41,7 @@ EOF ' test_expect_success 'cabin new empty' ' - test_must_fail "$CABIN_BIN" new 2>actual && + test_must_fail "$CABIN" new 2>actual && cat >expected <<-EOF && Error: package name must not be empty EOF @@ -51,7 +51,7 @@ EOF test_expect_success 'cabin new existing' ' test_when_finished "rm -rf existing" && mkdir -p existing && - test_must_fail "$CABIN_BIN" new existing 2>actual && + test_must_fail "$CABIN" new existing 2>actual && cat >expected <<-EOF && Error: directory \`existing\` already exists EOF diff --git a/tests/03-fmt.sh b/tests/03-fmt.sh index 38bc611dc..b82c79b7f 100644 --- a/tests/03-fmt.sh +++ b/tests/03-fmt.sh @@ -10,10 +10,10 @@ command -v clang-format >/dev/null && test_set_prereq CLANG_FORMAT if ! test_have_prereq CLANG_FORMAT; then test_expect_success 'cabin fmt without clang-format' ' test_when_finished "rm -rf pkg" && - "$CABIN_BIN" new pkg && + "$CABIN" new pkg && cd pkg && ( - test_must_fail "$CABIN_BIN" fmt 2>actual && + test_must_fail "$CABIN" fmt 2>actual && cat >expected <<-EOF && Error: fmt command requires clang-format; try installing it by: apt/brew install clang-format @@ -30,12 +30,12 @@ test_expect_success 'cabin fmt' ' OUT=$(mktemp -d) && test_when_finished "rm -rf $OUT" && cd $OUT && - "$CABIN_BIN" new pkg && + "$CABIN" new pkg && cd pkg && ( echo "int main(){}" >src/main.cc && md5sum src/main.cc >before && - "$CABIN_BIN" fmt 2>actual && + "$CABIN" fmt 2>actual && md5sum src/main.cc >after && test_must_fail test_cmp before after && cat >expected <<-EOF && @@ -49,11 +49,11 @@ test_expect_success 'cabin fmt no targets' ' OUT=$(mktemp -d) && test_when_finished "rm -rf $OUT" && cd $OUT && - "$CABIN_BIN" new pkg && + "$CABIN" new pkg && cd pkg && ( rm src/main.cc && - "$CABIN_BIN" fmt 2>actual && + "$CABIN" fmt 2>actual && cat >expected <<-EOF && Warning: no files to format EOF @@ -65,11 +65,11 @@ test_expect_success 'cabin fmt without manifest' ' OUT=$(mktemp -d) && test_when_finished "rm -rf $OUT" && cd $OUT && - "$CABIN_BIN" new pkg && + "$CABIN" new pkg && cd pkg && ( rm cabin.toml && - test_must_fail "$CABIN_BIN" fmt 2>actual && + test_must_fail "$CABIN" fmt 2>actual && cat >expected <<-EOF && Error: cabin.toml not find in \`$(realpath $OUT)/pkg\` and its parents EOF @@ -82,11 +82,11 @@ test_expect_success 'cabin fmt without name in manifest' ' OUT=$(mktemp -d) && test_when_finished "rm -rf $OUT" && cd $OUT && - "$CABIN_BIN" new pkg && + "$CABIN" new pkg && cd pkg && ( echo "[package]" >cabin.toml && - test_must_fail "$CABIN_BIN" fmt 2>actual && + test_must_fail "$CABIN" fmt 2>actual && cat >expected <<-EOF && Error: toml::value::at: key "name" not found --> $(realpath $OUT)/pkg/cabin.toml diff --git a/tests/04-init.sh b/tests/04-init.sh index 1b3a0d138..e19cf4a0a 100644 --- a/tests/04-init.sh +++ b/tests/04-init.sh @@ -10,7 +10,7 @@ test_expect_success 'cabin init' ' test_when_finished "rm -rf $OUT" && mkdir $OUT/pkg && cd $OUT/pkg && - "$CABIN_BIN" init 2>actual && + "$CABIN" init 2>actual && cat >expected <<-EOF && Created binary (application) \`pkg\` package EOF @@ -23,13 +23,13 @@ test_expect_success 'cabin init existing' ' test_when_finished "rm -rf $OUT" && mkdir $OUT/pkg && cd $OUT/pkg && - "$CABIN_BIN" init 2>actual && + "$CABIN" init 2>actual && cat >expected <<-EOF && Created binary (application) \`pkg\` package EOF test_cmp expected actual && test -f cabin.toml - test_must_fail "$CABIN_BIN" init 2>actual && + test_must_fail "$CABIN" init 2>actual && cat >expected <<-EOF && Error: cannot initialize an existing cabin package EOF diff --git a/tests/05-version.sh b/tests/05-version.sh index fab76f16e..68e4fbd91 100644 --- a/tests/05-version.sh +++ b/tests/05-version.sh @@ -9,7 +9,7 @@ test_expect_success 'cabin version' ' VERSION=$(grep -m1 version "$WHEREAMI"/../cabin.toml | cut -f 2 -d'\''"'\'') && COMMIT_SHORT_HASH=$(git rev-parse --short=8 HEAD) && COMMIT_DATE=$(git show -s --date=format-local:%Y-%m-%d --format=%cd) && - "$CABIN_BIN" version 1>actual && + "$CABIN" version 1>actual && cat >expected <<-EOF && cabin $VERSION ($COMMIT_SHORT_HASH $COMMIT_DATE) EOF @@ -17,8 +17,8 @@ EOF ' test_expect_success 'cabin verbose version' ' - "$CABIN_BIN" -vV 1>actual1 && - "$CABIN_BIN" -Vv 1>actual2 && + "$CABIN" -vV 1>actual1 && + "$CABIN" -Vv 1>actual2 && test_cmp actual1 actual2 && grep compiler actual1 ' diff --git a/tests/06-run.sh b/tests/06-run.sh index 1d8274eee..548b2737d 100644 --- a/tests/06-run.sh +++ b/tests/06-run.sh @@ -9,9 +9,9 @@ test_expect_success 'cabin run hello_world' ' OUT=$(mktemp -d) && test_when_finished "rm -rf $OUT" && cd $OUT && - "$CABIN_BIN" new hello_world && + "$CABIN" new hello_world && cd hello_world && - "$CABIN_BIN" run 1>stdout 2>stderr && + "$CABIN" run 1>stdout 2>stderr && ( test -d cabin-out && test -d cabin-out/debug && diff --git a/tests/07-remove.sh b/tests/07-remove.sh index 0951b97de..d51cbb78e 100644 --- a/tests/07-remove.sh +++ b/tests/07-remove.sh @@ -7,13 +7,13 @@ WHEREAMI=$(dirname "$(realpath "$0")") test_expect_success 'cabin remove tbb mydep toml11' ' test_when_finished "rm -rf remove_test" && - "$CABIN_BIN" new remove_test && + "$CABIN" new remove_test && cd remove_test && echo "[dependencies]" >> cabin.toml && echo "tbb = {}" >> cabin.toml && echo "toml11 = {}" >> cabin.toml && ( - "$CABIN_BIN" remove tbb mydep toml11 2>actual && + "$CABIN" remove tbb mydep toml11 2>actual && ! grep -q "tbb" cabin.toml && ! grep -q "toml11" cabin.toml ) && diff --git a/tests/setup.sh b/tests/setup.sh index 1412b8fed..7e64bc8e5 100644 --- a/tests/setup.sh +++ b/tests/setup.sh @@ -1,7 +1,7 @@ #!/bin/sh export WHEREAMI=$(dirname "$(realpath "$0")") -export CABIN_BIN="${CABIN_BIN:-"$WHEREAMI/../build/cabin"}" +export CABIN="${CABIN:-"$WHEREAMI/../build/cabin"}" SAVETZ=${TZ:-UTC}