This isn't as complete as the go test
command, mostly because go test
"magically" recompiles the package under test. The closest
you can get to go test
-like functionality is via duplication, as mentioned in the docs. It might be nice to make this easier via
param or different test rule (go_internal_test
) that just does the src/dep copying for you. We may be able to make this even more
amazing via some sort of auto-discovery (we can easily tell if the test is external or internal at test main generation time) and
create two different libs. But I digress; this is a v1.
This also fixes support for custom package names (was previously somewhat broken).
The slightly more controversial feature here is the test main generator. Particularly, the source (in go) is a) mostly ripped from https://github.com/golang/go/blob/master/src/cmd/go/test.go & b) checked in as the source. In order to actually use it at run-time, it creates a "fake" test target //__internal_buck:go_test_main_gen. This is mostly to allow you to build buck without having go installed. I'm not sure of a better way to do this, so any ideas are appreciated.
Tested via the integration tests - they work :)