This repository was archived by the owner on Sep 9, 2020. It is now read-only.
File tree 2 files changed +35
-3
lines changed 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2017 The Go Authors. All rights reserved.
2
+ // Use of this source code is governed by a BSD-style
3
+ // license that can be found in the LICENSE file.
4
+ package pkgtree
5
+
6
+ import "testing"
7
+
8
+ func BenchmarkListPackages (b * testing.B ) {
9
+ b .StopTimer ()
10
+
11
+ j := func (s ... string ) string {
12
+ return testDir (b , s ... )
13
+ }
14
+
15
+ table := []string {
16
+ "dotgodir" ,
17
+ "buildtag" ,
18
+ "varied" ,
19
+ }
20
+
21
+ b .StartTimer ()
22
+
23
+ for _ , name := range table {
24
+ for n := 0 ; n < b .N ; n ++ {
25
+ ListPackages (j (name ), name )
26
+ }
27
+ }
28
+ }
Original file line number Diff line number Diff line change @@ -472,10 +472,14 @@ func TestListPackagesNoDir(t *testing.T) {
472
472
}
473
473
}
474
474
475
- func TestListPackages (t * testing.T ) {
475
+ func testDir (t testing.TB , s ... string ) string {
476
476
srcdir := filepath .Join (getTestdataRootDir (t ), "src" )
477
+ return filepath .Join (srcdir , filepath .Join (s ... ))
478
+ }
479
+
480
+ func TestListPackages (t * testing.T ) {
477
481
j := func (s ... string ) string {
478
- return filepath . Join ( srcdir , filepath . Join ( s ... ) )
482
+ return testDir ( t , s ... )
479
483
}
480
484
481
485
table := map [string ]struct {
@@ -1976,7 +1980,7 @@ func TestToReachMapFilterDot(t *testing.T) {
1976
1980
}
1977
1981
}
1978
1982
1979
- func getTestdataRootDir (t * testing.T ) string {
1983
+ func getTestdataRootDir (t testing.TB ) string {
1980
1984
cwd , err := os .Getwd ()
1981
1985
if err != nil {
1982
1986
t .Fatal (err )
You can’t perform that action at this time.
0 commit comments