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
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/dba/tests/dba_flatfile.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ bool(true)
bool(true)
Try to remove key 1 again
bool(false)
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
[key10]name10: Content String 10
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Expand Down
12 changes: 6 additions & 6 deletions ext/dba/tests/dba_gdbm.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key4: Another Content String
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
[key10]name10: Content String 10
name9: Content String 9
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Expand Down Expand Up @@ -81,12 +81,12 @@ bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key4: Another Content String
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
[key10]name10: Content String 10
name9: Content String 9
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Expand Down
8 changes: 4 additions & 4 deletions ext/dba/tests/dba_inifile.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
[key10]:
[key10]name10: Content String 10
[key30]:
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
Total keys: 8
Key 1 exists? N
Key 2 exists? Y
Expand Down
12 changes: 6 additions & 6 deletions ext/dba/tests/dba_ndbm.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key4: Another Content String
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
[key10]name10: Content String 10
name9: Content String 9
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Expand Down Expand Up @@ -82,12 +82,12 @@ bool(true)
bool(true)
Try to remove key 1 again
bool(false)
key4: Another Content String
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
[key10]name10: Content String 10
name9: Content String 9
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Expand Down
8 changes: 4 additions & 4 deletions ext/dba/tests/dba_qdbm.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ bool(true)
bool(true)
Try to remove key 1 again
bool(false)
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
[key10]name10: Content String 10
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Expand Down Expand Up @@ -81,12 +81,12 @@ bool(true)
bool(true)
Try to remove key 1 again
bool(false)
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
[key10]name10: Content String 10
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Expand Down
4 changes: 2 additions & 2 deletions ext/dba/tests/dba_tcadb.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ bool(true)
bool(true)
Try to remove key 1 again
bool(false)
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
[key10]name10: Content String 10
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Expand Down
18 changes: 16 additions & 2 deletions ext/dba/tests/setup/setup_dba_tests.inc
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,28 @@ function run_standard_tests_ex(string $handler, string $name, LockFlag $lock, bo
echo 'Try to remove key 1 again', \PHP_EOL;
var_dump(dba_delete("key1", $db_writer));

// Fetch data
// Fetch and sort data. We sort to guarantee that the output is
// always the same across architectures. GDBM in particular does
// not guarantee that the insert order is the same as the
// iteration order with firstkey() and nextkey(). There is a
// Github report (issue 14786) of this actually happening. GDBM's
// own test suite sorts its output, suggesting that this is a
// reasonable workaround for the issue.
$output = [];
Girgias marked this conversation as resolved.
Show resolved Hide resolved

$key = dba_firstkey($db_writer);
$total_keys = 0;
while ($key) {
echo $key, ': ', dba_fetch($key, $db_writer), \PHP_EOL;
$output[] = $key . ': ' . dba_fetch($key, $db_writer) . \PHP_EOL;
$key = dba_nextkey($db_writer);
$total_keys++;
}

sort($output, SORT_STRING);
foreach ($output as $line) {
echo $line;
}

echo 'Total keys: ', $total_keys, \PHP_EOL;
for ($i = 1; $i < 6; $i++) {
echo "Key $i exists? ", dba_exists("key$i", $db_writer) ? 'Y' : 'N', \PHP_EOL;
Expand Down
4 changes: 2 additions & 2 deletions ext/pgsql/tests/80_bug14383.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ bool(true)
bool(true)
Try to remove key 1 again
bool(false)
[key10]name10: Content String 10
[key30]name30: Content String 30
key2: Content String 2
key4: Another Content String
key5: The last content string
name9: Content String 9
[key10]name10: Content String 10
[key30]name30: Content String 30
Total keys: 6
Key 1 exists? N
Key 2 exists? Y
Expand Down
Loading