File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change 1616package testutil
1717
1818import (
19+ "flag"
20+ "log"
1921 "net/url"
2022 "os"
2123 "runtime"
@@ -100,10 +102,13 @@ func SkipTestIfShortMode(t TB, reason string) {
100102// ExitInShortMode closes the current process (with 0) if the short test mode detected.
101103//
102104// To be used in Test-main, where test context (testing.TB) is not available.
103- //
104- // Requires custom env-variable (GOLANG_TEST_SHORT) apart of `go test --short flag`.
105105func ExitInShortMode (reason string ) {
106- if os .Getenv ("GOLANG_TEST_SHORT" ) == "true" {
106+ // Calling testing.Short() requires flags to be parsed before.
107+ if ! flag .Parsed () {
108+ flag .Parse ()
109+ }
110+ if testing .Short () {
111+ log .Println (reason )
107112 os .Exit (0 )
108113 }
109114}
Original file line number Diff line number Diff line change @@ -130,7 +130,7 @@ function run_unit_tests {
130130 local pkgs=" ${1:- ./ ...} "
131131 shift 1
132132 # shellcheck disable=SC2068 #For context see - https://github.com/etcd-io/etcd/pull/16433#issuecomment-1684312755
133- GOLANG_TEST_SHORT=true go_test " ${pkgs} " " parallel" : -short -timeout=" ${TIMEOUT:- 3m} " ${COMMON_TEST_FLAGS[@]:- } ${RUN_ARG[@]:- } " $@ "
133+ go_test " ${pkgs} " " parallel" : -short -timeout=" ${TIMEOUT:- 3m} " ${COMMON_TEST_FLAGS[@]:- } ${RUN_ARG[@]:- } " $@ "
134134}
135135
136136function unit_pass {
@@ -309,7 +309,7 @@ function cov_pass {
309309
310310 log_callout " [$( date) ] Collecting coverage from unit tests ..."
311311 for m in $( module_dirs) ; do
312- GOLANG_TEST_SHORT=true run_for_module " ${m} " go_test " ./..." " parallel" " pkg_to_coverprofileflag unit_${m} " -short -timeout=30m \
312+ run_for_module " ${m} " go_test " ./..." " parallel" " pkg_to_coverprofileflag unit_${m} " -short -timeout=30m \
313313 " ${gocov_build_flags[@]} " " $@ " || failed=" $failed unit"
314314 done
315315
You can’t perform that action at this time.
0 commit comments