summaryrefslogtreecommitdiffstats
path: root/src/cmd/go/testdata/script/test_trimpath.txt
blob: 065f9ce4d17852c87a360bba019132ad8df27bf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
[short] skip

go test -trimpath -v .
! stdout '[/\\]pkg_test[/\\]'
stdout -count=3 '[/\\]pkg[/\\]'

-- go.mod --
module example.com/pkg

go 1.17

-- pkg.go --
package pkg

import "runtime"

func PrintFile() {
	_, file, _, _ := runtime.Caller(0)
	println(file)
}

-- pkg_test.go --
package pkg

import "runtime"

func PrintFileForTest() {
	_, file, _, _ := runtime.Caller(0)
	println(file)
}

-- pkg_x_test.go --
package pkg_test

import (
	"runtime"
	"testing"

	"example.com/pkg"
)

func TestMain(m *testing.M) {
	pkg.PrintFile()
	pkg.PrintFileForTest()
	PrintFileInXTest()
}

func PrintFileInXTest() {
	_, file, _, _ := runtime.Caller(0)
	println(file)
}