checkWait is like check, but if the file is empty, it waits until it's not.
(t *testing.T, l *log, txt, notxt string)
| 143 | // checkWait is like check, but if the file is empty, |
| 144 | // it waits until it's not. |
| 145 | func checkWait(t *testing.T, l *log, txt, notxt string) { |
| 146 | t.Helper() |
| 147 | const ( |
| 148 | delay = 100 * time.Millisecond |
| 149 | iter = 3 |
| 150 | ) |
| 151 | for i := 0; ; i++ { |
| 152 | st, err := l.file.Stat() |
| 153 | if err != nil { |
| 154 | t.Fatal(err) |
| 155 | } |
| 156 | if st.Size() > 0 { |
| 157 | break |
| 158 | } |
| 159 | if i == iter { |
| 160 | t.Fatalf("waited %s for file %s to be non-empty but it still is", iter*delay, l.file.Name()) |
| 161 | } |
| 162 | time.Sleep(delay) |
| 163 | } |
| 164 | |
| 165 | check(t, l, txt, notxt) |
| 166 | } |
no test coverage detected
searching dependent graphs…