描述
Currently we have a GO_TEST_FUNC_ARGS variable which is passed directly to go test. With that we can do something like make check GO_TEST_FUNC_ARGS='-run "TestAuth.*"' to run only TestAuth{Sanity,Basic,Oauth,Override,Ignore} tests.
But it is a hassle to run all tests but TestFetch for example. An idea would be to maybe deprecate the GO_TEST_FUNC_ARGS in favor of GO_TEST_RUN_REGEXP and GO_TEST_DONT_RUN_REGEXP.
To run only TestAuth tests the invocation would be make check GO_TEST_RUN_REGEXP='TestAuth.*'.
To run all the tests but TestFetch: make check GO_TEST_DONT_RUN_REGEXP='TestFetch'.
To run all the auth test but override: make check GO_TEST_RUN_REGEXP='TestAuth.*' GO_TEST_DONT_RUN_REGEXP='TestAuthOverride' (or '.*Override').
Some other (probably bit crazy) notes:
- I couldn't find any builtin command to list all the tests that would be executed, so a hacky way to get the list would be:
git grep -P 'func Test\w+\(\w+\s+\*testing\.T\)' tests | grep -o '\bTest[[:alnum:]]\+' | sort -u
- run
grep '$(GO_TEST_RUN_REGEXP)'on that list to get a whitelist - run `grep -v '$(GO_TEST_DONT_RUN_REGEXP)' on that whitelist to get a final list of tests to run
- prepare the final list to something like (test1)|(test2)|...|(testN)
- We could then run `go test -run '$(prepared_final_list)' github.com/coreos/rkt/tests