-
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
1 parent
8385fbc
commit f1ce673
Showing
4 changed files
with
88 additions
and
0 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 @@ | ||
external-sources=true |
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,48 @@ | ||
# Use bats in Repositories | ||
|
||
Create a repository... | ||
|
||
Create a structure with submodules, e.g: | ||
|
||
```plain | ||
src/ | ||
<project>.bash | ||
... | ||
test/ | ||
bats/ <- submodule | ||
test_helper/ | ||
bats-support/ <- submodule | ||
bats-assert/ <- submodule | ||
<test>.bats | ||
... | ||
``` | ||
|
||
```bash | ||
git submodule add https://github.com/bats-core/bats-core.git test/bats | ||
``` | ||
|
||
```bash | ||
git submodule add https://github.com/bats-core/bats-support.git test/test_helper/bats-support | ||
``` | ||
|
||
```bash | ||
git submodule add https://github.com/bats-core/bats-assert.git test/test_helper/bats-assert | ||
``` | ||
|
||
```bash | ||
git add . | ||
``` | ||
|
||
```bash | ||
git commit -m "Add bats as submodules" | ||
``` | ||
|
||
```bash | ||
git push | ||
``` | ||
|
||
Init and update all submodules: | ||
|
||
```bash | ||
git submodule update --init --recursive | ||
``` |
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,20 @@ | ||
# Run from project dir: | ||
# ./test/bats/bin/bats test/test-call-with-arguments.bats | ||
|
||
setup() { | ||
load 'test_helper/test-setup' | ||
init_bats | ||
|
||
chmod +x src/simbashlog.bash | ||
} | ||
|
||
teardown() { | ||
chmod -x src/simbashlog.bash | ||
} | ||
|
||
@test "simplest call with arguments" { | ||
run simbashlog.bash -a console -s error --message 'An error occured' | ||
remove_ansi_codes_from_output | ||
|
||
[[ "$output" == "[ERROR] - An error occured" ]] | ||
} |
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 @@ | ||
#!/usr/bin/env bash | ||
|
||
function init_bats { | ||
load 'test_helper/bats-support/load' | ||
load 'test_helper/bats-assert/load' | ||
|
||
# get the containing directory of this file | ||
# use $BATS_TEST_FILENAME instead of ${BASH_SOURCE[0]} or $0, | ||
# as those will point to the bats executable's location or the preprocessed file respectively | ||
PROJECT_ROOT="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." >/dev/null 2>&1 && pwd)" | ||
# make executables in src/ visible to PATH | ||
PATH="$PROJECT_ROOT/src:$PATH" | ||
} | ||
|
||
function remove_ansi_codes_from_output { | ||
echo "Actual output with ansi codes: '$output'" | ||
output=$(echo "$output" | sed -r 's/\x1B\[[0-9;]*[mK]//g') | ||
echo "Actual output without ansi codes: '$output'" | ||
} |