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