Skip to content
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

Merged
merged 4 commits into from May 24, 2023

Commits on May 24, 2023

  1. all: replace gopkg.in/check.v1 with shim

    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>
    lmb committed May 24, 2023
    Configuration menu
    Copy the full SHA
    17cc26c View commit details
    Browse the repository at this point in the history
  2. docs: explain how to migrate from gocheck

    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>
    lmb and zacharysarah committed May 24, 2023
    Configuration menu
    Copy the full SHA
    b7bdb53 View commit details
    Browse the repository at this point in the history
  3. golangci: prohibit use of gopkg.in/check.v1

    Configure golangci-lint so that we don't add new code which uses
    the deprecated package.
    
    Signed-off-by: Lorenz Bauer <lmb@isovalent.com>
    lmb committed May 24, 2023
    Configuration menu
    Copy the full SHA
    faec193 View commit details
    Browse the repository at this point in the history
  4. testutils: remove PrivilegedCheck

    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>
    lmb committed May 24, 2023
    Configuration menu
    Copy the full SHA
    9811317 View commit details
    Browse the repository at this point in the history