-
-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add more tests, test stage 1 & 2 (#1078)
- Loading branch information
1 parent
b59bbc5
commit 8fc441e
Showing
10 changed files
with
111 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
lib-sharness/ | ||
test-results/ | ||
sharness.sh | ||
trash* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
#!/bin/sh | ||
|
||
WHEREAMI=$(dirname "$(realpath "$0")") | ||
export CABIN_TERM_COLOR='never' | ||
|
||
test_description='Check if the cabin binary exists' | ||
|
||
. $WHEREAMI/sharness.sh | ||
WHEREAMI=$(dirname "$(realpath "$0")") | ||
. $WHEREAMI/setup.sh | ||
|
||
test_expect_success 'The cabin binary exists' ' | ||
test -x "$WHEREAMI"/../build/cabin | ||
test -x "$CABIN_BIN" | ||
' | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/sh | ||
|
||
test_description='Test the version command' | ||
|
||
WHEREAMI=$(dirname "$(realpath "$0")") | ||
. $WHEREAMI/setup.sh | ||
|
||
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 && | ||
cat >expected <<-EOF && | ||
cabin $VERSION ($COMMIT_SHORT_HASH $COMMIT_DATE) | ||
EOF | ||
test_cmp expected actual | ||
' | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/sh | ||
|
||
test_description='Test the run command' | ||
|
||
WHEREAMI=$(dirname "$(realpath "$0")") | ||
. $WHEREAMI/setup.sh | ||
|
||
test_expect_success 'cabin run hello_world' ' | ||
OUT=$(mktemp -d) && | ||
test_when_finished "rm -rf $OUT" && | ||
cd $OUT && | ||
"$CABIN_BIN" new hello_world && | ||
cd hello_world && | ||
"$CABIN_BIN" run 1>stdout 2>stderr && | ||
( | ||
test -d cabin-out && | ||
test -d cabin-out/debug && | ||
test -x cabin-out/debug/hello_world | ||
) && | ||
( | ||
TIME=$(cat stderr | grep Finished | grep -o '\''[0-9]\+\.[0-9]\+'\'') && | ||
cat >stderr_exp <<-EOF && | ||
Compiling hello_world v0.1.0 ($(realpath $OUT)/hello_world) | ||
Finished \`dev\` profile [unoptimized + debuginfo] target(s) in ${TIME}s | ||
EOF | ||
test_cmp stderr_exp stderr | ||
) && | ||
( | ||
cat >stdout_exp <<-EOF && | ||
Hello, world! | ||
EOF | ||
test_cmp stdout_exp stdout | ||
) | ||
' | ||
|
||
test_done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
|
||
export WHEREAMI=$(dirname "$(realpath "$0")") | ||
export CABIN_BIN="${CABIN_BIN:-"$WHEREAMI/../build/cabin"}" | ||
export CABIN_TERM_COLOR='never' | ||
|
||
. $WHEREAMI/sharness.sh |