MCPcopy Index your code
hub / github.com/coder/coder / RunCleaner

Function RunCleaner

coderd/database/dbtestutil/cleaner.go:193–210  ·  view source on GitHub ↗

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)

()

Source from the content-addressed store, hash-verified

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
193func 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}

Callers 1

initFunction · 0.85

Calls 5

initMethod · 0.95
waitAndCleanMethod · 0.95
NotifyContextMethod · 0.80
CloseMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected