Commit 50bb2b6b authored by Bryan C. Mills's avatar Bryan C. Mills

cmd/go: allow "stdout" and "stderr" as inputs to script_test "cp" command

Updates #30241

Change-Id: I543d8914faf810835d3327baa3c84b3dff124156
Reviewed-on: https://go-review.googlesource.com/c/163519Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent 1670da9e
......@@ -509,16 +509,33 @@ func (ts *testScript) cmdCp(neg bool, args []string) {
}
for _, arg := range args[:len(args)-1] {
src := ts.mkabs(arg)
var (
src string
data []byte
mode os.FileMode
)
switch arg {
case "stdout":
src = arg
data = []byte(ts.stdout)
mode = 0666
case "stderr":
src = arg
data = []byte(ts.stderr)
mode = 0666
default:
src = ts.mkabs(arg)
info, err := os.Stat(src)
ts.check(err)
data, err := ioutil.ReadFile(src)
mode = info.Mode() & 0777
data, err = ioutil.ReadFile(src)
ts.check(err)
}
targ := dst
if dstDir {
targ = filepath.Join(dst, filepath.Base(src))
}
ts.check(ioutil.WriteFile(targ, data, info.Mode()&0777))
ts.check(ioutil.WriteFile(targ, data, mode))
}
}
......
......@@ -108,6 +108,8 @@ The commands are:
- cp src... dst
Copy the listed files to the target file or existing directory.
src can include "stdout" or "stderr" to use the standard output or standard error
from the most recent exec or go command.
- env [key=value...]
With no arguments, print the environment (useful for debugging).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment