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

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

Issue 6458091: code review 6458091: go/build: correct shouldBuild bug reading whole content... (Closed)
Left Patch Set: Created 12 years, 7 months ago
Right Patch Set: diff -r f979026319cc https://go.googlecode.com/hg/ Created 12 years, 7 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/pkg/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 "os" 8 "os"
9 "path/filepath" 9 "path/filepath"
10 "runtime" 10 "runtime"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 p, err := ImportDir(cwd, 0) 70 p, err := ImportDir(cwd, 0)
71 if err != nil { 71 if err != nil {
72 t.Fatal(err) 72 t.Fatal(err)
73 } 73 }
74 if p.ImportPath != "go/build" { 74 if p.ImportPath != "go/build" {
75 t.Fatalf("ImportPath=%q, want %q", p.ImportPath, "go/build") 75 t.Fatalf("ImportPath=%q, want %q", p.ImportPath, "go/build")
76 } 76 }
77 } 77 }
78
79 func TestShouldBuild(t *testing.T) {
80 const file1 = "// +build tag1\n\n" +
81 "package main\n"
82
83 const file2 = "// +build cgo\n\n" +
84 "// This package implements parsing of tags like\n" +
85 "// +build tag1\n" +
86 "package build"
87
88 const file3 = "// Copyright The Go Authors.\n\n" +
89 "package build\n\n" +
90 "// shouldBuild checks tags given by lines of the form\n" +
91 "// +build tag\n" +
92 "func shouldBuild(content []byte)\n"
93
94 ctx := &Context{BuildTags: []string{"tag1"}}
95 if !ctx.shouldBuild([]byte(file1)) {
96 t.Errorf("should not build file1, expected the contrary")
97 }
98 if ctx.shouldBuild([]byte(file2)) {
99 t.Errorf("should build file2, expected the contrary")
100 }
101
102 ctx = &Context{BuildTags: nil}
103 if !ctx.shouldBuild([]byte(file3)) {
104 t.Errorf("should not build file3, expected the contrary")
105 }
106 }
LEFTRIGHT

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