Skip to content

Commit

Permalink
tests: replace CABIN_BIN with CABIN (#1132)
Browse files Browse the repository at this point in the history
  • Loading branch information
ken-matsui authored Jan 31, 2025
1 parent 6a0717b commit 69cd916
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/01-cabin-exists.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
8 changes: 4 additions & 4 deletions tests/02-new.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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 &&
Expand All @@ -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
Expand All @@ -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
Expand Down
20 changes: 10 additions & 10 deletions tests/03-fmt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 &&
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/04-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 3 additions & 3 deletions tests/05-version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ 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
test_cmp expected actual
'

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
'
Expand Down
4 changes: 2 additions & 2 deletions tests/06-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand Down
4 changes: 2 additions & 2 deletions tests/07-remove.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
) &&
Expand Down
2 changes: 1 addition & 1 deletion tests/setup.sh
Original file line number Diff line number Diff line change
@@ -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}

Expand Down

0 comments on commit 69cd916

Please sign in to comment.