Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
123 lines (89 sloc) 3.07 KB
package main
import (
func mainUsage(f io.Writer) {
fmt.Fprint(f, mainHelp)
var mainHelp = `
The testscript command runs scripts
in a fresh temporary work directory tree.
testscript [-v] [-e VAR]... files...
The testscript command is designed to make it easy to create self-contained
reproductions of command sequences.
Each file is opened as a script and run as described in the documentation for The special filename "-" is
interpreted as the standard input.
As a special case, supporting files/directories in the .gomodproxy subdirectory
will be served via a server which
is available to each script via the GOPROXY environment variable. The contents
of the .gomodproxy subdirectory are not available to the script except via the
proxy server. See the documentation for for details on the format of these
Environment variables can be passed through to each script with the -e flag,
where VAR is the name of the variable. Variables override testscript-defined
values, with the exception of WORK which cannot be overridden. The -e flag can
appear multiple times to specify multiple variables.
The following example, fruit.txt, shows a simple reproduction that includes
.gomodproxy supporting files:
go get -m
go list
stdout ''
-- go.mod --
module mod
-- .gomodproxy/fruit.com_v1.0.0/.mod --
-- .gomodproxy/fruit.com_v1.0.0/.info --
-- .gomodproxy/fruit.com_v1.0.0/fruit/fruit.go --
package fruit
const Name = "Apple"
Running testscript -v fruit.txt we get:
> go get -m
go: finding v1.0.0
> go list
go: downloading v1.0.0
> stdout ''
The following example, goimports.txt, shows a simple reproduction involving
go install
# check goimports help information
exec goimports -d main.go
stdout 'import "math"'
-- go.mod --
module mod
require v0.0.0-20181221235234-d00ac6d27372
-- main.go --
package mod
const Pi = math.Pi
Running testscript -v goimports.txt we get:
> go install
go: finding v0.0.0-20181221235234-d00ac6d27372
go: downloading v0.0.0-20181221235234-d00ac6d27372
# check goimports help information (0.015s)
> exec goimports -d main.go
diff -u main.go.orig main.go
--- main.go.orig 2019-01-08 16:03:35.861907738 +0000
+++ main.go 2019-01-08 16:03:35.861907738 +0000
@@ -1,3 +1,5 @@
package mod
+import "math"
const Pi = math.Pi
> stdout 'import "math"'
You can’t perform that action at this time.