quicktest icon indicating copy to clipboard operation
quicktest copied to clipboard

cmd/qtify

Open josharian opened this issue 4 years ago • 6 comments

I’d love a source code rewriter that ports existing tests to quicktest. Could start with just the low-hanging fruit, the obvious cases. Bonus for also rewriting from testify. :)

With appropriate docs or a flag, it could even do slightly-semantic-changing things like err != nil to qt.IsNonNil.

josharian avatar May 01 '21 22:05 josharian

Yes, I've been wanting to do this for ages!

rogpeppe avatar May 04 '21 15:05 rogpeppe

I'd start with the testify rewrite because I think that's easier and because I'd like it to be easy to suggest that people migrate, and it's more of a clear win.

rogpeppe avatar May 04 '21 15:05 rogpeppe

bikeshedding on the name: qtfix ? gofixqt ? (I quite like including "go" in Go-oriented commands FWIW).

rogpeppe avatar May 04 '21 15:05 rogpeppe

(Disclaimer: I am the author of gotest.tools/v3/assert)

In case anyone is interested in a tool that does exactly this for a different assertion library gty-migrate-from-testify does this translation for gotest.tools/v3/assert.

It will rewrite all the common assertions directly, and print a line to stdout for any less-common assertion that could not be translated (which is generally a small number in my experience running the tool on large code bases).

As I mentioned in https://github.com/frankban/quicktest/issues/94#issuecomment-832114597, there are many similarities with these two libraries.

dnephin avatar May 04 '21 17:05 dnephin

@dnephin very interesting, thanks for pointing us to that!

frankban avatar May 05 '21 12:05 frankban

Damn, this would have saved me at least ten hours of work over the last year :) Happy to help test one such tool.

mvdan avatar Jan 17 '22 15:01 mvdan