| 26 | } |
| 27 | |
| 28 | func TestTempDirInCleanup(t *testing.T) { |
| 29 | if runtime.GOOS == "wasip1" || runtime.GOOS == "wasip2" { |
| 30 | t.Log("Skipping. TODO: implement RemoveAll for wasi") |
| 31 | return |
| 32 | } |
| 33 | |
| 34 | var dir string |
| 35 | |
| 36 | t.Run("test", func(t *testing.T) { |
| 37 | t.Cleanup(func() { |
| 38 | dir = t.TempDir() |
| 39 | }) |
| 40 | _ = t.TempDir() |
| 41 | }) |
| 42 | |
| 43 | fi, err := os.Stat(dir) |
| 44 | if fi != nil { |
| 45 | t.Fatalf("Directory %q from user Cleanup still exists", dir) |
| 46 | } |
| 47 | if !errors.Is(err, fs.ErrNotExist) { |
| 48 | t.Fatalf("Unexpected error: %v", err) |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | func TestTempDirInBenchmark(t *testing.T) { |
| 53 | testing.Benchmark(func(b *testing.B) { |