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

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

Issue 5489100: code review 5489100: go/build: add new +build tags 'cgo' and 'nocgo' (Closed)
Left Patch Set: Created 12 years, 3 months ago
Right Patch Set: diff -r 40e366e721a9 https://go.googlecode.com/hg/ Created 12 years, 3 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/debug/gosym/pclinetest.s ('k') | src/pkg/go/build/dir.go » ('j') | 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/exec" 8 "os/exec"
9 "path/filepath" 9 "path/filepath"
10 "reflect" 10 "reflect"
(...skipping 28 matching lines...) Expand all
39 &DirInfo{ 39 &DirInfo{
40 GoFiles: []string{"main.go"}, 40 GoFiles: []string{"main.go"},
41 Package: "main", 41 Package: "main",
42 Imports: []string{"go/build/pkgtest"}, 42 Imports: []string{"go/build/pkgtest"},
43 TestImports: []string{}, 43 TestImports: []string{},
44 }, 44 },
45 }, 45 },
46 { 46 {
47 "go/build/cgotest", 47 "go/build/cgotest",
48 &DirInfo{ 48 &DirInfo{
49 » » » CgoFiles: []string{"cgotest.go"}, 49 » » » CgoFiles: ifCgo([]string{"cgotest.go"}),
50 CFiles: []string{"cgotest.c"}, 50 CFiles: []string{"cgotest.c"},
51 HFiles: []string{"cgotest.h"}, 51 HFiles: []string{"cgotest.h"},
52 Imports: []string{"C", "unsafe"}, 52 Imports: []string{"C", "unsafe"},
53 TestImports: []string{}, 53 TestImports: []string{},
54 Package: "cgotest", 54 Package: "cgotest",
55 }, 55 },
56 }, 56 },
57 }
58
59 func ifCgo(x []string) []string {
60 if DefaultContext.CgoEnabled {
61 return x
62 }
63 return nil
57 } 64 }
58 65
59 const cmdtestOutput = "3" 66 const cmdtestOutput = "3"
60 67
61 func TestBuild(t *testing.T) { 68 func TestBuild(t *testing.T) {
62 for _, tt := range buildPkgs { 69 for _, tt := range buildPkgs {
63 tree := Path[0] // Goroot 70 tree := Path[0] // Goroot
64 dir := filepath.Join(tree.SrcDir(), tt.dir) 71 dir := filepath.Join(tree.SrcDir(), tt.dir)
65 info, err := ScanDir(dir) 72 info, err := ScanDir(dir)
66 if err != nil { 73 if err != nil {
67 t.Errorf("ScanDir(%#q): %v", tt.dir, err) 74 t.Errorf("ScanDir(%#q): %v", tt.dir, err)
68 continue 75 continue
69 } 76 }
70 if !reflect.DeepEqual(info, tt.info) { 77 if !reflect.DeepEqual(info, tt.info) {
71 t.Errorf("ScanDir(%#q) = %#v, want %#v\n", tt.dir, info, tt.info) 78 t.Errorf("ScanDir(%#q) = %#v, want %#v\n", tt.dir, info, tt.info)
79 continue
80 }
81
82 if tt.dir == "go/build/cgotest" && len(info.CgoFiles) == 0 {
72 continue 83 continue
73 } 84 }
74 85
75 s, err := Build(tree, tt.dir, info) 86 s, err := Build(tree, tt.dir, info)
76 if err != nil { 87 if err != nil {
77 t.Errorf("Build(%#q): %v", tt.dir, err) 88 t.Errorf("Build(%#q): %v", tt.dir, err)
78 continue 89 continue
79 } 90 }
80 91
81 if err := s.Run(); err != nil { 92 if err := s.Run(); err != nil {
(...skipping 14 matching lines...) Expand all
96 } 107 }
97 108
98 // Deferred because cmdtest depends on pkgtest. 109 // Deferred because cmdtest depends on pkgtest.
99 defer func(s *Script) { 110 defer func(s *Script) {
100 if err := s.Nuke(); err != nil { 111 if err := s.Nuke(); err != nil {
101 t.Errorf("nuking: %v", err) 112 t.Errorf("nuking: %v", err)
102 } 113 }
103 }(s) 114 }(s)
104 } 115 }
105 } 116 }
LEFTRIGHT

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