Skip to content

[Test] Optimized pdo_mysql tests #12555

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

Conversation

SakiTakamachi
Copy link
Member

@SakiTakamachi SakiTakamachi commented Oct 29, 2023

[wip]

PDO's test specifications, especially the config, are too different, so I'm trying to unify them to some extent and make the tests easier to understand. However, changing everything at once would result in too many diffs, so I started with pdo_mysql first.

  • Since the inc files are buried in tests and I don't always know where they are, I organized them into a directory.
  • config.inc used to get and set environment variables at the same time, but setting has been separated into init.inc. This allows you to load config.inc if you simply want environment variable values ​​without worrying about side effects.
  • I have summarized some skip conditions into MySQLPDOTest methods so that they can be reused.

Other fixes

  • Since some tests used PDOTest and others used MySQLPDOTest, we unified them into MySQLPDOTest.
  • common.phpt is no longer needed, so I removed it. (I'm thinking of deleting common.phpt for other PDO drivers as well.)
  • For some tests that only use one table, the table name has been unified to "test".
  • Added --CLEAN-- to tests that need to be cleaned up but have not been cleaned up.
  • table.inc is not used so I deleted it.

The number of files is still quite large, so if you would like to split it up further, please let me know.

Comment on lines 17 to 26
$createSql = "CREATE TABLE `test` (
`count` bigint(20) unsigned NOT NULL DEFAULT '0'
)";

$db->exec('drop table if exists bug53551');
$db->exec('drop table if exists test');
$db->exec($createSql);
$db->exec("insert into bug53551 set `count` = 1 ");
$db->exec("insert into test set `count` = 1 ");
$db->exec("SET sql_mode = 'Traditional'");
$sql = 'UPDATE bug53551 SET `count` = :count';
$sql = 'UPDATE test SET `count` = :count';
$stmt = $db->prepare($sql);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not do this, each test should use it's own table so we can run them in parallel, and this also goes against #11879

Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This clashes with #11879 and from a glance most of this should be dropped as it is using a common table for all tests which is something we are actively worked to undo as it prevents running tests in parallel.

@SakiTakamachi SakiTakamachi force-pushed the tests/optimize-pdo-mysql-tests branch from 4b16c62 to a6e29ab Compare October 29, 2023 17:39
@SakiTakamachi
Copy link
Member Author

@Girgias
Oops, I overlooked that PR. Undo the table name change.

@SakiTakamachi SakiTakamachi force-pushed the tests/optimize-pdo-mysql-tests branch from a6e29ab to b2df20d Compare October 29, 2023 17:52
@SakiTakamachi
Copy link
Member Author

SakiTakamachi commented Oct 29, 2023

@Girgias
I undone the table name change.


Maybe I should wait until the changes in #11879 are fully completed.

@SakiTakamachi SakiTakamachi force-pushed the tests/optimize-pdo-mysql-tests branch 2 times, most recently from 4c86a38 to 64ba080 Compare October 29, 2023 18:33
@SakiTakamachi SakiTakamachi force-pushed the tests/optimize-pdo-mysql-tests branch from 64ba080 to f3280f7 Compare October 29, 2023 23:01
Comment on lines +2 to 4
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.inc');
require_once(dirname(__FILE__) . str_replace('/', DIRECTORY_SEPARATOR, '/../../../../ext/pdo/tests/pdo_test.inc'));

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.inc');
require_once(dirname(__FILE__) . str_replace('/', DIRECTORY_SEPARATOR, '/../../../../ext/pdo/tests/pdo_test.inc'));
require_once __DIR__ . DIRECTORY_SEPARATOR . 'init.inc';
require_once dirname(__DIR__, 4) . '/ext/pdo/tests/pdo_test.inc';

No need to convert paths for Windows, also do not use parenthesis around require as it is not a function but a language construct and the semantics are slightly different.

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

Successfully merging this pull request may close these issues.

2 participants