-
Notifications
You must be signed in to change notification settings - Fork 17.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
proposal: x/tools/testfiles: provide utilities for testing tools for Go code with modules #68408
Comments
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
@earthboundkid Do you want to submit the CL you started for #44158? Or anything else I could do to help it get over the finish line? I think this would lead to a nice simplification to this proposal. |
I have been too busy to work on #44158 and I'm not sure what the best way to implement |
Change https://go.dev/cl/598996 mentions this issue: |
Use the new txtar.FS function to consolidate API around fs.FS. This has been simplified to two functions: ExtractTxtarFileToTmp, and CopyToTmp. CopyToTmp is a combination replacement for CopyFS and CopyDirToTmp. The main distinction is that it now takes an explicit renaming map instead of implicitly removing ".test" extensions. Updates golang/go#68408 Change-Id: I9558044ec4613835327c0b0a5e8d1cc8fe847d59 Reviewed-on: https://go-review.googlesource.com/c/tools/+/598996 Reviewed-by: Alan Donovan <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Auto-Submit: Tim King <[email protected]>
Updated the proposal with the new consolidated API. |
Updated July 30.
Proposal Details
The proposal is to move the existing internal
x/tools/internal/testfiles.CopyToTmp
function for testing Go code withgo.mod
files into a new exported packagex/tools/testfiles
. This function creates a temporary testing directory from anio/fs.FS
and then potentially renaming files.The potential renaming allows for populating the new directory with files names significant to Go, such as
go.mod
, without checking in files with special names. For example if we copy the directory testdata:using `dir := testfiles.CopyToTmp(t, os.DirFS("testdata"), "go.mod.test,go.mod"), the resulting files will be:
This package was originally created to support
x/tools/analysistest.Run
. From it's documentation:Adopting this proposal would resolve #37054, #46041, #53063, and #61336.
Note this proposal works well with both
testdata/
directories usingos.DirFS
, and txtar archives usingx/tools/txtar.FS
(#44158).The text was updated successfully, but these errors were encountered: