1
0
mirror of https://github.com/php/php-src.git synced 2026-04-23 16:08:35 +02:00

Merge branch 'PHP-7.4'

* PHP-7.4:
  fix flaky zip tests, order is OS dependent
This commit is contained in:
Joe Watkins
2019-06-12 09:48:09 +02:00
8 changed files with 117 additions and 56 deletions
+11 -5
View File
@@ -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
+11 -5
View File
@@ -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
+13 -7
View File
@@ -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
+12 -6
View File
@@ -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
+14 -8
View File
@@ -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
+14 -8
View File
@@ -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
+23 -12
View File
@@ -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
+19 -5
View File
@@ -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)) {