You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since #15513, we can now do go test -c -o dir/ ./.... This works great and has a lot of use cases mentioned in the issue.
The issue, though, is this requires every package to have a unique name. This is not the case for most code bases, including Go itself (you can check with go list ./... | xargs -n1 basename | sort | uniq -d I believe).
It would be great to allow an alternate naming for the compiled tests. For example, instead of naming a file a/b/c/some_test.go as c.test, it could be named a_b_c.test or similar.
This would ensure the new mode works for all codebases.
This could be a new flag, or it could be the default when using -c with multiple files. However, the latter is probably a breaking change unless its included in 1.21 which may be too late.
The text was updated successfully, but these errors were encountered:
seankhliao
changed the title
cmd/go: support naming compiled tests with full qualified name
proposal: cmd/go: support naming compiled tests with full qualified name
Jul 6, 2023
This can still cause a collision if I have a package named a/b and a package named a_b (unusual but not impossible).
Another option is to preserve the directory structure, so we'd end up with for example a/b/c.test. (I'd love if that were a thing for go build since you can also get collisions there.)
There is a tradeoff between ergonomics and API complexity: you always have the fallback of running go test -c on the packages individually, although getting the concurrency right could be a little tricky.
Since #15513, we can now do
go test -c -o dir/ ./...
. This works great and has a lot of use cases mentioned in the issue.The issue, though, is this requires every package to have a unique name. This is not the case for most code bases, including Go itself (you can check with
go list ./... | xargs -n1 basename | sort | uniq -d
I believe).It would be great to allow an alternate naming for the compiled tests. For example, instead of naming a file
a/b/c/some_test.go
asc.test
, it could be nameda_b_c.test
or similar.This would ensure the new mode works for all codebases.
This could be a new flag, or it could be the default when using
-c
with multiple files. However, the latter is probably a breaking change unless its included in 1.21 which may be too late.The text was updated successfully, but these errors were encountered: