-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: relocate script test framework from cmd/go to cmd/internal #68606
Comments
Related Issues and Documentation
(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.) |
When seeing "script", I thought it's the Either way, it would be a great improvement. |
Yes, the intent is to support txtar-style tests, such as this one in cmd/go: |
Change https://go.dev/cl/601357 mentions this issue: |
Change https://go.dev/cl/601358 mentions this issue: |
Change https://go.dev/cl/601356 mentions this issue: |
Change https://go.dev/cl/601359 mentions this issue: |
Change https://go.dev/cl/601361 mentions this issue: |
Change https://go.dev/cl/601355 mentions this issue: |
Change https://go.dev/cl/601360 mentions this issue: |
Relocate cmd/go's internal/par package up a level into cmd/internal/par, so that it can be used by other cmd/internal packages. No change in functionality. This change is intended to be in support of making the cmd/go script test framework available to other commands in addition to just the Go command. Updates #68606. Change-Id: I920a5d5c9b362584fabdbb2305414325b42856a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/601355 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
Relocate cmd/go's internal/robustio package up a level into cmd/internal/robustio, so that it can be used by other cmd/internal packages. No change in functionality. This change is intended to be in support of making the cmd/go script test framework available to other commands in addition to just the Go command. Updates #68606. Change-Id: Ic8421ef59d9b7d79a50c3679d180cfa2546c4cd3 Reviewed-on: https://go-review.googlesource.com/c/go/+/601356 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Michael Matloob <[email protected]>
Common up the the "known OS/Arch" tables from { cmd/go/internal/imports, cmd/go/internal/modindex, go/build } and relocate them to a new package, internal/syslist. No change in functionality. Updates #68606. Change-Id: I6414a05c96b8fddbdbd9678d322cb49d9b1b0af3 Reviewed-on: https://go-review.googlesource.com/c/go/+/601357 Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Michael Matloob <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Relocate cmd/go's internal/script package up a level into cmd/internal/script, so as to enable the use of script tests in other cmd packages. No change in functionality. Updates #68606. Change-Id: I3974b0bf59c76e0f459184c9f3090d6077dd5d91 Reviewed-on: https://go-review.googlesource.com/c/go/+/601358 Reviewed-by: Michael Matloob <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Add top level apis to provide a general-purpose "script test" runner for clients within cmd, e.g. tools such as compile, link, nm, and so on. This patch doesn't add any uses of the new apis, this will happen in follow-on CLs. Updates #68606. Change-Id: Ib7200a75d4dc7dc50897628f1a6269937be15a76 Reviewed-on: https://go-review.googlesource.com/c/go/+/601359 Reviewed-by: David Chase <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
Add support for running script tests as part of the linker's suite of tests, hooking in the script test engine packages recently moved from cmd/go to cmd/internal. Linker script tests will use the test binary itself as the linker for Go builds, and can also run the C compiler if needed. New script test cases (*.txt files) should be added to the directory cmd/link/testdata/script. For demo purposes, this patch also adds a new "randlayout_option.txt" script test that replicates the existing linker's TestRandLayout testpoint in script form. Updates #68606. Change-Id: Icf26bf657850e39548d6ea819f2542fc68a3899b Reviewed-on: https://go-review.googlesource.com/c/go/+/601360 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: David Chase <[email protected]>
Add support for running script tests as part of the compiler's suite of tests, hooking in the script test engine packages recently moved from cmd/go to cmd/internal. These script tests will use the test binary itself as the compile tool for Go builds, and can also run the C compiler if needed. New script test cases (*.txt files) should be added to the directory cmd/compile/testdata/script. Updates #68606. Change-Id: I9b056a07024b0a72320a89ad734e4b4a51f1c10c Reviewed-on: https://go-review.googlesource.com/c/go/+/601361 Reviewed-by: Cherry Mui <[email protected]> Reviewed-by: David Chase <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Change https://go.dev/cl/601715 mentions this issue: |
Change https://go.dev/cl/601756 mentions this issue: |
Introduce a new function AddToolChainScriptConditions that augments a default "script.Cond" set with a collection of useful conditions, including godebug/goexperiment, cgo, race support, buildmode, asan, msan, and so on. Having these conditions available makes it easier to write script tests that deal with specific build-flavor corner cases. The functions backing the new conditions are helper functions migrated over from the Go command's script test setup. Updates #68606. Change-Id: I14def1115b54dc47529c983abcd2c5ea9326b9de Reviewed-on: https://go-review.googlesource.com/c/go/+/601715 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Cherry Mui <[email protected]>
Add in automatic README generation and README consistency checking for the cmd/compile and cmd/link script tests. This code is adapted from the similar facility in cmd/go (e.g. scriptreadme_test.go); the README helps folks writing new tests understand the mechanics. Updates #68606. Change-Id: I8ff7ff8e814abd4385bd670440511b2c60a4cef6 Reviewed-on: https://go-review.googlesource.com/c/go/+/601756 Reviewed-by: Cherry Mui <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]>
Closing out this issue, the new framework is running + functional. Happy script test writing... |
The Go command has a very nice "script" testing framework that makes it easy to write regression tests that involve smallish multifile test cases and sequences of "go" command invocations. Other tools (compiler, linker, etc) would benefit from a similar facility. The convention for the compiler has been to add new test cases in $GOROOT/test, which then run by the harness in cmd/internal/testdir, howewer the harness code there has a lot of peculiarities: except for the simplest cases (e.g. compiler crash when run on a single file) it is difficult for test writers to pick out the correct flavor of test (rundir, runindir, compiledir, etc) to get the behavior they want.
To make it easier and simpler to code up more complicated test cases, I propose to relocate the cmd/go script test framework from cmd/go to cmd/internal, then make it available in some form for testing our various tools (compile, link, nm, etc). This is a tracking issue to record the progress on this effort.
The text was updated successfully, but these errors were encountered: