Fix use of GOPATHs with multiple items.

pull/18/head
Hugo Landau 10 years ago
parent 7a948f972c
commit 8bc6cfea1c

@ -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)

Loading…
Cancel
Save