Skip to content

Commit 87d9e02

Browse files
committed
Don't truncate subsecond precision in run-tests.php JUNIT output
When run-tests.php has been typed[1], the type of `$time` has been chosen to be `int`. This, however, leads to truncation, and the somewhat relevant subsecond precision is lost. We fix that by changing the type to `float`, although `int|string` would be more appropriate, but requires PHP ≥ 7.4.0. Another option would be to move the `number_format()` formatting into `junit_mark_test_as()`. [1] <11274f5> Closes GH-7836.
1 parent ee61094 commit 87d9e02

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

run-tests.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3478,7 +3478,7 @@ function junit_mark_test_as(
34783478
$type,
34793479
string $file_name,
34803480
string $test_name,
3481-
?int $time = null,
3481+
?float $time = null,
34823482
string $message = '',
34833483
string $details = ''
34843484
): void {
@@ -3533,15 +3533,15 @@ function junit_mark_test_as(
35333533
$JUNIT['files'][$file_name]['xml'] .= "</testcase>\n";
35343534
}
35353535

3536-
function junit_suite_record(string $suite, string $param, int $value = 1): void
3536+
function junit_suite_record(string $suite, string $param, float $value = 1): void
35373537
{
35383538
global $JUNIT;
35393539

35403540
$JUNIT[$param] += $value;
35413541
$JUNIT['suites'][$suite][$param] += $value;
35423542
}
35433543

3544-
function junit_get_timer(string $file_name): int
3544+
function junit_get_timer(string $file_name): float
35453545
{
35463546
global $JUNIT;
35473547
if (!junit_enabled()) {

0 commit comments

Comments
 (0)