LEFT | RIGHT |
(no file at all) | |
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 build | 5 package build |
6 | 6 |
7 import ( | 7 import ( |
8 "io" | 8 "io" |
9 "os" | 9 "os" |
10 "path/filepath" | 10 "path/filepath" |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 196 |
197 func TestImportCmd(t *testing.T) { | 197 func TestImportCmd(t *testing.T) { |
198 p, err := Import("cmd/internal/objfile", "", 0) | 198 p, err := Import("cmd/internal/objfile", "", 0) |
199 if err != nil { | 199 if err != nil { |
200 t.Fatal(err) | 200 t.Fatal(err) |
201 } | 201 } |
202 if !strings.HasSuffix(filepath.ToSlash(p.Dir), "src/cmd/internal/objfile
") { | 202 if !strings.HasSuffix(filepath.ToSlash(p.Dir), "src/cmd/internal/objfile
") { |
203 t.Fatalf("Import cmd/internal/objfile returned Dir=%q, want %q",
filepath.ToSlash(p.Dir), ".../src/cmd/internal/objfile") | 203 t.Fatalf("Import cmd/internal/objfile returned Dir=%q, want %q",
filepath.ToSlash(p.Dir), ".../src/cmd/internal/objfile") |
204 } | 204 } |
205 } | 205 } |
| 206 |
| 207 const expandSrcDirPath = "/projects/src/add" |
| 208 |
| 209 var expandSrcDirTests = []struct { |
| 210 input, expected string |
| 211 }{ |
| 212 {"-L $SRCDIR/libs -ladd", "-L /projects/src/add/libs -ladd"}, |
| 213 {"${SRCDIR}/add_linux_386.a -pthread -lstdc++", "/projects/src/add/add_l
inux_386.a -pthread -lstdc++"}, |
| 214 {"Nothing to expand here!", "Nothing to expand here!"}, |
| 215 {"$", "$"}, |
| 216 {"$$", "$$"}, |
| 217 {"${", "${"}, |
| 218 {"$}", "$}"}, |
| 219 {"$FOO ${BAR}", "$FOO ${BAR}"}, |
| 220 |
| 221 // Note: this is a known bug |
| 222 {"Find me the $SRCDIRECTORY.", "Find me the /projects/src/addECTORY."}, |
| 223 // If it is fixed then the correct test case should be: |
| 224 // {"Find me the $SRCDIRECTORY.", "Find me the $SRCDIRECTORY."}, |
| 225 } |
| 226 |
| 227 func TestExpandSrcDir(t *testing.T) { |
| 228 for _, test := range expandSrcDirTests { |
| 229 output := expandSrcDir(test.input, expandSrcDirPath) |
| 230 if output != test.expected { |
| 231 t.Errorf("%q expands to %q when %q is expected", test.in
put, output, test.expected) |
| 232 } |
| 233 } |
| 234 } |
LEFT | RIGHT |