-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add test module #55
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Copyright 2023 The cert-manager Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
shared_test_targets ?= | ||
go_test_targets ?= | ||
junitfile ?= |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright 2023 The cert-manager Authors. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
## Run golang tests | ||
## @category [shared] Test | ||
.PHONY: test-go | ||
test-go: | $(NEEDS_GOTESTSUM) | ||
$(if $(go_test_targets),$(GOTESTSUM) $(addprefix --junitfile=, $(junitfile)) -- $(go_test_targets)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this general enough to model tests like https://github.com/cert-manager/approver-policy/blob/main/make/test-smoke.mk#L58-L63 here? & is that what we are aiming for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Depends if we care much about the runner, I only used gotestsum because I saw cert-manager repo using it and it already existed as a tool. Happy to use ginkgo instead if thats easier. Of could use a flag to specify what runner you want then have a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The challenge is that unit tests sometimes use gotestsum and e2e tests use ginkgo or another combination of both. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could not define any go_test_targets and just add your own target to shared_test_targets. Then you could use whatever runner you like. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have given me an idea for an improvement though 🙂 |
||
|
||
shared_test_targets += test-go | ||
|
||
.PHONY: test | ||
## Run all test targets | ||
## @category [shared] Test | ||
test: $(shared_test_targets) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does "golang" mean in this context?
Generally we have unit and e2e tests using both ginkgo and gotestsum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was just thinking unit tests since e2e tests usually require extra setup so should setup their own target. I can reword the target to test-go-unit or something?