Skip to content

Commit e333fc0

Browse files
committed
Strip newlines from exception messages for more concise failures
1 parent fdfbdb1 commit e333fc0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

tests/utils/tools.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,15 @@ function throws($function, $exceptionname, $infunction = null) {
243243
if (strcasecmp($function, $infunction) == 0) {
244244
printf("OK: Got %s thrown from %s\n", $exceptionname, $infunction);
245245
} else {
246-
printf("ALMOST: Got %s - but was thrown in %s, not %s (%s)\n", $exceptionname, $function, $infunction, $e->getMessage());
246+
$message = str_replace(array("\n", "\r", ' ', $e->getMessage()));
247+
printf("ALMOST: Got %s - but was thrown in %s, not %s (%s)\n", $exceptionname, $function, $infunction, $message);
247248
}
248249
return $e->getMessage();
249250
}
250251
printf("OK: Got %s\n", $exceptionname);
251252
} else {
252-
printf("ALMOST: Got %s - expected %s: %s\n", get_class($e), $exceptionname, $e->getMessage());
253+
$message = str_replace(array("\n", "\r", ' ', $e->getMessage()));
254+
printf("ALMOST: Got %s - expected %s: %s\n", get_class($e), $exceptionname, $message);
253255
}
254256
return $e->getMessage();
255257
}

0 commit comments

Comments
 (0)