aboutsummaryrefslogtreecommitdiff
path: root/src/testing
diff options
context:
space:
mode:
authorHossein Zolfi <hossein.zolfi@gmail.com>2023-01-27 18:20:09 +0330
committerGopher Robot <gobot@golang.org>2023-02-22 16:42:04 +0000
commit81316ff50a4a81cc2077f8a831b4e1896c56a564 (patch)
tree1c703d42a0d7ad65735f9c3b062ee5aaff95afc0 /src/testing
parentc17f8057b09b26b32f0a2aaa1efc9dd89921d431 (diff)
downloadgo-81316ff50a4a81cc2077f8a831b4e1896c56a564.tar.xz
testing: add -fullpath to go test
When -test.fullpath flag is provided to go test, go test displays the full file names in error messages. Fixes #37708 Change-Id: I6096e75ed816fd42205810f20624e495047a73a2 Reviewed-on: https://go-review.googlesource.com/c/go/+/463837 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'src/testing')
-rw-r--r--src/testing/testing.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/testing/testing.go b/src/testing/testing.go
index fc34cbf28b..2d0fd89137 100644
--- a/src/testing/testing.go
+++ b/src/testing/testing.go
@@ -441,6 +441,7 @@ func Init() {
parallel = flag.Int("test.parallel", runtime.GOMAXPROCS(0), "run at most `n` tests in parallel")
testlog = flag.String("test.testlogfile", "", "write test action log to `file` (for use only by cmd/go)")
shuffle = flag.String("test.shuffle", "off", "randomize the execution order of tests and benchmarks")
+ fullPath = flag.Bool("test.fullpath", false, "show full file names in error messages")
initBenchmarkFlags()
initFuzzFlags()
@@ -472,6 +473,7 @@ var (
parallel *int
shuffle *string
testlog *string
+ fullPath *bool
haveExamples bool // are there examples?
@@ -751,8 +753,9 @@ func (c *common) decorate(s string, skip int) string {
file := frame.File
line := frame.Line
if file != "" {
- // Truncate file name at last file name separator.
- if index := strings.LastIndex(file, "/"); index >= 0 {
+ if *fullPath {
+ // If relative path, truncate file name at last file name separator.
+ } else if index := strings.LastIndex(file, "/"); index >= 0 {
file = file[index+1:]
} else if index = strings.LastIndex(file, "\\"); index >= 0 {
file = file[index+1:]