loov / goda

Go Dependency Analysis toolkit
MIT License
1.37k stars 45 forks source link

make it easier to select tests #51

Closed rogpeppe closed 3 years ago

rogpeppe commented 3 years ago

Currently to include test packages, you can use test=1(something) but that's awkward to type, not that easy to remember and requires shell quotes.

I find myself needing this qualifier a lot, because test code is a large part of any repository and a big part of refactoring calculations.

How about using a :test qualifier instead?

So, for example, ./...:test would include all the test code in ./....

./...:test:all would include all dependencies of all packages and tests below ..

egonelbre commented 3 years ago

There's a slight issue with including tests using a selector. In some sense the loading of packages happens before the selector is applied. https://github.com/loov/goda/blob/master/internal/pkgset/context.go#L64

There would also be a need to select "tests only" and packages with tests.

It certainly could be special-cased in terms of loading. i.e. if the expression contains :test then add the tests to the loading context.

Alternatively adding :test could "reload" the whole previous packages with tests included.

pkg:all:test -- load tests for all packages
pkg:test:all -- load all dependencies for `pkg` tests

But this makes it slightly awkward to load pkg+test.

Maybe the syntax needs to be extended to support something like pkg+:test?

egonelbre commented 3 years ago

Maybe the latter syntax example should be :<op><selector>, then you can write:

pkg:+test
pkg:-test

pkg:-source

pkg:+imp