-
Notifications
You must be signed in to change notification settings - Fork 7
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
slim dependencies; add go.mod #5
base: master
Are you sure you want to change the base?
Conversation
People don't like large dependencies and Go modules includes test dependencies too, so it's nice to trim down a bit and be a little less opinonated in the API (making the loggo dependency optional if you wish to plug it in).
"github.com/juju/testing" | ||
jc "github.com/juju/testing/checkers" | ||
gc "gopkg.in/check.v1" | ||
qt "github.com/frankban/quicktest" |
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.
Unsure about adding another testing library into the Juju ecosystem..
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.
FWIW this library is very much general purpose, rather than Juju-specific, and quicktest was developed by a Canonicaler and is already in use by quite a few Canonical modules.
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.
+1 for quicktest, it's simpler than gocheck and actively maintained.
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 like it too, but we already have multiple testing approaches that are partially implemented. Would rather an addition like this was added after consensus has been reached in a thread to the Juju discource.
This slims down the dependencies considerably, which is appropriate for a low level package like retry. For the time being, we also use a fork of the juju/clock package that also uses quicktest until juju/clock#5 lands.
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.
LGTM
This slims down the dependencies considerably, which is appropriate for a low level package like retry. For the time being, we also use a fork of the juju/clock package that also uses quicktest until juju/clock#5 lands.
FYI: this will currently break when attempting to merge, as the CI expects a certain set of hooks to be in place. |
FWIW I've now forked this repository. I'll unfork if someone decides this PR might be a good idea. |
A few comments why the build was broken:
Those can probably be fixed in the test runner (from what I can tell, 'go mod' is designed that you don't do a 'get dependencies' step, go build just does it implicitly, which feels imprecise but we'll see) I'm happy with go mod support, we probably want to transition more things to that. I did a quick search and it seems most of our important dependencies do have support for it. I'm not particularly fond of going through yet another round getting used to another dependency tool, but as I'm not overly fond of 'dep' anyway, we can give it a shot. As to quicktest vs gocheck. The biggest thing is the loss of suite level setup/teardown, though functionally that can be "call SetUp at the start of every test function". (There is also TestMain(testing.M) support, though it does require rewriting all the stuff we currently do, and means that packages with multiple suites don't fit the pattern.) The pattern of quicktest Checkers also doesn't match gocheck. Checkers which means it will be incompatible with juju/testing/checkers. So actually converting a significant portion of the code base is a rather massive undertaking. Given that Clock is actually infrastructure for testing, but it, itself, doesn't depend on any testing infrastructure, it probably doesn't matter. We did discuss this briefly last week, but got side tracked with other scheduling discussions. I'll try to follow up on the discourse thread now that we're out of the sprint week. |
Two thoughts here:
I suspect it wouldn't be too bad. The usage of the checkers is the same, and it's not hard to make new checkers that behave the same as the old ones. For example, github.com/juju/qthttptest already contains equivalents to some of the testing/checkers checkers (e.g. JSONEquals). Once you've made new equivalent checkers, porting the code is just a matter of importing the checkers from a different package. I changed a bunch of modules from gocheck to quicktest and it was pretty painless.
One observation is that the conversion doesn't have to happen all at once; a code base can happily support both styles of test while migration is happening. For example, in Candid, I made one PR per converted package and it worked pretty well. Another is that the tests read pretty similarly with both packages, so there's not a big cognitive gap when jumping between the two, so supporting both styles for a while shouldn't end up as a huge burden. |
I'm going to garbage collect this and just continue to use my fork of this project soon. |
People don't like large dependencies and Go modules includes test
dependencies too, so it's nice to trim down a bit and be a little less
opinonated in the API (making the loggo dependency optional if
you wish to plug it in).
As an example, for a low level package that imports testclock
and uses quicktest, the resulting
go.mod
file currently looks like this:When updated to use the version of juju/clock that uses quicktest, it looks like this: