@@ -21,6 +21,10 @@ set -o pipefail
21
21
KUBE_ROOT=$( dirname " ${BASH_SOURCE[0]} " ) /../..
22
22
source " ${KUBE_ROOT} /hack/lib/init.sh"
23
23
24
+ kube::golang::setup_env
25
+ kube::golang::setup_gomaxprocs
26
+ kube::util::require-jq
27
+
24
28
# start the cache mutation detector by default so that cache mutators will be found
25
29
KUBE_CACHE_MUTATION_DETECTOR=" ${KUBE_CACHE_MUTATION_DETECTOR:- true} "
26
30
export KUBE_CACHE_MUTATION_DETECTOR
@@ -43,16 +47,23 @@ KUBE_TEST_ARGS=${KUBE_TEST_ARGS:-}
43
47
# Default glog module settings.
44
48
KUBE_TEST_VMODULE=${KUBE_TEST_VMODULE:- " " }
45
49
46
- kube::test::find_integration_test_dirs () {
50
+ kube::test::find_integration_test_pkgs () {
47
51
(
48
52
cd " ${KUBE_ROOT} "
49
- # The "./" syntax here produces Go-compatible package names.
50
- find ./test/integration/ -name ' *_test.go' -print0 \
51
- | xargs -0n1 dirname \
52
- | LC_ALL=C sort -u
53
- find ./staging/src/k8s.io/apiextensions-apiserver/test/integration/ -name ' *_test.go' -print0 \
54
- | xargs -0n1 dirname \
55
- | LC_ALL=C sort -u
53
+
54
+ # Get a list of all the modules in this workspace.
55
+ local -a workspace_module_patterns
56
+ kube::util::read-array workspace_module_patterns < <(
57
+ go list -m -json | jq -r ' .Dir' \
58
+ | while read -r D; do
59
+ SUB=" ${D} /test/integration" ;
60
+ test -d " ${SUB} " && echo " ${SUB} /..." ;
61
+ done)
62
+
63
+ # Get a list of all packages which have test files.
64
+ go list -find \
65
+ -f ' {{if or (gt (len .TestGoFiles) 0) (gt (len .XTestGoFiles) 0)}}{{.ImportPath}}{{end}}' \
66
+ " ${workspace_module_patterns[@]} "
56
67
)
57
68
}
58
69
@@ -81,7 +92,7 @@ runTests() {
81
92
# empty here to ensure that we aren't unintentionally consuming them from the
82
93
# previous make invocation.
83
94
KUBE_TEST_ARGS=" ${SHORT:- -short=true} --vmodule=${KUBE_TEST_VMODULE} ${KUBE_TEST_ARGS} " \
84
- WHAT=" ${WHAT:- $(kube:: test:: find_integration_test_dirs | paste -sd' ' -)} " \
95
+ WHAT=" ${WHAT:- $(kube:: test:: find_integration_test_pkgs | paste -sd' ' -)} " \
85
96
GOFLAGS=" ${GOFLAGS:- } " \
86
97
KUBE_TIMEOUT=" ${KUBE_TIMEOUT} " \
87
98
KUBE_RACE=" " \
0 commit comments