-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
210 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
name: Test With Bats | ||
|
||
on: workflow_call | ||
|
||
jobs: | ||
bats-test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
- run: sudo apt install bats | ||
- run: ./scripts/bats-test-setup.sh | ||
- run: ./scripts/scripts/bats-test-run.sh | ||
- uses: actions/upload-artifact@v4 | ||
with: | ||
name: bats-test-resutls | ||
path: | | ||
./bats-test-* |
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 |
---|---|---|
|
@@ -2,3 +2,6 @@ target | |
*.deb | ||
*.deb.sha256sum | ||
*.deb.sha512sum | ||
test_helper | ||
.gitmodules | ||
bats-test-* |
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,12 @@ | ||
#!/usr/bin/env bash | ||
|
||
BATS_HELPER=test_helper | ||
export BATS_HELPER | ||
|
||
CUSTOM_LOG=bats-test-custom.log | ||
export CUSTOM_LOG | ||
|
||
SOURCE_BIN=$(pwd)/src/bin | ||
export SOURCE_BIN | ||
|
||
bats -r tests | tee bats-test-result.log |
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,8 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
sudo apt update -y | ||
sudo apt install bats -y | ||
|
||
git submodule add https://github.com/bats-core/bats-support.git test_helper/bats-support | ||
git submodule add https://github.com/bats-core/bats-assert.git test_helper/bats-assert |
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,38 @@ | ||
setup() { | ||
load '../common-setup' | ||
common_setup | ||
|
||
testDatafile=$BATS_TEST_DIRNAME/cat_test_data | ||
outputExpected=$BATS_TEST_FILENAME.$BATS_TEST_DESCRIPTION.expected | ||
outputActual="$TEST_TEMP_DIR/$(basename "$BATS_TEST_FILENAME").$BATS_TEST_DESCRIPTION.actual" | ||
|
||
} | ||
|
||
cat_test(){ | ||
command=$1 | ||
|
||
run bash -c "cat $testDatafile | $command | tee $outputActual" | ||
|
||
assert_output - < $outputExpected | ||
} | ||
@test "cat.blue" { | ||
cat_test cat.blue | ||
} | ||
@test "cat.cyan" { | ||
cat_test cat.cyan | ||
} | ||
@test "cat.green" { | ||
cat_test cat.green | ||
} | ||
@test "cat.grey" { | ||
cat_test cat.grey | ||
} | ||
@test "cat.magenta" { | ||
cat_test cat.magenta | ||
} | ||
@test "cat.red" { | ||
cat_test cat.red | ||
} | ||
@test "cat.yellow" { | ||
cat_test cat.yellow | ||
} |
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,2 @@ | ||
[1;34mHello World From cat.*! | ||
[0m |
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,2 @@ | ||
[1;36mHello World From cat.*! | ||
[0m |
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,2 @@ | ||
[1;32mHello World From cat.*! | ||
[0m |
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,2 @@ | ||
[1;90mHello World From cat.*! | ||
[0m |
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,2 @@ | ||
[1;35mHello World From cat.*! | ||
[0m |
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,2 @@ | ||
[1;31mHello World From cat.*! | ||
[0m |
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,2 @@ | ||
[1;33mHello World From cat.*! | ||
[0m |
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 @@ | ||
Hello World From cat.*! |
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,3 @@ | ||
Hello World From cat.*! (Line 1) | ||
Hello World From cat.*! (Line 2) | ||
Hello World From cat.*! (Line 3) |
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,37 @@ | ||
setup() { | ||
load '../common-setup' | ||
common_setup | ||
|
||
outputExpected=$BATS_TEST_FILENAME.expected | ||
outputActual="$TEST_TEMP_DIR/$(basename "$BATS_TEST_FILENAME").$BATS_TEST_DESCRIPTION.actual" | ||
|
||
testLine="Hello World!" | ||
} | ||
clear-colors-echo-test(){ | ||
command=$1 | ||
|
||
run bash -c "$command $testLine | clear-colors | tee $outputActual" | ||
assert_output - <$outputExpected | ||
} | ||
@test "clear-colors_echo.blue" { | ||
clear-colors-echo-test echo.blue | ||
} | ||
@test "clear-colors_echo.cyan" { | ||
clear-colors-echo-test echo.cyan | ||
} | ||
@test "clear-colors_echo.green" { | ||
clear-colors-echo-test echo.green | ||
} | ||
@test "clear-colors_echo.grey" { | ||
clear-colors-echo-test echo.grey | ||
} | ||
@test "clear-colors_echo.magenta" { | ||
clear-colors-echo-test echo.magenta | ||
} | ||
@test "clear-colors_echo.red" { | ||
clear-colors-echo-test echo.red | ||
} | ||
@test "clear-colors_echo.yellow" { | ||
clear-colors-echo-test echo.yellow | ||
} | ||
|
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 @@ | ||
Hello World! |
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,18 @@ | ||
common_setup(){ | ||
load "../../$BATS_HELPER/bats-support/load" | ||
load "../../$BATS_HELPER/bats-assert/load" | ||
|
||
PATH="$SOURCE_BIN:$PATH" | ||
|
||
echo "PATH: $PATH" >>"$CUSTOM_LOG" | ||
|
||
if [[ -z $BATS_RUN_TMPDIR ]]; then | ||
TEST_TEMP_DIR=/tmp/$CUSTOM_LOG | ||
mkdir -p $TEST_TEMP_DIR | ||
else | ||
TEST_TEMP_DIR=$BATS_RUN_TMPDIR | ||
fi | ||
|
||
echo "BATS_RUN_TMPDIR: $BATS_RUN_TMPDIR" >>"$CUSTOM_LOG" | ||
echo "TEST_TEMP_DIR: $TEST_TEMP_DIR" >>"$CUSTOM_LOG" | ||
} |
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 @@ | ||
setup(){ | ||
load '../common-setup' | ||
common_setup | ||
|
||
outputExpected=$BATS_TEST_FILENAME.$BATS_TEST_DESCRIPTION.expected | ||
outputActual="$TEST_TEMP_DIR/$(basename "$BATS_TEST_FILENAME").$BATS_TEST_DESCRIPTION.actual" | ||
|
||
testLine="Hello World!" | ||
} | ||
echo_test(){ | ||
command=$1 | ||
|
||
run bash -c "$command $testLine | tee $outputActual" | ||
assert_output - <$outputExpected | ||
} | ||
@test "echo.blue" { | ||
echo_test echo.blue | ||
} | ||
@test "echo.cyan" { | ||
echo_test echo.cyan | ||
} | ||
@test "echo.green" { | ||
echo_test echo.green | ||
} | ||
@test "echo.grey" { | ||
echo_test echo.grey | ||
} | ||
@test "echo.magenta" { | ||
echo_test echo.magenta | ||
} | ||
@test "echo.red" { | ||
echo_test echo.red | ||
} | ||
@test "echo.yellow" { | ||
echo_test echo.yellow | ||
} |
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,2 @@ | ||
[1;34mHello World! | ||
[0m |
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,2 @@ | ||
[1;36mHello World! | ||
[0m |
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,2 @@ | ||
[1;32mHello World! | ||
[0m |
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,2 @@ | ||
[1;90mHello World! | ||
[0m |
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,2 @@ | ||
[1;35mHello World! | ||
[0m |
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,2 @@ | ||
[1;31mHello World! | ||
[0m |
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,2 @@ | ||
[1;33mHello World! | ||
[0m |