...
1[short] skip
2
3go test -trimpath -v .
4! stdout '[/\\]pkg_test_test[/\\]'
5stdout -count=2 '[/\\]pkg_test[/\\]'
6
7-- go.mod --
8module example.com/pkg_test
9
10go 1.17
11
12-- pkg.go --
13package pkg_test
14
15import "runtime"
16
17func PrintFile() {
18 _, file, _, _ := runtime.Caller(0)
19 println(file)
20}
21
22-- pkg_x_test.go --
23package pkg_test_test
24
25import (
26 "runtime"
27 "testing"
28
29 "example.com/pkg_test"
30)
31
32func PrintFileForTest() {
33 _, file, _, _ := runtime.Caller(0)
34 println(file)
35}
36
37func TestMain(m *testing.M) {
38 pkg_test.PrintFile()
39 PrintFileForTest()
40}
View as plain text