22
33load environment
44
5+ # By default, the test will try to clone its own repo to avoid flakiness due to
6+ # an external dependency. However, doing so causes a failure on Travis, since it
7+ # uses shallow clones to produce test runs, resulting in the error:
8+ #
9+ # fatal: attempt to fetch/clone from a shallow repository
10+ #
11+ # However, since Travis already depends on having a good connection to GitHub,
12+ # we'll use the real URL. Alternatively, `git` could be stubbed out via
13+ # `stub_program_in_path` from `_GO_CORE_DIR/lib/bats/helpers`, but the potential
14+ # for neither flakiness nor complexity seems that great, and this approach
15+ # provides extra confidence that the mechanism works as advertised.
16+ #
17+ # A developer can also run the test locally against the real URL by setting
18+ # `TEST_USE_REAL_URL` on the command line. The value of `GO_CORE_URL` is
19+ # subsequently displayed in the name of the test case to validate which repo is
20+ # being used during the test run.
21+ TEST_USE_REAL_URL=" ${TEST_USE_REAL_URL:- $TRAVIS } "
22+ GO_CORE_URL=" ${TEST_USE_REAL_URL: +$_GO_CORE_URL } "
23+ GO_CORE_URL=" ${GO_CORE_URL:- $_GO_CORE_DIR } "
24+
525setup () {
626 test_filter
727 mkdir " $TEST_GO_ROOTDIR "
28+
29+ if [[ -e " $GO_CORE_URL /.git/shallow" ]]; then
30+ skip " Can't clone shallow repositories"
31+ fi
832}
933
1034teardown () {
@@ -29,7 +53,7 @@ create_template_script() {
2953 chmod 700 " $TEST_GO_ROOTDIR /go-template"
3054}
3155
32- @test " $SUITE : clone the go-script-bash repository" {
56+ @test " $SUITE : clone the go-script-bash repository from $GO_CORE_URL " {
3357 create_template_script " $_GO_CORE_DIR " " $_GO_CORE_VERSION "
3458 run " $TEST_GO_ROOTDIR /go-template"
3559
0 commit comments