Skip to content

Commit f1c3dd8

Browse files
committed
upgrade to modern bats
1 parent 29839a0 commit f1c3dd8

File tree

7 files changed

+14
-8
lines changed

7 files changed

+14
-8
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "test/test_helper/bats-assert"]
55
path = test/test_helper/bats-assert
66
url = https://github.com/ztombol/bats-assert
7+
[submodule "test/bats"]
8+
path = test/bats
9+
url = https://github.com/bats-core/bats-core.git

hacking-and-testing.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,23 +14,25 @@ cd ~/projects/catfabulator && git diff
1414

1515
### Running tests
1616

17-
You'll need to install [bats](https://github.com/sstephenson/bats#installing-bats-from-source), the Bash automated testing system. It's also available as `brew install bats`
17+
The tests use [bats-core](https://bats-core.readthedocs.io/en/latest/index.html), the Bash automated testing system.
1818

1919
```sh
2020
git submodule sync
21-
git submodule update --init # pull in the assertion library, bats-assert
21+
git submodule update --init
2222

2323
# run the test suite once:
24-
bats test
24+
./test/bats/bin/bats test
2525

2626
# run it on every change with `entr`
2727
brew install entr
28-
ls --color=never diff-so-fancy test/*.bats | entr bats test
28+
ls --color=never diff-so-fancy test/*.bats | entr ./test/bats/bin/bats test
2929
```
30+
3031
When writing assertions, you'll likely want to compare to expected output. To grab that reliably, you can use something like `git --no-pager diff | diff-so-fancy > output.txt`
3132

3233
You can lint your scripts via shellcheck, our CI bots will also check.
3334

3435
```sh
3536
brew install shellcheck
3637
shellcheck *.sh
38+
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"diff-so-fancy": "diff-so-fancy"
77
},
88
"scripts": {
9-
"test": "bats test"
9+
"test": "./test/bats/bin/bats test"
1010
},
1111
"repository": {
1212
"type": "git",

test/bats

Submodule bats added at 49b377a

test/diff-so-fancy.bats

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ output=$( load_fixture "ls-function" | $diff_so_fancy )
1111

1212
@test "diff-so-fancy runs exits without error" {
1313
load_fixture "ls-function" | $diff_so_fancy
14-
assert_success
14+
run assert_success
1515
}
1616

1717
@test "index line is removed entirely" {

test/test_helper/bats-support

0 commit comments

Comments
 (0)