]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: adjust TestFileLineInErrorMessages
authorAlex Brainman <alex.brainman@gmail.com>
Thu, 25 Jun 2015 04:12:48 +0000 (14:12 +1000)
committerRuss Cox <rsc@golang.org>
Sat, 27 Jun 2015 18:43:45 +0000 (18:43 +0000)
cmd/go sometimes returns relative path in the error message
(see shortPath function). Account for that during
TestFileLineInErrorMessages.

Fixes #11355

Change-Id: Ica79359eab48d669d307449fdd458764895fab2c
Reviewed-on: https://go-review.googlesource.com/11475
Reviewed-by: Russ Cox <rsc@golang.org>
src/cmd/go/go_test.go

index 1146a41c18a74920e248fe081377f5cc13449156..e70bff0bbd54d39890dccf2fc71423a64749898e 100644 (file)
@@ -548,7 +548,11 @@ func TestFileLineInErrorMessages(t *testing.T) {
        tg.tempFile("err.go", `package main; import "bar"`)
        path := tg.path("err.go")
        tg.runFail("run", path)
-       tg.grepStderr("^"+regexp.QuoteMeta(path)+":", "missing file:line in error message")
+       shortPath := path
+       if rel, err := filepath.Rel(tg.pwd(), path); err == nil && len(rel) < len(path) {
+               shortPath = rel
+       }
+       tg.grepStderr("^"+regexp.QuoteMeta(shortPath)+":", "missing file:line in error message")
 }
 
 func TestProgramNameInCrashMessages(t *testing.T) {