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
all: make it easier to migrate off of gopkg.in/check.v1 #25484
Conversation
/test |
8c1f19b
to
d77f3cf
Compare
/test |
/test |
/test |
1 similar comment
/test |
/test |
e7c9042
to
7c3ac8a
Compare
/test |
a63a6bb
to
5b53733
Compare
/test |
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.
Thanks!
811261a
to
096315f
Compare
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.
This is a really good change - Azure LGTM
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.
🧹
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.
@lmb 👋🏻 Some style nits, otherwise docs LGTM. Approving with the understanding that changes must be made prior to merge.
/test |
There are a lot of tests in the codebase which use gopkg.in/check.v1, which hasn't seen an update in the last three years. A while back it was decided that we'd migrate away from the package and instead use plain old stdlib testing. In practice things aren't so simple. We have so many tests that migrating them in one fell swoop is impossible. At the same time, the API exposed by check is entirely incompatible with testing. It's not possible to write a helper function which works for both check and testing. So far we've opted to provide two separate helpers, for example PrivilegedTest and PrivilegedCheck. This causes a lot of duplication and discourages sharing helpers. It also makes refactoring code from check to testing harder since the natural way to express the SetUp and TearDown behaviour of check is such a helper function. Additionally, check is a burden on anyone trying to run the tests: it has completely separate flags which control what tests are being run. The output also doesn't match what other go tooling expects, both for tests and benchmarks. To fix both of these, replace gopkg.in/check.v1 with a fork that removes most command line flags and gets rid of the custom runner. Instead, suites and tests are run as subtests. The other API should be mostly compatible. Most importantly check.C now embeds testing.T. As a result, check.C satisfies testing.TB, which allows us to access helpers written for the testing package from within unmigrated tests. Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Remove outdated documentation relating to gocheck and explain how existing tests can be translated from gocheck to testing. Co-authored-by: ZSC <zacharysarah@users.noreply.github.com> Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Configure golangci-lint so that we don't add new code which uses the deprecated package. Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
Now that check.C embeds testing.T we don't need separate testutils anymore. This shows how we can introduce helpers that are available from both testing and check style tests. Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
/test Job 'Cilium-PR-K8s-1.26-kernel-net-next' failed: Click to show.Test Name
Failure Output
Jenkins URL: https://jenkins.cilium.io/job/Cilium-PR-K8s-1.26-kernel-net-next/145/ If it is a flake and a GitHub issue doesn't already exist to track it, comment Then please upload the Jenkins artifacts to that issue. |
As per the discussion in the maintainers / community channel, tagging this ready to merge. |
Merge after the community meeting on 2023-05-24. Since this PR touches a lot of files it won't require all CODEOWNERs to sign off before merging. Feel free to provide feedback if you've been tagged for review, but it's not a requirement.
testutils: remove PrivilegedCheck
docs: explain how to migrate from gocheck
golangci: prohibit use of gopkg.in/check.v1
all: replace gopkg.in/check.v1 with shim