MCPcopy
hub / github.com/tinygo-org/tinygo / TestTempDirInCleanup

Function TestTempDirInCleanup

src/testing/testing_test.go:28–50  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

26}
27
28func 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
52func TestTempDirInBenchmark(t *testing.T) {
53 testing.Benchmark(func(b *testing.B) {

Callers

nothing calls this directly

Calls 7

LogMethod · 0.65
CleanupMethod · 0.65
TempDirMethod · 0.65
FatalfMethod · 0.65
RunMethod · 0.45
StatMethod · 0.45
IsMethod · 0.45

Tested by

no test coverage detected