Skip to content

Commit 2cdde96

Browse files
committed
use ginkgo cli to execute tests
1 parent 57b5145 commit 2cdde96

File tree

6 files changed

+178
-107
lines changed

6 files changed

+178
-107
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 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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module sigs.k8s.io/controller-runtime/hack/tools
33
go 1.16
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
89
)

0 commit comments

Comments
 (0)