Is it possible to skip directories from testing. For example given the structure below is it possible to test mypackage, mypackage/other and mypackage/net but not mypackage/
Go test takes a list of packages to test on the command line (see go help packages
) so you can test an arbitrary set of packages with a single invocation like so:
go test import/path/to/mypackage import/path/to/mypackage/other import/path/to/mypackage/net
Or, depending on your shell:
go test import/path/to/mypackage{,/other,/net}
You might be able to use interesting invocations of go list
as the arguments (again, depending on your shell):
go test `go list`
Your comment says you want to skip one sub-directory so (depending on your shell) perhaps this:
go test `go list ./... | grep -v directoriesToSkip`
as with anything, if you do that a lot you could make a shell alias/whatever for it.
If the reason you want to skip tests is, for example, that you have long/expensive tests that you often want to skip, than the tests themselves could/should check testing.Short() and call t.Skip() as appropriate.
Then you could run either:
go test -short import/path/to/mypackage/...
or from within the mypackage
directory:
go test -short ./...
You can use things other testing.Short()
to trigger skipping as well.