(t testing.TB, dir string)
| 935 | } |
| 936 | |
| 937 | func 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 | |
| 961 | type testWriter struct{ T testing.TB } |
| 962 |
no outgoing calls
no test coverage detected