From 8bc6cfea1c73ae45a260169309e0e0b179bc748b Mon Sep 17 00:00:00 2001 From: Hugo Landau Date: Mon, 1 Dec 2014 00:55:40 +0000 Subject: [PATCH] Fix use of GOPATHs with multiple items. --- ncdomain/convert_test.go | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/ncdomain/convert_test.go b/ncdomain/convert_test.go index 61fdb61..8f55071 100644 --- a/ncdomain/convert_test.go +++ b/ncdomain/convert_test.go @@ -37,16 +37,27 @@ func stripTag(L string) string { return L } -func suiteReader(t *testing.T) <-chan testItem { - testItemChan := make(chan testItem, 20) - +func openFileFromGOPATH(fn string) (f *os.File, err error) { gopath := os.Getenv("GOPATH") if gopath == "" { gopath = "." } - fpath := filepath.Join(gopath, "src/github.com/hlandau/nctestsuite/testsuite.txt") - f, err := os.Open(fpath) + for _, p := range strings.Split(gopath, string(os.PathListSeparator)) { + f, err = os.Open(filepath.Join(p, fn)) + if err == nil { + return + } + } + + return +} + +func suiteReader(t *testing.T) <-chan testItem { + testItemChan := make(chan testItem, 20) + + fpath := "src/github.com/hlandau/nctestsuite/testsuite.txt" + f, err := openFileFromGOPATH(fpath) if err != nil { t.Fatalf("Error: Couldn't open %s: %+v", fpath, err)