File tree Expand file tree Collapse file tree 3 files changed +35
-6
lines changed Expand file tree Collapse file tree 3 files changed +35
-6
lines changed Original file line number Diff line number Diff line change @@ -161,16 +161,33 @@ func (ts *TestScript) cmdCp(neg bool, args []string) {
161161 }
162162
163163 for _ , arg := range args [:len (args )- 1 ] {
164- src := ts .MkAbs (arg )
165- info , err := os .Stat (src )
166- ts .Check (err )
167- data , err := ioutil .ReadFile (src )
168- ts .Check (err )
164+ var (
165+ src string
166+ data []byte
167+ mode os.FileMode
168+ )
169+ switch arg {
170+ case "stdout" :
171+ src = arg
172+ data = []byte (ts .stdout )
173+ mode = 0666
174+ case "stderr" :
175+ src = arg
176+ data = []byte (ts .stderr )
177+ mode = 0666
178+ default :
179+ src = ts .MkAbs (arg )
180+ info , err := os .Stat (src )
181+ ts .Check (err )
182+ mode = info .Mode () & 0777
183+ data , err = ioutil .ReadFile (src )
184+ ts .Check (err )
185+ }
169186 targ := dst
170187 if dstDir {
171188 targ = filepath .Join (dst , filepath .Base (src ))
172189 }
173- ts .Check (ioutil .WriteFile (targ , data , info . Mode () & 0777 ))
190+ ts .Check (ioutil .WriteFile (targ , data , mode ))
174191 }
175192}
176193
Original file line number Diff line number Diff line change @@ -133,6 +133,8 @@ The predefined commands are:
133133
134134- cp src... dst
135135 Copy the listed files to the target file or existing directory.
136+ src can include "stdout" or "stderr" to use the standard output or standard error
137+ from the most recent exec or go command.
136138
137139- env [key=value...]
138140 With no arguments, print the environment (useful for debugging).
Original file line number Diff line number Diff line change 1+ [!exec:cat] stop
2+
3+ # hello world
4+ exec cat hello.text
5+ cp stdout got
6+ cmp got hello.text
7+
8+ -- hello.text --
9+ hello world
10+
You can’t perform that action at this time.
0 commit comments