MCPcopy Create free account
hub / github.com/bracesdev/errtrace / chdir

Function chdir

cmd/errtrace/main_test.go:937–959  ·  view source on GitHub ↗
(t testing.TB, dir string)

Source from the content-addressed store, hash-verified

935}
936
937func chdir(t testing.TB, dir string) (restore func()) {
938 t.Helper()
939
940 cwd, err := os.Getwd()
941 if err != nil {
942 t.Fatal(err)
943 }
944
945 var once sync.Once
946 restore = func() {
947 once.Do(func() {
948 if err := os.Chdir(cwd); err != nil {
949 t.Fatal(err)
950 }
951 })
952 }
953
954 t.Cleanup(restore)
955 if err := os.Chdir(dir); err != nil {
956 t.Fatal(err)
957 }
958 return restore
959}
960
961type testWriter struct{ T testing.TB }
962

Callers 2

testGoldenContentsFunction · 0.85
TestExpandPatternsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected