MCPcopy Index your code
hub / github.com/cheat/cheat / repoRoot

Function repoRoot

test/integration/helpers_test.go:12–20  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

10// It derives this from the known location of this source file
11// (test/integration/) relative to the repo root.
12func 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.
23func repoRootBench(b *testing.B) string {

Callers 5

TestFirstRunIntegrationFunction · 0.85
TestBriefFlagIntegrationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected