MCPcopy
hub / github.com/urfave/cli / TestTracing

Function TestTracing

cli_test.go:31–59  ·  cli_test.go::TestTracing
(t *testing.T)

Source from the content-addressed store, hash-verified

29}
30
31func TestTracing(t *testing.T) {
32 olderr := os.Stderr
33 oldtracing := isTracingOn
34 defer func() {
35 os.Stderr = olderr
36 isTracingOn = oldtracing
37 }()
38
39 file, err := os.CreateTemp(os.TempDir(), "cli*")
40 assert.NoError(t, err)
41 os.Stderr = file
42
43 // Note we can't really set the env since the isTracingOn
44 // is read at module startup so any changes mid code
45 // won't take effect
46 isTracingOn = false
47 tracef("something")
48
49 isTracingOn = true
50 tracef("foothing")
51
52 assert.NoError(t, file.Close())
53
54 b, err := os.ReadFile(file.Name())
55 assert.NoError(t, err)
56
57 assert.Contains(t, string(b), "foothing")
58 assert.NotContains(t, string(b), "something")
59}

Callers

nothing calls this directly

Calls 2

tracefFunction · 0.85
NameMethod · 0.65

Tested by

no test coverage detected