From ed284ff4d05a1734f21162cb1a3863331bbacc70 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Mon, 27 Dec 2021 13:44:53 +0100 Subject: [PATCH] Don't truncate subsecond precision in run-tests.php JUNIT output MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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] --- run-tests.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/run-tests.php b/run-tests.php index 333b6058fbed1..709c657c2f0fe 100755 --- a/run-tests.php +++ b/run-tests.php @@ -3478,7 +3478,7 @@ function junit_mark_test_as( $type, string $file_name, string $test_name, - ?int $time = null, + ?float $time = null, string $message = '', string $details = '' ): void { @@ -3533,7 +3533,7 @@ function junit_mark_test_as( $JUNIT['files'][$file_name]['xml'] .= "\n"; } -function junit_suite_record(string $suite, string $param, int $value = 1): void +function junit_suite_record(string $suite, string $param, float $value = 1): void { global $JUNIT; @@ -3541,7 +3541,7 @@ function junit_suite_record(string $suite, string $param, int $value = 1): void $JUNIT['suites'][$suite][$param] += $value; } -function junit_get_timer(string $file_name): int +function junit_get_timer(string $file_name): float { global $JUNIT; if (!junit_enabled()) {