Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tests/DemoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function withDemo(callable $body, string $prefix = '', array $env = []): void
usleep(100000);
}
try {
$body(function (string $method, string $uri, array $headers = [], string $content = '') use ($port, $prefix): array {
$body(function (string $method, string $uri, array $headers = [], string $content = '') use ($port, $prefix, $proc): array {
$h = '';
foreach ($headers as $k => $v) {
$h .= "$k: $v\r\n";
Expand All @@ -61,6 +61,13 @@ function withDemo(callable $body, string $prefix = '', array $env = []): void
$cookies[$m[1]] = $m[2];
}
}
if ($status === 0) {
// No answer: say whether the server is gone (and how) rather than leave a bare 0 to the caller.
$st = proc_get_status($proc);
if (!$st['running']) {
throw new TestFailure("$method $uri: no answer, the demo's server ended -- " . ($st['signaled'] ? 'signal ' . $st['termsig'] . ' (11: PHP crashed)' : 'exit ' . $st['exitcode']));
}
}
$location = null;
foreach ($http_response_header ?? [] as $line) {
if (stripos($line, 'Location:') === 0) {
Expand Down
Loading