blob: 6cbad83bc78051199936e32cc4aec35a80e2a50f (
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
|
[short] skip
go test -trimpath -v .
! stdout '[/\\]pkg_test_test[/\\]'
stdout -count=2 '[/\\]pkg_test[/\\]'
-- go.mod --
module example.com/pkg_test
go 1.17
-- pkg.go --
package pkg_test
import "runtime"
func PrintFile() {
_, file, _, _ := runtime.Caller(0)
println(file)
}
-- pkg_x_test.go --
package pkg_test_test
import (
"runtime"
"testing"
"example.com/pkg_test"
)
func PrintFileForTest() {
_, file, _, _ := runtime.Caller(0)
println(file)
}
func TestMain(m *testing.M) {
pkg_test.PrintFile()
PrintFileForTest()
}
|