Skip to content

Commit

Permalink
improvement: added bats as git submodule
Browse files Browse the repository at this point in the history
  • Loading branch information
BartSte committed Nov 22, 2023
1 parent 867cbdd commit d1ded2e
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 24 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,12 @@ jobs:

- name: Install bats
run: |
sudo apt-get update -y
sudo apt-get install git -y
git submodule add https://github.com/bats-core/bats-core.git test/bats
git submodule add https://github.com/bats-core/bats-support.git test/test_helper/bats-support
git submodule add https://github.com/bats-core/bats-assert.git test/test_helper/bats-assert
git submodule init
git submodule update
- name: Run Bats Test
shell: 'script -q -e -c "bash {0}"' # work around tty issues
env:
TERM: linux # fix tput for tty issue work around
run: |
export BATS_LIB_PATH="${PWD}/test":"${PWD}/test/bats":"${PWD}/test/test_helper"; $PWD/test/bats/bin/bats --tap test
$PWD/test/bats/bin/bats --tap test
22 changes: 12 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,28 +201,30 @@ This is useful when you do not like page wrapping.

## Tests

To run the test make sure the following is installed:
To run the test the following submodules need to be installed as git
sub modules:

- Install [bats-core](https://github.com/bats-core/bats-core)
- Install [bats-assert](https://github.com/ztombol/bats-assert)
- Install [bats-support](https://github.com/ztombol/bats-support)

After this, set the `BATS_LIB_PATH` environment variable to the directories
where the bats libraries are installed. For example:
To install these sub modules, run the following commands:

```bash
export BATS_LIB_PATH=/usr/lib:/usr/lib/bats
```
git submodule init
git submodule update
```

For more information, see the [bats-core documentation](https://bats-core.readthedocs.io/en/stable/)

To run the tests, cd to the root of the repository and run:
After this, you can use the `bats` executable in the root of the repository to
run the tests. To run all tests, run:

```bash
bats test
./bats test
```

where `bats` is the bats-core executable that should be in your path.
here, `./bats` is a shortcut to `./test/bats/bin/bats`.

For more information, see the [bats-core documentation](https://bats-core.readthedocs.io/en/stable/)

## Troubleshooting

Expand Down
5 changes: 5 additions & 0 deletions bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

# Shortcut to the bats executable at `./test/bats/bin/bats`
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
"$DIR"/test/bats/bin/bats $@
4 changes: 2 additions & 2 deletions test/cli-options.bats
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bats
# vim: ft=bash
bats_load_library bats-assert
bats_load_library bats-support
load test_helper/bats-assert/load
load test_helper/bats-support/load
load helpers.bash

@test "Run with -h" {
Expand Down
4 changes: 2 additions & 2 deletions test/fzf-select-option-preview.bats
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bats
# vim: ft=bash
bats_load_library bats-assert
bats_load_library bats-support
load test_helper/bats-assert/load
load test_helper/bats-support/load
load helpers.bash

@test "Run with -h" {
Expand Down
4 changes: 2 additions & 2 deletions test/fzf-select-option.bats
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bats
# vim: ft=bash
bats_load_library bats-assert
bats_load_library bats-support
load test_helper/bats-assert/load
load test_helper/bats-support/load
load helpers.bash

@test "Run with -h" {
Expand Down
4 changes: 2 additions & 2 deletions test/help-message.bats
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bats
# vim: ft=bash
bats_load_library bats-assert
bats_load_library bats-support
load test_helper/bats-assert/load
load test_helper/bats-support/load
load helpers.bash

get_temp() {
Expand Down

0 comments on commit d1ded2e

Please sign in to comment.