| 1405 | } |
| 1406 | |
| 1407 | func run() error { |
| 1408 | if tc := os.Getenv("TEAMCITY_VERSION"); len(tc) > 0 { |
| 1409 | fmt.Printf("Found Teamcity: %s\n", tc) |
| 1410 | isTeamcity = true |
| 1411 | } |
| 1412 | if *clear { |
| 1413 | removeAllTestContainers() |
| 1414 | return nil |
| 1415 | } |
| 1416 | if len(*runPkg) > 0 && len(*runTest) > 0 { |
| 1417 | log.Fatalf("Both pkg and test can't be set.\n") |
| 1418 | } |
| 1419 | fmt.Printf("Proc ID is %d\n", procId) |
| 1420 | fmt.Printf("Detected architecture: %s", runtime.GOARCH) |
| 1421 | |
| 1422 | // Ensure $GOPATH/bin is in PATH so that tools installed via `go install` |
| 1423 | // (e.g. protoc-gen-go) are found by subprocesses like protoc. |
| 1424 | gopath := os.Getenv("GOPATH") |
| 1425 | if gopath == "" { |
| 1426 | gopath = filepath.Join(os.Getenv("HOME"), "go") |
| 1427 | } |
| 1428 | gopathBin := filepath.Join(gopath, "bin") |
| 1429 | currentPath := os.Getenv("PATH") |
| 1430 | if !strings.Contains(currentPath, gopathBin) { |
| 1431 | os.Setenv("PATH", gopathBin+string(os.PathListSeparator)+currentPath) |
| 1432 | } |
| 1433 | |
| 1434 | start := time.Now() |
| 1435 | oc.Took(0, "START", time.Millisecond) |
| 1436 | |
| 1437 | if *rebuildBinary { |
| 1438 | var cmd *exec.Cmd |
| 1439 | if *race { |
| 1440 | cmd = command("make", "BUILD_RACE=y", "install") |
| 1441 | } else { |
| 1442 | cmd = command("make", "install") |
| 1443 | } |
| 1444 | cmd.Dir = *baseDir |
| 1445 | if err := cmd.Run(); err != nil { |
| 1446 | return err |
| 1447 | } |
| 1448 | oc.Took(0, "COMPILE", time.Since(start)) |
| 1449 | } |
| 1450 | |
| 1451 | tmpDir, err := os.MkdirTemp("", "dgraph-test") |
| 1452 | x.Check(err) |
| 1453 | defer os.RemoveAll(tmpDir) |
| 1454 | |
| 1455 | err = executePreRunSteps() |
| 1456 | x.Check(err) |
| 1457 | N := *concurrency |
| 1458 | if len(*runPkg) > 0 || len(*runTest) > 0 { |
| 1459 | N = 1 |
| 1460 | } |
| 1461 | closer := z.NewCloser(N) |
| 1462 | testCh := make(chan task) |
| 1463 | errCh := make(chan error, 1000) |
| 1464 | var runWg sync.WaitGroup |