xerrors: fix TestErrorf false positive when top-level dir is renamed

The rePath pattern will typically replace two matches with "/path.":
one with the test's import path, like " /golang.org/x/xerrors_test.",
and a file path like " /Users/gopher/golang.org/x/xerrors/fmt_test.".

The former will always end with "/xerrors_test." as long as the module
path is still "golang.org/x/xerrors" and the TestErrorf test is inside
an xerrors_test package. The latter may not match xerrors.*test if the
top-level directory isn't named "xerrors". But it will always end with
"/fmt_test." as long as the TestErrorf test is still inside the file
named "fmt_test.go".

So look for those two patterns to fix false positive failures when the
git repository is cloned to a custom path without any "xerrors" in it.

Change-Id: I4d95121734337050309c2d989afd8f82430a2f31
Reviewed-on: https://go-review.googlesource.com/c/xerrors/+/609380
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
1 file changed