com php-src: fix flaky zip tests, order is OS dependent: ext/zip/tests/bug64342_1-mb.phpt ext/zip/test s/bug64342_1.phpt ext/zip/tests/oo_addempty
dir.phpt ext/zip/tests/oo_addfile.phpt ext/zip/tests/ oo_addglob.phpt ext/zip/tests/oo_addpattern.phpt ex t/zip/tests/oo_rename.phpt
ext/zip/tests/utils.inc
| From: | Joe Watkins | Date: | Wed, 12 Jun 2019 07:47:47 +0000 |
| Subject: | com php-src: fix flaky zip tests, order is OS dependent: ext/zip/tests/bug64342_1-mb.phpt ext/zip/test s/bug64342_1.phpt ext/zip/tests/oo_addempty dir.phpt ext/zip/tests/oo_addfile.phpt ext/zip/tests/ oo_addglob.phpt ext/zip/tests/oo_addpattern.phpt ex t/zip/tests/oo_rename.phpt ext/zip/tests/utils.inc |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-106697@lists.php.net to get a copy of this message | ||
Commit: e2eb1ee1e3c4bc66f81bde2c5e26dd12f549efb2
Author: Joe Watkins <krakjoe@php.net> Wed, 12 Jun 2019 09:47:47 +0200
Parents: 66bd7875f85fb74695ec9fa98bba88d114580b9f
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=e2eb1ee1e3c4bc66f81bde2c5e26dd12f549efb2
Log:
fix flaky zip tests, order is OS dependent
Changed paths:
M ext/zip/tests/bug64342_1-mb.phpt
M ext/zip/tests/bug64342_1.phpt
M ext/zip/tests/oo_addemptydir.phpt
M ext/zip/tests/oo_addfile.phpt
M ext/zip/tests/oo_addglob.phpt
M ext/zip/tests/oo_addpattern.phpt
M ext/zip/tests/oo_rename.phpt
M ext/zip/tests/utils.inc
Diff:
diff --git a/ext/zip/tests/bug64342_1-mb.phpt b/ext/zip/tests/bug64342_1-mb.phpt
index 611a416..6b14c7f 100644
--- a/ext/zip/tests/bug64342_1-mb.phpt
+++ b/ext/zip/tests/bug64342_1-mb.phpt
@@ -21,7 +21,16 @@ if (!$zip->addFile($dirname . 'cant_find_me.txt',
'test.php')) {
echo "failed\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
echo "failed\n";
@@ -30,7 +39,4 @@ if ($zip->status == ZIPARCHIVE::ER_OK) {
?>
--EXPECT--
failed
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
+OK
diff --git a/ext/zip/tests/bug64342_1.phpt b/ext/zip/tests/bug64342_1.phpt
index 84cd5db..0baf4c8 100644
--- a/ext/zip/tests/bug64342_1.phpt
+++ b/ext/zip/tests/bug64342_1.phpt
@@ -21,7 +21,16 @@ if (!$zip->addFile($dirname . 'cant_find_me.txt',
'test.php')) {
echo "failed\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
echo "failed\n";
@@ -30,7 +39,4 @@ if ($zip->status == ZIPARCHIVE::ER_OK) {
?>
--EXPECT--
failed
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
+OK
diff --git a/ext/zip/tests/oo_addemptydir.phpt b/ext/zip/tests/oo_addemptydir.phpt
index e639529..efaa354 100644
--- a/ext/zip/tests/oo_addemptydir.phpt
+++ b/ext/zip/tests/oo_addemptydir.phpt
@@ -20,16 +20,22 @@ if (!$zip->open($file)) {
$zip->addEmptyDir('emptydir');
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt",
+ "emptydir/"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
- echo "failed\n";
+ echo "failed3\n";
}
@unlink($file);
?>
--EXPECT--
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
-4 emptydir/
+OK
diff --git a/ext/zip/tests/oo_addfile.phpt b/ext/zip/tests/oo_addfile.phpt
index 7592f5b..271642b 100644
--- a/ext/zip/tests/oo_addfile.phpt
+++ b/ext/zip/tests/oo_addfile.phpt
@@ -21,7 +21,17 @@ if (!$zip->addFile($dirname . 'utils.inc', 'test.php')) {
echo "failed\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt",
+ "test.php"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
echo "failed\n";
@@ -29,8 +39,4 @@ if ($zip->status == ZIPARCHIVE::ER_OK) {
@unlink($file);
?>
--EXPECT--
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
-4 test.php
+OK
diff --git a/ext/zip/tests/oo_addglob.phpt b/ext/zip/tests/oo_addglob.phpt
index 0699797..b20d4ab 100644
--- a/ext/zip/tests/oo_addglob.phpt
+++ b/ext/zip/tests/oo_addglob.phpt
@@ -29,10 +29,21 @@ if (!$zip->addGlob($dirname . '*.{txt,baz}', GLOB_BRACE, $options))
{
echo "failed1\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt",
+ "baz/foo.txt",
+ "baz/bar..baz"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
- echo "failed2\n";
+ echo "failed3\n";
}
?>
--CLEAN--
@@ -44,9 +55,4 @@ unlink($dirname . 'bar.baz');
rmdir($dirname);
?>
--EXPECT--
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
-4 baz/foo.txt
-5 baz/bar.baz
+OK
diff --git a/ext/zip/tests/oo_addpattern.phpt b/ext/zip/tests/oo_addpattern.phpt
index a66ecba..fe1a573 100644
--- a/ext/zip/tests/oo_addpattern.phpt
+++ b/ext/zip/tests/oo_addpattern.phpt
@@ -30,10 +30,21 @@ if (!$zip->addPattern('/\.txt$/', $dir, $options)) {
echo "failed\n";
}
if ($zip->status == ZIPARCHIVE::ER_OK) {
- dump_entries_name($zip);
+ if (!verify_entries($zip, [
+ "bar",
+ "foobar/",
+ "foobar/baz",
+ "entry1.txt",
+ "baz/foo.txt",
+ "baz/bar.txt"
+ ])) {
+ echo "failed\n";
+ } else {
+ echo "OK";
+ }
$zip->close();
} else {
- echo "failed\n";
+ echo "failed3\n";
}
?>
--CLEAN--
@@ -45,9 +56,4 @@ unlink($dirname .. 'bar.txt');
rmdir($dirname);
?>
--EXPECT--
-0 bar
-1 foobar/
-2 foobar/baz
-3 entry1.txt
-4 baz/bar.txt
-5 baz/foo.txt
+OK
diff --git a/ext/zip/tests/oo_rename.phpt b/ext/zip/tests/oo_rename.phpt
index 1ec661e..518fe35 100644
--- a/ext/zip/tests/oo_rename.phpt
+++ b/ext/zip/tests/oo_rename.phpt
@@ -23,17 +23,24 @@ $zip->addFromString('dir/entry2.txt', 'entry #2');
if (!$zip->status == ZIPARCHIVE::ER_OK) {
var_dump($zip);
- echo "failed\n";
+ echo "failed2\n";
}
$zip->close();
if (!$zip->open($file)) {
- exit('failed');
+ exit('failed3');
}
-dump_entries_name($zip);
-echo "\n";
+if (!verify_entries($zip, [
+ "entry1.txt",
+ "entry2.txt",
+ "dir/entry2.txt"
+])) {
+ exit("failed4");
+} else {
+ echo "OK\n";
+}
if (!$zip->renameIndex(0, 'ren_entry1.txt')) {
echo "failed index 0\n";
@@ -42,16 +49,20 @@ if (!$zip->renameIndex(0, 'ren_entry1.txt')) {
if (!$zip->renameName('dir/entry2.txt', 'dir3/ren_entry2.txt')) {
echo "failed name dir/entry2.txt\n";
}
-dump_entries_name($zip);
+
+if (!verify_entries($zip, [
+ "ren_entry1.txt",
+ "entry2.txt",
+ "dir3/ren_entry2.txt"
+])) {
+ exit("failed5");
+} else {
+ echo "OK\n";
+}
$zip->close();
@unlink($file);
?>
--EXPECT--
-0 entry1.txt
-1 entry2.txt
-2 dir/entry2.txt
-
-0 ren_entry1.txt
-1 entry2.txt
-2 dir3/ren_entry2.txt
+OK
+OK
diff --git a/ext/zip/tests/utils.inc b/ext/zip/tests/utils.inc
index c7cd2a8..f44ab3a 100644
--- a/ext/zip/tests/utils.inc
+++ b/ext/zip/tests/utils.inc
@@ -1,11 +1,25 @@
<?php
+function verify_entries($zip, $entries = []) {
+ $verified = true;
+ $found = [];
-function dump_entries_name($z) {
- for($i=0; $i<$z->numFiles; $i++) {
- $sb = $z->statIndex($i);
- echo $i . ' ' . $sb['name'] . "\n";
- }
+ for ($index = 0; $index < $zip->numFiles; $index++) {
+ $stat = $zip->statIndex($index);
+
+ if (!in_array($stat["name"], $entries)) {
+ $verified = false;
+ }
+
+ $found[] = $stat["name"];
+ }
+
+ if (!$verified) {
+ var_dump($found);
+ }
+
+ return $verified;
}
+
/* recursively remove a directoryy */
function rmdir_rf($dir) {
if ($handle = opendir($dir)) {