Skip to content

Commit ccc5b15

Browse files
committed
use ginkgo cli to execute tests
1 parent 27ecd22 commit ccc5b15

File tree

6 files changed

+232
-108
lines changed

6 files changed

+232
-108
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# Test binary, build with `go test -c`
99
*.test
10+
test-report.xml
1011

1112
# Output of the go coverage tool, specifically when used with LiteIDE
1213
*.out

Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ TOOLS_BIN_DIR := $(TOOLS_DIR)/bin
4040
GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/golangci-lint)
4141
GO_APIDIFF := $(TOOLS_BIN_DIR)/go-apidiff
4242
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/controller-gen
43+
GINKGO := $(TOOLS_BIN_DIR)/ginkgo
4344
ENVTEST_DIR := $(abspath tools/setup-envtest)
4445

4546
# The help will print out all targets with their descriptions organized bellow their categories. The categories are represented by `##@` and the target descriptions by `##`.
@@ -55,12 +56,12 @@ help: ## Display this help
5556
## --------------------------------------
5657

5758
.PHONY: test
58-
test: test-tools ## Run the script check-everything.sh which will check all.
59+
test: test-tools $(GINKGO) ## Run the script check-everything.sh which will check all.
5960
TRACE=1 ./hack/check-everything.sh
6061

6162
.PHONY: test-tools
62-
test-tools: ## tests the tools codebase (setup-envtest)
63-
cd tools/setup-envtest && go test ./...
63+
test-tools: $(GINKGO) ## tests the tools codebase (setup-envtest)
64+
$(GINKGO) tools/setup-envtest/...
6465

6566
## --------------------------------------
6667
## Binaries
@@ -72,6 +73,9 @@ $(GO_APIDIFF): $(TOOLS_DIR)/go.mod # Build go-apidiff from tools folder.
7273
$(CONTROLLER_GEN): $(TOOLS_DIR)/go.mod # Build controller-gen from tools folder.
7374
cd $(TOOLS_DIR) && go build -tags=tools -o bin/controller-gen sigs.k8s.io/controller-tools/cmd/controller-gen
7475

76+
$(GINKGO): $(TOOLS_DIR)/go.mod
77+
cd $(TOOLS_DIR) && go build -tags=tools -o bin/ginkgo github.com/onsi/ginkgo/v2/ginkgo
78+
7579
$(GOLANGCI_LINT): .github/workflows/golangci-lint.yml # Download golanci-lint using hack script into tools folder.
7680
hack/ensure-golangci-lint.sh \
7781
-b $(TOOLS_BIN_DIR) \

hack/test-all.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,17 @@
1616

1717
set -e
1818

19-
source $(dirname ${BASH_SOURCE})/common.sh
19+
hack_dir=$(dirname ${BASH_SOURCE})
20+
source ${hack_dir}/common.sh
2021

21-
header_text "running go test"
22+
(
23+
cd ${hack_dir}/tools
24+
go build -tags=tools -o bin/ginkgo github.com/onsi/ginkgo/v2/ginkgo
25+
)
2226

23-
go test -race ${P_FLAG} ${MOD_OPT} ./...
27+
header_text "running tests using ginkgo"
28+
29+
${hack_dir}/tools/bin/ginkgo --junit-report test-report.xml --keep-going --race -r ${P_FLAG} ${MOD_OPT}
2430

2531
if [[ -n ${ARTIFACTS:-} ]]; then
2632
if grep -Rin '<failure type="Failure">' ${ARTIFACTS}/*; then exit 1; fi

hack/tools/go.mod

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,60 @@
11
module sigs.k8s.io/controller-runtime/hack/tools
22

3-
go 1.16
3+
go 1.17
44

55
require (
6-
github.com/joelanford/go-apidiff v0.1.0
7-
sigs.k8s.io/controller-tools v0.7.0
6+
github.com/joelanford/go-apidiff v0.4.0
7+
github.com/onsi/ginkgo/v2 v2.1.4
8+
sigs.k8s.io/controller-tools v0.9.2
9+
)
10+
11+
require (
12+
github.com/Microsoft/go-winio v0.4.16 // indirect
13+
github.com/ProtonMail/go-crypto v0.0.0-20210428141323-04723f9f07d7 // indirect
14+
github.com/acomagu/bufpipe v1.0.3 // indirect
15+
github.com/emirpasic/gods v1.12.0 // indirect
16+
github.com/fatih/color v1.12.0 // indirect
17+
github.com/go-git/gcfg v1.5.0 // indirect
18+
github.com/go-git/go-billy/v5 v5.3.1 // indirect
19+
github.com/go-git/go-git/v5 v5.4.2 // indirect
20+
github.com/go-logr/logr v1.2.0 // indirect
21+
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 // indirect
22+
github.com/gobuffalo/flect v0.2.5 // indirect
23+
github.com/gogo/protobuf v1.3.2 // indirect
24+
github.com/google/gofuzz v1.1.0 // indirect
25+
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 // indirect
26+
github.com/imdario/mergo v0.3.12 // indirect
27+
github.com/inconshreveable/mousetrap v1.0.0 // indirect
28+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
29+
github.com/json-iterator/go v1.1.12 // indirect
30+
github.com/kevinburke/ssh_config v0.0.0-20201106050909-4977a11b4351 // indirect
31+
github.com/mattn/go-colorable v0.1.8 // indirect
32+
github.com/mattn/go-isatty v0.0.12 // indirect
33+
github.com/mitchellh/go-homedir v1.1.0 // indirect
34+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
35+
github.com/modern-go/reflect2 v1.0.2 // indirect
36+
github.com/sergi/go-diff v1.1.0 // indirect
37+
github.com/spf13/cobra v1.4.0 // indirect
38+
github.com/spf13/pflag v1.0.5 // indirect
39+
github.com/xanzy/ssh-agent v0.3.0 // indirect
40+
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
41+
golang.org/x/exp v0.0.0-20220328175248-053ad81199eb // indirect
42+
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
43+
golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect
44+
golang.org/x/sys v0.0.0-20220403020550-483a9cbc67c0 // indirect
45+
golang.org/x/text v0.3.7 // indirect
46+
golang.org/x/tools v0.1.10 // indirect
47+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
48+
gopkg.in/inf.v0 v0.9.1 // indirect
49+
gopkg.in/warnings.v0 v0.1.2 // indirect
50+
gopkg.in/yaml.v2 v2.4.0 // indirect
51+
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
52+
k8s.io/api v0.24.0 // indirect
53+
k8s.io/apiextensions-apiserver v0.24.0 // indirect
54+
k8s.io/apimachinery v0.24.0 // indirect
55+
k8s.io/klog/v2 v2.60.1 // indirect
56+
k8s.io/utils v0.0.0-20220210201930-3a6ce19ff2f9 // indirect
57+
sigs.k8s.io/json v0.0.0-20211208200746-9f7c6b3444d2 // indirect
58+
sigs.k8s.io/structured-merge-diff/v4 v4.2.1 // indirect
59+
sigs.k8s.io/yaml v1.3.0 // indirect
860
)

0 commit comments

Comments
 (0)