LEFT | RIGHT |
(no file at all) | |
| 1 // +build api_tool |
| 2 |
1 // Copyright 2011 The Go Authors. All rights reserved. | 3 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 4 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 5 // license that can be found in the LICENSE file. |
4 | 6 |
5 package main | 7 package main |
6 | 8 |
7 import ( | 9 import ( |
8 "bytes" | 10 "bytes" |
9 "flag" | 11 "flag" |
10 "fmt" | 12 "fmt" |
(...skipping 15 matching lines...) Expand all Loading... |
26 t.Fatal(err) | 28 t.Fatal(err) |
27 } | 29 } |
28 fis, err := td.Readdir(0) | 30 fis, err := td.Readdir(0) |
29 if err != nil { | 31 if err != nil { |
30 t.Fatal(err) | 32 t.Fatal(err) |
31 } | 33 } |
32 for _, fi := range fis { | 34 for _, fi := range fis { |
33 if !fi.IsDir() { | 35 if !fi.IsDir() { |
34 continue | 36 continue |
35 } | 37 } |
36 w := NewWalker() | |
37 w.wantedPkg[fi.Name()] = true | |
38 | 38 |
39 w.root = "testdata/src/pkg" | |
40 goldenFile := filepath.Join("testdata", "src", "pkg", fi.Name(),
"golden.txt") | 39 goldenFile := filepath.Join("testdata", "src", "pkg", fi.Name(),
"golden.txt") |
41 » » w.WalkPackage(fi.Name()) | 40 » » w := NewWalker(nil, "testdata/src/pkg") |
| 41 » » w.export(w.Import(fi.Name())) |
42 | 42 |
43 if *updateGolden { | 43 if *updateGolden { |
44 os.Remove(goldenFile) | 44 os.Remove(goldenFile) |
45 f, err := os.Create(goldenFile) | 45 f, err := os.Create(goldenFile) |
46 if err != nil { | 46 if err != nil { |
47 t.Fatal(err) | 47 t.Fatal(err) |
48 } | 48 } |
49 for _, feat := range w.Features() { | 49 for _, feat := range w.Features() { |
50 fmt.Fprintf(f, "%s\n", feat) | 50 fmt.Fprintf(f, "%s\n", feat) |
51 } | 51 } |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 buf := new(bytes.Buffer) | 132 buf := new(bytes.Buffer) |
133 gotok := compareAPI(buf, tt.features, tt.required, tt.optional,
tt.exception) | 133 gotok := compareAPI(buf, tt.features, tt.required, tt.optional,
tt.exception) |
134 if gotok != tt.ok { | 134 if gotok != tt.ok { |
135 t.Errorf("%s: ok = %v; want %v", tt.name, gotok, tt.ok) | 135 t.Errorf("%s: ok = %v; want %v", tt.name, gotok, tt.ok) |
136 } | 136 } |
137 if got := buf.String(); got != tt.out { | 137 if got := buf.String(); got != tt.out { |
138 t.Errorf("%s: output differs\nGOT:\n%s\nWANT:\n%s", tt.n
ame, got, tt.out) | 138 t.Errorf("%s: output differs\nGOT:\n%s\nWANT:\n%s", tt.n
ame, got, tt.out) |
139 } | 139 } |
140 } | 140 } |
141 } | 141 } |
LEFT | RIGHT |