Changeset 6 in code
- Timestamp:
- Dec 5, 2014, 6:21:42 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zs.go
r5 r6 111 111 err := run(path.Join(ZSDIR, cmd[0]), cmd[1:], vars, outbuf) 112 112 if err != nil { 113 log.Println(err) 113 if _, ok := err.(*exec.ExitError); ok { 114 return "", err 115 } 114 116 outbuf = bytes.NewBuffer(nil) 115 117 err := run(cmd[0], cmd[1:], vars, outbuf) 116 if err != nil { 118 // Return exit errors, but ignore if the command was not found 119 if _, ok := err.(*exec.ExitError); ok { 117 120 return "", err 118 121 } -
trunk/zs_test.go
r5 r6 6 6 "log" 7 7 "os" 8 "os/exec" 8 9 "strings" 9 10 "testing" … … 124 125 } 125 126 127 func TestEvalCommand(t *testing.T) { 128 s, err := eval([]string{"echo", "hello"}, map[string]string{}) 129 if err != nil { 130 t.Error(err) 131 } 132 if s != "hello\n" { 133 t.Error(s) 134 } 135 _, err = eval([]string{"cat", "bogus/file"}, map[string]string{}) 136 if _, ok := err.(*exec.ExitError); !ok { 137 t.Error("expected ExitError") 138 } 139 _, err = eval([]string{"missing command"}, map[string]string{}) 140 if err != nil { 141 t.Error("missing command should be ignored") 142 } 143 } 144 126 145 func TestHelperProcess(*testing.T) { 127 146 if os.Getenv("ZS_HELPER") != "1" {
Note:
See TracChangeset
for help on using the changeset viewer.