File tree Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Expand file tree Collapse file tree 3 files changed +27
-5
lines changed Original file line number Diff line number Diff line change @@ -22,5 +22,8 @@ cmd/clusterctl/examples/ibmcloud/provider-component/user-data/ubuntu/worker-user
22
22
# test coverage out
23
23
cover.out
24
24
25
+ # JUnit test output from ginkgo unit tests
26
+ junit * .xml
27
+
25
28
# dep ensured 3rd code
26
29
vendor /sigs.k8s.io /cluster-api /docs /book /* .json
Original file line number Diff line number Diff line change @@ -21,13 +21,13 @@ import (
21
21
"testing"
22
22
23
23
. "github.com/onsi/ginkgo"
24
+ "github.com/onsi/ginkgo/reporters"
24
25
. "github.com/onsi/gomega"
25
26
"k8s.io/client-go/kubernetes/scheme"
26
27
"k8s.io/client-go/rest"
27
28
clusterv1 "sigs.k8s.io/cluster-api/api/v1alpha4"
28
29
"sigs.k8s.io/controller-runtime/pkg/client"
29
30
"sigs.k8s.io/controller-runtime/pkg/envtest"
30
- "sigs.k8s.io/controller-runtime/pkg/envtest/printer"
31
31
32
32
infrastructurev1alpha4 "github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/api/v1alpha4"
33
33
// +kubebuilder:scaffold:imports
@@ -42,10 +42,8 @@ var testEnv *envtest.Environment
42
42
43
43
func TestAPIs (t * testing.T ) {
44
44
RegisterFailHandler (Fail )
45
-
46
- RunSpecsWithDefaultAndCustomReporters (t ,
47
- "Controller Suite" ,
48
- []Reporter {printer.NewlineReporter {}})
45
+ junitReporter := reporters .NewJUnitReporter ("junit-controller.xml" )
46
+ RunSpecsWithDefaultAndCustomReporters (t , "Controller Suite" , []Reporter {junitReporter })
49
47
}
50
48
51
49
var _ = BeforeSuite (func (done Done ) {
Original file line number Diff line number Diff line change @@ -22,8 +22,29 @@ REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/..
22
22
# shellcheck source=../hack/ensure-go.sh
23
23
source " ${REPO_ROOT} /hack/ensure-go.sh"
24
24
25
+ # Directory to store JUnit XML test report.
26
+ JUNIT_REPORT_DIR=${JUNIT_REPORT_DIR:- }
27
+
28
+ # If JUNIT_REPORT_DIR is unset, and ARTIFACTS is set, then have them match.
29
+ if [[ -z " ${JUNIT_REPORT_DIR:- } " && -n " ${ARTIFACTS:- } " ]]; then
30
+ JUNIT_REPORT_DIR=" ${ARTIFACTS} "
31
+ fi
32
+
33
+ # Add Junit test reports to ARTIFACTS directory.
34
+ function addJunitFiles(){
35
+ declare -a junitFileList
36
+ readarray -t junitFileList <<< " $(find " ${REPO_ROOT} " -name 'junit-*.xml')"
37
+
38
+ for i in " ${junitFileList[@]} "
39
+ do
40
+ mv " ${i} " " ${ARTIFACTS} "
41
+ done
42
+ }
43
+
25
44
cd " ${REPO_ROOT} " && \
26
45
source ./scripts/fetch_ext_bins.sh && \
27
46
fetch_tools && \
28
47
setup_envs && \
29
48
make generate lint test
49
+
50
+ addJunitFiles
You can’t perform that action at this time.
0 commit comments