Edit report at https://bugs.php.net/bug.php?id=80018&edit=1
ID: 80018 Updated by: ni...@php.net Reported by: jamieliu at google dot com Summary: Tests expect var_dump(FLOAT) to print an integer -Status: Open +Status: Closed Type: Bug Package: Testing related Operating System: All PHP Version: master-Git-2020-08-25 (Git) Block user comment: N Private report: N New Comment: Automatic comment on behalf of jamie...@google.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=c8093fe94a0bfa6aff3ead29744fb20d7c60c07b Log: Fix bug #80018: Tolerate var_dump() printing floats in exponential notation in tests Previous Comments: ------------------------------------------------------------------------ [2020-08-25 20:52:39] jamieliu at google dot com The following patch has been added/updated: Patch Name: 0001-Tolerate-var_dump-printing-floats-in-exponential-not.patch Revision: 1598388759 URL: https://bugs.php.net/patch-display.php?bug=80018&patch=0001-Tolerate-var_dump-printing-floats-in-exponential-not.patch&revision=1598388759 ------------------------------------------------------------------------ [2020-08-25 20:50:01] jamieliu at google dot com My mistake, I though test format strings were interpreted by sscanf(). Using %f instead seems to work (tested by modifying ext/standard/tests/file/disk.phpt to call disk_free_space() and disk_total_space() on a tmpfs mount as described in the original report). ------------------------------------------------------------------------ [2020-08-25 20:32:48] c...@php.net I agree that this should be fixed, but to my knowledge run-tests.php does not support %E, but only %f. Are you using another test runner? ------------------------------------------------------------------------ [2020-08-25 20:09:25] jamieliu at google dot com Description: ------------ Many tests parse the result of var_dump() on a float and expect the result to be an integer: $ find . -name '*.phpt' | xargs grep 'float(%d)' ./Zend/tests/cast_to_double.phpt:float(%d) ./Zend/tests/settype_double.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk.phpt:float(%d) ./ext/standard/tests/file/disk.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_error.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_error.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_error.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_free_space_basic.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/file/disk_total_space_variation.phpt:float(%d) ./ext/standard/tests/general_functions/type.phpt:float(%d) ./ext/standard/tests/general_functions/type.phpt:float(%d) ./ext/standard/tests/general_functions/type.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) ./ext/standard/tests/general_functions/gettype_settype_basic.phpt:float(%d) This is problematic because var_dump() will print sufficiently large numbers in exponential notation. An example in Linux: $ mkdir tmp $ sudo mount -t tmpfs -o size=$((1 << 62)) tmpfs tmp $ ~/src/php-src/sapi/cli/php --version PHP 8.0.0-dev (cli) (built: Aug 25 2020 12:55:38) ( NTS ) Copyright (c) The PHP Group Zend Engine v4.0.0-dev, Copyright (c) Zend Technologies $ ~/src/php-src/sapi/cli/php -r 'var_dump(disk_total_space("tmp"));' float(4.611686018427388E+18) I think every instance of "float(%d)" in such tests could simply be converted to use "float(%E)" instead. Test script: --------------- See description. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80018&edit=1