Skip to content
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

ext/dba/tests: sort expected test output #14962

Merged
merged 4 commits into from
Jul 26, 2024

Conversation

orlitzky
Copy link
Contributor

Fixes #14786 by sorting the fetched rows before echoing them, and updating the expected output to reflect the sort order.

I don't have dbm, ndbm, or Oracle db < 4 to test so hopefully the CI does.

orlitzky added 2 commits July 15, 2024 12:05
Iterating through a database with firstkey() and nextkey() is
guaranteed to retrieve all rows, but apparently not in any particular
order. This is causing a test failure for at least one user, so we
steal the sort() approach from GDBM to ensure that the output is
predictable.
The actual output is now sorted for consistency, so we need to update
the expected output as well. As a nice side effect, some differences
in the expected outputs for the various engines have been eliminated.

Closes phpGH-14786
@cmb69
Copy link
Member

cmb69 commented Jul 15, 2024

I don't have dbm, ndbm, or Oracle db < 4 to test so hopefully the CI does.

Windows won't (only QDBM and LMDB are tested on CI, currently). I haven't checked other OSs.

This test uses a routine from ext/dba that now sorts its (actual)
output, so we have to sort the expected output here as well.
Copy link
Member

@devnexen devnexen left a comment

Choose a reason for hiding this comment

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

ack for pgsql

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.

LGTM, we probably should backport this

After doing some more digging, it looks like GDBM isn't the only
engine where the iteration order with firstkey() and nextkey()
might change unexpectedly.
@orlitzky
Copy link
Contributor Author

Thanks, I added one more commit to clarify the comment.

@Girgias Girgias merged commit 44b0baf into php:master Jul 26, 2024
11 checks passed
devnexen pushed a commit to devnexen/php-src that referenced this pull request Jul 27, 2024
* ext/dba/tests/setup/setup_dba_tests.inc: sort test output

Iterating through a database with firstkey() and nextkey() is
guaranteed to retrieve all rows, but apparently not in any particular
order. This is causing a test failure for at least one user, so we
steal the sort() approach from GDBM to ensure that the output is
predictable.

* ext/dba/tests/dba_*.phpt: sort expected test output

The actual output is now sorted for consistency, so we need to update
the expected output as well. As a nice side effect, some differences
in the expected outputs for the various engines have been eliminated.

Closes phpGH-14786

* ext/pgsql/tests/80_bug14383.phpt: sort expected test output

This test uses a routine from ext/dba that now sorts its (actual)
output, so we have to sort the expected output here as well.

* ext/dba/tests/setup/setup_dba_tests.inc: update comment

After doing some more digging, it looks like GDBM isn't the only
engine where the iteration order with firstkey() and nextkey()
might change unexpectedly.
@nielsdos
Copy link
Member

Alpine hit the sorting issue too: #16902 (comment)
They have disabled the test for that reason.
I think this PR should be backported, WDYT?

@Girgias
Copy link
Member

Girgias commented Nov 25, 2024

Yeah probably should

@nielsdos
Copy link
Member

nielsdos commented Nov 26, 2024

OK. I'll get to it, I'll make a PR soon and if that passes CI merge it.
EDIT: see #16950

nielsdos pushed a commit to nielsdos/php-src that referenced this pull request Nov 26, 2024
Alpine CI regularly fails because of the sorting order of these tests.
See php#14962 (comment)
nielsdos pushed a commit that referenced this pull request Nov 26, 2024
Alpine CI regularly fails because of the sorting order of these tests.
See #14962 (comment)

Closes GH-16950.
nielsdos added a commit that referenced this pull request Nov 26, 2024
* PHP-8.2:
  Backport GH-14962 to stable versions
nielsdos added a commit that referenced this pull request Nov 26, 2024
* PHP-8.3:
  Backport GH-14962 to stable versions
nielsdos added a commit that referenced this pull request Nov 26, 2024
* PHP-8.4:
  Backport GH-14962 to stable versions
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.

ext/dba/tests/dba_gdbm.phpt: test failure due to key ordering
5 participants