Skip to content

Failure to resolve PDO as required extension in tests #12878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
ltrk2 opened this issue Dec 6, 2023 · 6 comments
Closed

Failure to resolve PDO as required extension in tests #12878

ltrk2 opened this issue Dec 6, 2023 · 6 comments

Comments

@ltrk2
Copy link

ltrk2 commented Dec 6, 2023

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

@SakiTakamachi
Copy link
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

@ltrk2
Copy link
Author

ltrk2 commented Dec 6, 2023

@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?

@SakiTakamachi
Copy link
Member

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

@ltrk2
Copy link
Author

ltrk2 commented Dec 6, 2023

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.

@SakiTakamachi
Copy link
Member

SakiTakamachi commented Dec 6, 2023

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.

@ltrk2
Copy link
Author

ltrk2 commented Dec 7, 2023

@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.

@ltrk2 ltrk2 closed this as completed Dec 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants