Skip to content

Commit bd63cf1

Browse files
committed
adding BATS core and supporting libraries
removing dependency for user to have to install BATS
1 parent 8d6dba5 commit bd63cf1

File tree

10 files changed

+40
-4
lines changed

10 files changed

+40
-4
lines changed

.gitmodules

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[submodule "test/e2e/bats/core"]
2+
path = test/e2e/bats/core
3+
url = https://github.com/bats-core/bats-core
4+
[submodule "test/e2e/bats/support"]
5+
path = test/e2e/bats/support
6+
url = https://github.com/bats-core/bats-support
7+
[submodule "test/e2e/bats/assert"]
8+
path = test/e2e/bats/assert
9+
url = https://github.com/bats-core/bats-assert
10+
[submodule "test/e2e/bats/file"]
11+
path = test/e2e/bats/file
12+
url = https://github.com/bats-core/bats-file

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ test: test-unit test-e2e
4949
test-unit:
5050
go test $(GO_FLAGS) $(GO_TEST_FLAGS) $(CMD) $(PKG) $(ARGS)
5151

52-
# runs all end-to-end tests using bats, it assumes bats is installed
52+
# looks for *.bats files in the test/e2e directory and runs them
5353
test-e2e:
54-
./test/e2e/e2e.bats
54+
./hack/run-e2e.sh
5555

5656
# wait for KinD cluster to be on ready state, so tests can be performed
5757
verify-kind:

docs/testing.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,22 @@ The install script waits for the Controller instance to be running.
5454
[BATS][batsCore] is a testing framework for Bash. It's structured as a regular script with enhanced
5555
syntax to define test cases, collect results, and more.
5656

57-
To run BATS based tests, make sure you have `bats` installed, and then execute:
57+
The BATS core tool and it's supporting libraries are linked in this project as `git submodules`,
58+
alleviating the need to install BATS yourself.
5859

60+
To run BATS based tests, make sure that you have cloned the project (including all submodules):
61+
62+
```sh
63+
Option 1.)
64+
$ git clone --recurse-submodules --depth 1 https://github.com/shipwright-io/cli.git
65+
66+
Option 2.) (if you did not clone using the above command)
67+
$ cd /your/project/directory/cli
68+
$ git submodule init
69+
$ git submodule update
70+
```
71+
72+
then run:
5973
```sh
6074
make test-e2e
6175
```

hack/run-e2e.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
for i in test/e2e/*.bats; do
4+
./test/e2e/bats/core/bin/bats ${i}
5+
done

test/e2e/bats/assert

Submodule assert added at 672ad18

test/e2e/bats/core

Submodule core added at 90a051b

test/e2e/bats/file

Submodule file added at 17fa557

test/e2e/bats/support

Submodule support added at d140a65

test/e2e/e2e.bats

100755100644
File mode changed.

test/e2e/helpers.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function shp () {
1717
${BIN} ${*}
1818
}
1919

20+
# generate a random string of no more than 16 characters
2021
function random_name () {
21-
LC_ALL=C tr -dc a-z </dev/urandom | head -c64
22+
LC_ALL=C tr -dc a-z </dev/urandom | head -c16
2223
}

0 commit comments

Comments
 (0)