(t *testing.T)
| 1425 | } |
| 1426 | |
| 1427 | func TestGetGOPATHs(t *testing.T) { |
| 1428 | // This test cannot run in parallel. |
| 1429 | old := os.Getenv("GOPATH") |
| 1430 | defer os.Setenv("GOPATH", old) |
| 1431 | os.Setenv("GOPATH", "") |
| 1432 | if p := getGOPATHs(); len(p) != 1 { |
| 1433 | // It's the home directory + /go. |
| 1434 | t.Fatalf("expected only one path: %v", p) |
| 1435 | } |
| 1436 | |
| 1437 | root, err := os.MkdirTemp("", "stack") |
| 1438 | if err != nil { |
| 1439 | t.Fatal(err) |
| 1440 | } |
| 1441 | defer func() { |
| 1442 | if err = os.RemoveAll(root); err != nil { |
| 1443 | t.Error(err) |
| 1444 | } |
| 1445 | }() |
| 1446 | os.Setenv("GOPATH", filepath.Join(root, "a")+string(filepath.ListSeparator)+filepath.Join(root, "b")+string(filepath.Separator)) |
| 1447 | if p := getGOPATHs(); len(p) != 2 { |
| 1448 | t.Fatalf("expected two paths: %v", p) |
| 1449 | } |
| 1450 | } |
| 1451 | |
| 1452 | // TestGomoduleComplex is an integration test that creates a non-trivial tree |
| 1453 | // of go modules using the "replace" statement. |
nothing calls this directly
no test coverage detected
searching dependent graphs…