Skip to content

Commit 8351678

Browse files
committed
Dump info if TracingDriver is used
1 parent 2dd5fd8 commit 8351678

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/AsyncTestCase.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,18 @@ final protected function setTimeout(int $timeout)
111111
{
112112
$this->timeoutId = Loop::delay($timeout, function () use ($timeout) {
113113
Loop::stop();
114-
$this->fail('Expected test to complete before ' . $timeout . 'ms time limit');
114+
Loop::setErrorHandler(null);
115+
116+
$loop = Loop::get();
117+
if ($loop instanceof Loop\TracingDriver) {
118+
$additionalInfo = "\r\n\r\n" . $loop->dump();
119+
} elseif (\class_exists(Loop\TracingDriver::class)) {
120+
$additionalInfo = "\r\n\r\nSet AMP_DEBUG_TRACE_WATCHERS=true as environment variable to trace watchers keeping the loop running.";
121+
} else {
122+
$additionalInfo = "\r\n\r\nInstall amphp/amp@^2.3 and set AMP_DEBUG_TRACE_WATCHERS=true as environment variable to trace watchers keeping the loop running. ";
123+
}
124+
125+
$this->fail('Expected test to complete before ' . $timeout . 'ms time limit' . $additionalInfo);
115126
});
116127

117128
Loop::unreference($this->timeoutId);

0 commit comments

Comments
 (0)