"addcrlf": (*testScript).cmdAddcrlf,
"cd": (*testScript).cmdCd,
"cmp": (*testScript).cmdCmp,
+ "cmpenv": (*testScript).cmdCmpenv,
"cp": (*testScript).cmdCp,
"env": (*testScript).cmdEnv,
"exec": (*testScript).cmdExec,
if len(args) != 2 {
ts.fatalf("usage: cmp file1 file2")
}
+ ts.doCmdCmp(args, false)
+}
+// cmpenv compares two files with environment variable substitution.
+func (ts *testScript) cmdCmpenv(neg bool, args []string) {
+ if neg {
+ ts.fatalf("unsupported: ! cmpenv")
+ }
+ if len(args) != 2 {
+ ts.fatalf("usage: cmpenv file1 file2")
+ }
+ ts.doCmdCmp(args, true)
+}
+
+func (ts *testScript) doCmdCmp(args []string, env bool) {
name1, name2 := args[0], args[1]
var text1, text2 string
if name1 == "stdout" {
ts.check(err)
text2 = string(data)
+ if env {
+ text1 = ts.expand(text1)
+ text2 = ts.expand(text2)
+ }
+
if text1 == text2 {
return
}
from the most recent exec or go command.
(If the files have differing content, the failure prints a diff.)
+- cmpenv file1 file2
+ Like cmp, but environment variables are substituted in the file contents
+ before the comparison. For example, $GOOS is replaced by the target GOOS.
+
- cp src... dst
Copy the listed files to the target file or existing directory.