OLD | NEW |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package exec | 5 package exec |
6 | 6 |
7 import ( | 7 import ( |
8 "testing" | 8 "testing" |
9 ) | 9 ) |
10 | 10 |
11 var nonExistentPaths = []string{ | 11 var nonExistentPaths = []string{ |
12 "some-non-existent-path", | 12 "some-non-existent-path", |
13 "non-existent-path/slashed", | 13 "non-existent-path/slashed", |
14 } | 14 } |
15 | 15 |
16 func TestLookPathNotFound(t *testing.T) { | 16 func TestLookPathNotFound(t *testing.T) { |
17 for _, name := range nonExistentPaths { | 17 for _, name := range nonExistentPaths { |
18 path, err := LookPath(name) | 18 path, err := LookPath(name) |
19 if err == nil { | 19 if err == nil { |
20 t.Fatalf("LookPath found %q in $PATH", name) | 20 t.Fatalf("LookPath found %q in $PATH", name) |
21 } | 21 } |
22 if path != "" { | 22 if path != "" { |
23 t.Fatalf("LookPath path == %q when err != nil", path) | 23 t.Fatalf("LookPath path == %q when err != nil", path) |
24 } | 24 } |
25 perr, ok := err.(*PathError) | 25 perr, ok := err.(*PathError) |
26 if !ok { | 26 if !ok { |
27 t.Fatal("LookPath error is not a PathError") | 27 t.Fatal("LookPath error is not a PathError") |
28 } | 28 } |
29 if perr.Name != name { | 29 if perr.Name != name { |
30 » » » t.Fatal("want PathError name %q, got %q", name, perr.Nam
e) | 30 » » » t.Fatalf("want PathError name %q, got %q", name, perr.Na
me) |
31 } | 31 } |
32 } | 32 } |
33 } | 33 } |
OLD | NEW |