Skip to content

Failure to resolve PDO as required extension in tests #12878

Closed

Description

@ltrk2

Description

The following code:

--TEST--
test
--EXTENSIONS--
PDO
--FILE--
<?php
print("hello");
?>
--EXPECTF--
hello

When executed using the test runner as

php -n generated/run-tests.php -n -P -q test.phpt

Resulted in this output:

=====================================================================
Running selected tests.
SKIP test [test.phpt] reason: Required extension missing: PDO
=====================================================================
Number of tests :     1                 0
Tests skipped   :     1 (100.0%) --------
Tests warned    :     0 (  0.0%) (  0.0%)
Tests failed    :     0 (  0.0%) (  0.0%)
Tests passed    :     0 (  0.0%) (  0.0%)
---------------------------------------------------------------------
Time taken      :     0 seconds
=====================================================================

But I expected this output instead:

=====================================================================
Running selected tests.
=====================================================================
Number of tests :     1                 1
Tests skipped   :     0 (  0.0%) --------
Tests warned    :     0 (  0.0%) (  0.0%)
Tests failed    :     0 (  0.0%) (  0.0%)
Tests passed    :     1 (100.0%) (100.0%)
---------------------------------------------------------------------
Time taken      :     0 seconds
=====================================================================

It works fine in PHP 8.2. I'd gladly just use pdo, but we have a set of tests that run on versions 7.0 through 8.3 and the lower versions only support PDO.

What are your thoughts regarding this?

PHP Version

PHP 8.3.0

Operating System

Ubuntu 22.04

Activity

  1. SakiTakamachi commented on Dec 6, 2023

    @SakiTakamachi
    Member

    Is it not the phpt that comes with php-src, but the phpt that you created yourself?

    If so, you can implement skip by writing:

    --TEST--
    test
    --SKIPIF--
    <?php if (!extension_loaded('pdo')) die('skip pdo extension not loaded'); ?>
    --FILE--
    <?php
    print("hello");
    ?>
    --EXPECTF--
    hello
    
  2. ltrk2 commented on Dec 6, 2023

    @ltrk2
    Author

    @SakiTakamachi that's a viable option indeed, thanks for the suggestion!

    Do you perhaps know what might be causing this difference between 8.2 and 8.3?

  3. SakiTakamachi commented on Dec 6, 2023

    @SakiTakamachi
    Member

    @ltrk2
    In my environment, "PDO" is not found even in 8.2...

  4. ltrk2 commented on Dec 6, 2023

    @ltrk2
    Author

    I see.. the exact version I'm using is 8.2.4. Perhaps the change occurred some time after that. Both versions (8.3.0 & 8.2.4) are built using the same process from source on my end.

  5. SakiTakamachi commented on Dec 6, 2023

    @SakiTakamachi
    Member

    Excuse me, I seem to have made a mistake in some operation. Reproduced in 8.2.

    I identified the commit that made this change.
    commit: b401001
    PR: #8363

    Previously, even if we passed "PDO", it would be converted to lower case and then compared, but it seems that the process of converting to lower case has disappeared.

  6. ltrk2 commented on Dec 7, 2023

    @ltrk2
    Author

    @SakiTakamachi Indeed.. thank you for finding this! It all makes sense now. I greatly appreciate your help in figuring this out.

    I also found the answer to another strange occurrence: using PHP 8.0 and below the EXTENSIONS section behaves differently because it was slightly repurposed in 6c9a056 which first made it into PHP 8.1.

    All in all, my options are either using SKIPIF or patching run-tests.php as generated by old versions, since all of them are out of support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions