@@ -138,42 +138,18 @@ function default_build_test_runner() {
138
138
[[ -z " ${go_pkg_dirs} " ]] && return ${failed}
139
139
# Ensure all the code builds
140
140
subheader " Checking that go code builds"
141
- local report
142
- report=" $( mktemp) "
143
- local errors_go1=" "
144
- local errors_go2=" "
145
- if ! capture_output " ${report} " go build -v ./... ; then
146
- failed=1
147
- # Consider an error message everything that's not a package name.
148
- errors_go1=" $( grep -v ' ^\(github\.com\|knative\.dev\)/' " ${report} " | sort | uniq) "
149
- fi
150
141
# Get all build tags in go code (ignore /vendor, /hack and /third_party)
151
142
local tags
152
- tags=" $( grep -r ' // +build' . \
153
- | grep -v ' ^./vendor/' | grep -v ' ^./hack/' | grep -v ' ^./third_party' \
154
- | cut -f3 -d' ' | tr ' ,' ' \n' | sort | uniq | tr ' \n' ' ' ) "
155
- local tagged_pkgs
156
- tagged_pkgs=" $( grep -r ' // +build' . \
157
- | grep -v ' ^./vendor/' | grep -v ' ^./hack/' | grep -v ' ^./third_party' \
158
- | grep " :// +build " | cut -f1 -d: | xargs dirname \
159
- | sort | uniq | tr ' \n' ' ' ) "
160
- for pkg in ${tagged_pkgs} ; do
161
- # `go test -c` lets us compile the tests but do not run them.
162
- if ! capture_output " ${report} " go test -c -tags=" ${tags} " " ${pkg} " ; then
163
- failed=1
164
- # Consider an error message everything that's not a successful test result.
165
- errors_go2+=" $( grep -v ' ^\(ok\|\?\)\s\+\(github\.com\|knative\.dev\)/' " ${report} " ) "
166
- fi
167
- # Remove unused generated binary, if any.
168
- rm -f e2e.test
169
- done
143
+ tags=" $( find . \
144
+ -path ' ./vendor' -prune -o -path ' ./hack' -prune -o -path ' ./third_party' -prune \
145
+ -o -type f -name ' *.go' -exec grep ' // +build' {} + \
146
+ | cut -f3 -d' ' | tr ' ,' ' \n' | uniq | sort | tr ' \n' ' ' ) "
147
+ report_build_test Build_Go \
148
+ go test -vet=off -tags " ${tags} " -exec echo ./... || failed=2
170
149
171
- local errors_go
172
- errors_go=" $( echo -e " ${errors_go1} \n${errors_go2} " | uniq) "
173
- create_junit_xml _build_tests Build_Go " ${errors_go} "
174
150
# Check that we don't have any forbidden licenses in our images.
175
151
subheader " Checking for forbidden licenses"
176
- report_build_test Check_Licenses check_licenses || failed=1
152
+ report_build_test Check_Licenses check_licenses || failed=3
177
153
return ${failed}
178
154
}
179
155
0 commit comments