testenv: add Pause() method (#5367)

This commit is contained in:
Joe Kralicky 2024-11-07 15:41:59 -05:00 committed by GitHub
parent 37017e2a5b
commit 135e737d7c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -114,6 +114,10 @@ type Environment interface {
// no effect. It is usually not necessary to call Stop() directly unless you
// need to stop the test environment before the test is completed.
Stop()
// Pause will block and wait until SIGINT is received, then continue. This
// has the same effect as if the test failed and the PauseOnFailure option was
// given, but can be called at any time.
Pause()
// SubdomainURL returns a string [values.Value] which will contain a complete
// URL for the given subdomain of the server's domain (given by its serving
@ -642,6 +646,14 @@ func (e *environment) Stop() {
})
}
func (e *environment) Pause() {
e.t.Log("\x1b[31m*** test manually paused; continue with ctrl+c ***\x1b[0m")
c := make(chan os.Signal, 1)
signal.Notify(c, syscall.SIGINT)
<-c
e.t.Log("\x1b[31mctrl+c received, continuing\x1b[0m")
}
func (e *environment) cleanup() {
e.cleanupOnce.Do(func() {
e.debugf("stop: test cleanup")