Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(3096)

Delta Between Two Patch Sets: src/go/build/build_test.go

Issue 114640044: code review 114640044: go/build: perform simple variable substitution in #cgo lines
Left Patch Set: diff -r 19201bb04c4fc975273e0d9f8d68bf844d1163cd http://code.google.com/p/go Created 9 years, 7 months ago
Right Patch Set: diff -r e54b1af55910c77e4a215112193472f0276b3c8d http://code.google.com/p/go Created 9 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/go/build/build.go ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(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
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 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b