(t *testing.T)
| 40 | } |
| 41 | |
| 42 | func TestAll(t *testing.T) { |
| 43 | // We use a global channel so that the function below does not |
| 44 | // receive any arguments, so we can test that parseFirstFunc works |
| 45 | // regardless of arguments on the stack. |
| 46 | _allDone = make(chan struct{}) |
| 47 | defer close(_allDone) |
| 48 | |
| 49 | for i := 0; i < 5; i++ { |
| 50 | go waitForDone() |
| 51 | } |
| 52 | |
| 53 | cur := Current() |
| 54 | got := All() |
| 55 | |
| 56 | // Retry until the background stacks are not runnable/running. |
| 57 | for { |
| 58 | if !isBackgroundRunning(cur, got) { |
| 59 | break |
| 60 | } |
| 61 | runtime.Gosched() |
| 62 | got = All() |
| 63 | } |
| 64 | |
| 65 | // We have exactly 7 gorotuines: |
| 66 | // "main" goroutine |
| 67 | // test goroutine |
| 68 | // 5 goroutines started above. |
| 69 | require.Len(t, got, 7) |
| 70 | sort.Sort(byGoroutineID(got)) |
| 71 | |
| 72 | assert.Contains(t, got[0].Full(), "testing.(*T).Run") |
| 73 | assert.Contains(t, got[0].allFunctions, "testing.(*T).Run") |
| 74 | |
| 75 | assert.Contains(t, got[1].Full(), "TestAll") |
| 76 | assert.Contains(t, got[1].allFunctions, "go.uber.org/goleak/internal/stack.TestAll") |
| 77 | |
| 78 | for i := 0; i < 5; i++ { |
| 79 | assert.Contains(t, got[2+i].Full(), "stack.waitForDone") |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | func TestCurrent(t *testing.T) { |
| 84 | const pkgPrefix = "go.uber.org/goleak/internal/stack" |
nothing calls this directly
no test coverage detected
searching dependent graphs…