Commit ba607240 authored by Bryan C. Mills's avatar Bryan C. Mills

cmd/go: add a chmod command to script_test

Change-Id: I5d4f65553f6c368d101be59aae9440f5ec9573b7
Reviewed-on: https://go-review.googlesource.com/c/153461
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: 's avatarIan Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 21da8e60
...@@ -342,6 +342,7 @@ Script: ...@@ -342,6 +342,7 @@ Script:
var scriptCmds = map[string]func(*testScript, bool, []string){ var scriptCmds = map[string]func(*testScript, bool, []string){
"addcrlf": (*testScript).cmdAddcrlf, "addcrlf": (*testScript).cmdAddcrlf,
"cd": (*testScript).cmdCd, "cd": (*testScript).cmdCd,
"chmod": (*testScript).cmdChmod,
"cmp": (*testScript).cmdCmp, "cmp": (*testScript).cmdCmp,
"cmpenv": (*testScript).cmdCmpenv, "cmpenv": (*testScript).cmdCmpenv,
"cp": (*testScript).cmdCp, "cp": (*testScript).cmdCp,
...@@ -400,6 +401,24 @@ func (ts *testScript) cmdCd(neg bool, args []string) { ...@@ -400,6 +401,24 @@ func (ts *testScript) cmdCd(neg bool, args []string) {
fmt.Fprintf(&ts.log, "%s\n", ts.cd) fmt.Fprintf(&ts.log, "%s\n", ts.cd)
} }
// chmod changes permissions for a file or directory.
func (ts *testScript) cmdChmod(neg bool, args []string) {
if neg {
ts.fatalf("unsupported: ! chmod")
}
if len(args) < 2 {
ts.fatalf("usage: chmod perm paths...")
}
perm, err := strconv.ParseUint(args[0], 0, 32)
if err != nil || perm&uint64(os.ModePerm) != perm {
ts.fatalf("invalid mode: %s", args[0])
}
for _, path := range args[1:] {
err := os.Chmod(path, os.FileMode(perm))
ts.check(err)
}
}
// cmp compares two files. // cmp compares two files.
func (ts *testScript) cmdCmp(neg bool, args []string) { func (ts *testScript) cmdCmp(neg bool, args []string) {
if neg { if neg {
......
...@@ -86,6 +86,10 @@ The commands are: ...@@ -86,6 +86,10 @@ The commands are:
- cd dir - cd dir
Change to the given directory for future commands. Change to the given directory for future commands.
- chmod perm path...
Change the permissions of the files or directories named by the path arguments
to be equal to perm. Only numerical permissions are supported.
- cmp file1 file2 - cmp file1 file2
Check that the named files have the same content. Check that the named files have the same content.
By convention, file1 is the actual data and file2 the expected data. By convention, file1 is the actual data and file2 the expected data.
......
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