Skip to content
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

cmd/go: extract TestScript functionality to internal/script #29288

Open
minux opened this issue Dec 15, 2018 · 5 comments

Comments

@minux
Copy link
Member

@minux minux commented Dec 15, 2018

While writing a test for #29253, it is apparent that using the existing cmd/go script test framework makes the test writing easy and straightforward. However, I don't like the fact that a test for cmd/link has to be placed in cmd/go/testdata/script.

I think the underlying concept of the script is very useful and enables us to write very simple single file test cases for even the most complicated scenarios.

I'd like to suggest that we move its functionality to internal/script (and txtar) and also make it client extendable so that it's possible for all cmd/* packages to use it (perhaps we can even unify the $GOROOT/test/run.go with it?)

Also, I'd like to make it possible to run single text archive go test cases with something like:

   go test internal/script bug.txt

Perhaps we could even make a go report-bug command to automate the packaging of such test cases? (Then we don't need to create a repo just to show a Go bug, and I think a lot of other products support a way to bundle a test case into a single file, the text archive is quite useful in this context.)

Thoughts?

@minux minux added the Proposal label Dec 15, 2018
@minux minux added this to the Proposal milestone Dec 15, 2018
@bcmills

This comment has been minimized.

Copy link
Member

@bcmills bcmills commented Dec 17, 2018

@rogpeppe

This comment has been minimized.

Copy link
Contributor

@rogpeppe rogpeppe commented Dec 17, 2018

FWIW I have extracted much of the script_test.go functionality into this package. Feel free to bring some or all of it back within the Go repository. It's missing some of the pieces that I considered were go-command-specific (particularly the bits that were about compiling Go programs, which added a reasonable amount of complexity). It should be extensible enough to add that functionality back in though.

@rsc

This comment has been minimized.

Copy link
Contributor

@rsc rsc commented Dec 19, 2018

This seems OK to try in Go 1.13 provided it stays as internal/script and we don't just grow an enormous number of "commands" in the scripting language. I don't want to commit to an API for external use. I'm also worried about, for example, the "go" command in the cmd/go tests. It doesn't make sense in a general internal/script test. What commands move? What commands stay? It's unclear to me how well this will generalize. But feel free to make a concrete proposal.

@rogpeppe

This comment has been minimized.

Copy link
Contributor

@rogpeppe rogpeppe commented Dec 20, 2018

FWIW, that's the reason I removed the "go" command from my factored out version and made the set of commands extensible. I tried to keep the set of commands limited to those that were generally applicable.

@andybons

This comment has been minimized.

Copy link
Member

@andybons andybons commented Mar 27, 2019

Per @golang/proposal-review, accepted for 1.13.

@andybons andybons changed the title proposal: extract cmd/go TestScript functionality to internal/script? cmd/go: extract TestScript functionality to internal/script? Mar 27, 2019
@andybons andybons changed the title cmd/go: extract TestScript functionality to internal/script? cmd/go: extract TestScript functionality to internal/script Mar 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.