Skip to content

Commit 91653df

Browse files
authored
cmd/testscript: add README.md that matches -help output. (#45)
1 parent abaa39a commit 91653df

File tree

1 file changed

+106
-0
lines changed

1 file changed

+106
-0
lines changed

cmd/testscript/README.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
```
2+
The testscript command runs github.com/rogpeppe/go-internal/testscript scripts
3+
in a fresh temporary work directory tree.
4+
5+
Usage:
6+
testscript [-v] files...
7+
8+
The testscript command is designed to make it easy to create self-contained
9+
reproductions of command sequences.
10+
11+
Each file is opened as a script and run as described in the documentation for
12+
github.com/rogpeppe/go-internal/testscript. The special filename "-" is
13+
interpreted as the standard input.
14+
15+
As a special case, supporting files/directories in the .gomodproxy subdirectory
16+
will be served via a github.com/rogpeppe/go-internal/goproxytest server which
17+
is available to each script via the GOPROXY environment variable. The contents
18+
of the .gomodproxy subdirectory are not available to the script except via the
19+
proxy server. See the documentation for
20+
github.com/rogpeppe/go-internal/goproxytest for details on the format of these
21+
files/directories.
22+
23+
Examples
24+
========
25+
26+
The following example, fruit.txt, shows a simple reproduction that includes
27+
.gomodproxy supporting files:
28+
29+
go get -m fruit.com
30+
go list fruit.com/...
31+
stdout 'fruit.com/fruit'
32+
33+
-- go.mod --
34+
module mod
35+
36+
-- .gomodproxy/fruit.com_v1.0.0/.mod --
37+
module fruit.com
38+
39+
-- .gomodproxy/fruit.com_v1.0.0/.info --
40+
{"Version":"v1.0.0","Time":"2018-10-22T18:45:39Z"}
41+
42+
-- .gomodproxy/fruit.com_v1.0.0/fruit/fruit.go --
43+
package fruit
44+
45+
const Name = "Apple"
46+
47+
Running testscript -v fruit.txt we get:
48+
49+
...
50+
> go get -m fruit.com
51+
[stderr]
52+
go: finding fruit.com v1.0.0
53+
54+
> go list fruit.com/...
55+
[stdout]
56+
fruit.com/fruit
57+
58+
[stderr]
59+
go: downloading fruit.com v1.0.0
60+
61+
> stdout 'fruit.com/fruit'
62+
PASS
63+
64+
65+
The following example, goimports.txt, shows a simple reproduction involving
66+
goimports:
67+
68+
go install golang.org/x/tools/cmd/goimports
69+
70+
# check goimports help information
71+
exec goimports -d main.go
72+
stdout 'import "math"'
73+
74+
-- go.mod --
75+
module mod
76+
77+
require golang.org/x/tools v0.0.0-20181221235234-d00ac6d27372
78+
79+
-- main.go --
80+
package mod
81+
82+
const Pi = math.Pi
83+
84+
Running testscript -v goimports.txt we get:
85+
86+
...
87+
> go install golang.org/x/tools/cmd/goimports
88+
[stderr]
89+
go: finding golang.org/x/tools v0.0.0-20181221235234-d00ac6d27372
90+
go: downloading golang.org/x/tools v0.0.0-20181221235234-d00ac6d27372
91+
92+
# check goimports help information (0.015s)
93+
> exec goimports -d main.go
94+
[stdout]
95+
diff -u main.go.orig main.go
96+
--- main.go.orig 2019-01-08 16:03:35.861907738 +0000
97+
+++ main.go 2019-01-08 16:03:35.861907738 +0000
98+
@@ -1,3 +1,5 @@
99+
package mod
100+
101+
+import "math"
102+
+
103+
const Pi = math.Pi
104+
> stdout 'import "math"'
105+
PASS
106+
```

0 commit comments

Comments
 (0)