Skip to content

Commit a919e75

Browse files
committed
tests: Replace Bats submodule with a shallow clone
The theory is that this will work better when trying to compose projects using the framework and its plugins, since it won't be a web of submodules all the way down. By creating shallow clones on demand when the `./go` script for the framework, a plugin, or an application is executed, we may avoid creating circular dependencies and generally reduce the amount of bandwidth and disk space consumed by each build.
1 parent ceab5ea commit a919e75

File tree

5 files changed

+9
-20
lines changed

5 files changed

+9
-20
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
.*.swp
22
.DS_Store
3+
tests/bats/
34
tests/coverage/
45
tests/kcov/

.gitmodules

-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
[submodule "test/bats"]
2-
path = tests/bats
3-
url = https://github.com/sstephenson/bats
4-
shallow = true

scripts/test

+4-9
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,13 @@
2323
# This command script can serve as a template for your own project's test
2424
# script. Copy it into your project's script directory and customize as needed.
2525

26-
declare _GO_BATS_COVERAGE_INCLUDE
27-
_GO_BATS_COVERAGE_INCLUDE=('go' 'go-core.bash' 'lib/' 'libexec/' 'scripts/')
28-
declare _GO_COVERALLS_URL='https://coveralls.io/github/mbland/go-script-bash'
29-
3026
# Passes all arguments through to `@go.bats_main` from `lib/bats-main`.
3127
_test_main() {
32-
. "$_GO_USE_MODULES" 'bats-main'
33-
34-
if [[ ! -d "$_GO_BATS_DIR" ]]; then
35-
git submodule update --init "$_GO_BATS_DIR"
36-
fi
28+
local _GO_BATS_COVERAGE_INCLUDE
29+
_GO_BATS_COVERAGE_INCLUDE=('go' 'go-core.bash' 'lib/' 'libexec/' 'scripts/')
30+
local _GO_COVERALLS_URL='https://coveralls.io/github/mbland/go-script-bash'
3731

32+
. "$_GO_USE_MODULES" 'bats-main'
3833
# Tab completions
3934
@go.bats_main "$@"
4035
}

tests/bats

-1
This file was deleted.

tests/test.bats

+4-6
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,12 @@ _trim_expected() {
8888

8989
stub_program_in_path 'git' 'echo "GIT ARGV: $*"'
9090

91-
# This will fail because we didn't create the tests/ directory, but git should
92-
# have been called correctly.
91+
# Note that rather than running our own `./go` script, we're running
92+
# `TEST_GO_SCRIPT` instead. This will fail because we didn't create the tests/
93+
# directory, but `git` should have been called correctly.
9394
run "$TEST_GO_SCRIPT" test --list test
94-
95-
# Since `test` will try to clone the submodule, but the `git` stub doesn't
96-
# actually do anything, `@go.bats_main` will then call `@go.bats_clone`.
9795
assert_failure
98-
assert_lines_match '^GIT ARGV: submodule update --init tests/bats$' \
96+
assert_lines_match \
9997
"^GIT ARGV: clone .* -b $_GO_BATS_VERSION $_GO_BATS_URL $_GO_BATS_DIR\$" \
10098
"^Successfully cloned \"$_GO_BATS_URL\" .* \"$_GO_BATS_DIR\"" \
10199
'^Root directory argument tests is not a directory\.$'

0 commit comments

Comments
 (0)