repoRoot returns the absolute path to the repository root. It derives this from the known location of this source file (test/integration/) relative to the repo root.
(t *testing.T)
| 10 | // It derives this from the known location of this source file |
| 11 | // (test/integration/) relative to the repo root. |
| 12 | func repoRoot(t *testing.T) string { |
| 13 | t.Helper() |
| 14 | _, file, _, ok := runtime.Caller(0) |
| 15 | if !ok { |
| 16 | t.Fatal("failed to determine repo root via runtime.Caller") |
| 17 | } |
| 18 | // file is <repo>/test/integration/helpers_test.go → go up two dirs |
| 19 | return filepath.Dir(filepath.Dir(filepath.Dir(file))) |
| 20 | } |
| 21 | |
| 22 | // repoRootBench is the same as repoRoot but for use in benchmarks. |
| 23 | func repoRootBench(b *testing.B) string { |
no outgoing calls
no test coverage detected