RunCleaner runs the test database cleaning process. It takes no arguments but uses stdio and environment variables for its operation. The cleaner is designed to run in a separate process from the main test suite, connected over stdio. If the main test process ends (panics, times out, or is killed)
()
| 191 | // process ends (panics, times out, or is killed) without explicitly discarding the databases it clones, the cleaner |
| 192 | // removes them so they don't leak beyond the test session. c.f. https://github.com/coder/internal/issues/927 |
| 193 | func RunCleaner() { |
| 194 | c := cleaner{} |
| 195 | ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) |
| 196 | defer cancel() |
| 197 | // canceling a test via the IDE sends us an interrupt signal. We only want to process that signal during init. After |
| 198 | // we want to ignore the signal and do our cleaning. |
| 199 | signalCtx, signalCancel := signal.NotifyContext(ctx, os.Interrupt) |
| 200 | defer signalCancel() |
| 201 | err := c.init(signalCtx) |
| 202 | if err != nil { |
| 203 | _, _ = fmt.Fprintf(os.Stdout, "failed to init: %s", err.Error()) |
| 204 | _ = os.Stdout.Close() |
| 205 | return |
| 206 | } |
| 207 | _, _ = fmt.Fprint(os.Stdout, cleanerRespOK) |
| 208 | _ = os.Stdout.Close() |
| 209 | c.waitAndClean() |
| 210 | } |
no test coverage detected