Skip to content

Commit b95ea80

Browse files
committed
Fix ext/standard tests
1 parent af509ef commit b95ea80

File tree

3 files changed

+213
-21
lines changed

3 files changed

+213
-21
lines changed

patches/8.3/tests.patch

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,20 @@ Subject: Fix tests
1919
is not documented and should be probably resolved in a system-agnostic
2020
way at some point. On Solaris 11.4 unlink() works as expected,
2121
otherwise.
22+
23+
Added helper function to get relative path to fix some tests as they
24+
are creating directories and files all over the place on the system,
25+
when test fails.
2226
---
23-
ext/standard/tests/file/002.phpt | 2 +-
24-
ext/standard/tests/file/copy_variation4.phpt | 11 +++++++++--
25-
ext/zip/tests/gh18431.phpt | 4 ++++
26-
ext/zip/tests/oo_addemptydir_error.phpt | 2 +-
27-
ext/zip/tests/oo_addglob2.phpt | 6 ++++++
28-
ext/zip/tests/oo_encryption.phpt | 6 ++++++
29-
6 files changed, 27 insertions(+), 4 deletions(-)
27+
ext/standard/tests/file/002.phpt | 2 +-
28+
ext/standard/tests/file/copy_variation4.phpt | 11 ++++++++--
29+
ext/standard/tests/file/file.inc | 21 +++++++++++++++++++
30+
.../tests/file/unlink_variation10.phpt | 12 ++++++++---
31+
ext/zip/tests/gh18431.phpt | 4 ++++
32+
ext/zip/tests/oo_addemptydir_error.phpt | 2 +-
33+
ext/zip/tests/oo_addglob2.phpt | 6 ++++++
34+
ext/zip/tests/oo_encryption.phpt | 6 ++++++
35+
8 files changed, 57 insertions(+), 7 deletions(-)
3036

3137
diff --git a/ext/standard/tests/file/002.phpt b/ext/standard/tests/file/002.phpt
3238
index 134f5416fc4..0eb882dc397 100644
@@ -63,6 +69,64 @@ index d467cb4ce9a..99e7ab2ebd6 100644
6369
?>
6470
--FILE--
6571
<?php
72+
diff --git a/ext/standard/tests/file/file.inc b/ext/standard/tests/file/file.inc
73+
index c972784f9da..c7665d2846d 100644
74+
--- a/ext/standard/tests/file/file.inc
75+
+++ b/ext/standard/tests/file/file.inc
76+
@@ -654,4 +654,25 @@ function compare_stats($stat1, $stat2, $fields, $op = "==", $flag = false ) {
77+
return $result;
78+
}
79+
80+
+/**
81+
+ * Get a relative path.
82+
+ */
83+
+function relativePath($from, $to)
84+
+{
85+
+ $from = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $from);
86+
+ $to = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $to);
87+
+
88+
+ $fromArray = explode(DIRECTORY_SEPARATOR, rtrim($from, DIRECTORY_SEPARATOR));
89+
+ $toArray = explode(DIRECTORY_SEPARATOR, rtrim($to, DIRECTORY_SEPARATOR));
90+
+
91+
+ while (count($fromArray) && count($toArray) && ($fromArray[0] == $toArray[0])) {
92+
+ array_shift($fromArray);
93+
+ array_shift($toArray);
94+
+ }
95+
+
96+
+ $relativePath = str_pad('', count($fromArray) * 3, '..' . DIRECTORY_SEPARATOR) . implode(DIRECTORY_SEPARATOR, $toArray);
97+
+
98+
+ return ($relativePath === '') ? '.' : $relativePath;
99+
+}
100+
+
101+
?>
102+
diff --git a/ext/standard/tests/file/unlink_variation10.phpt b/ext/standard/tests/file/unlink_variation10.phpt
103+
index 127b070d23a..a3355a99560 100644
104+
--- a/ext/standard/tests/file/unlink_variation10.phpt
105+
+++ b/ext/standard/tests/file/unlink_variation10.phpt
106+
@@ -10,14 +10,20 @@
107+
?>
108+
--FILE--
109+
<?php
110+
+
111+
+// include the file.inc for function relativePath().
112+
+include(__DIR__ . '/file.inc');
113+
+
114+
echo "*** Testing unlink() : variation ***\n";
115+
116+
-$workDir = "unlinkVar10.tmp";
117+
-$tmpDir = "subDir.tmp";
118+
+$cwd = getcwd();
119+
+$relativePath = relativePath($cwd, __DIR__);
120+
+
121+
+$workDir = $relativePath . '/unlinkVar10.tmp';
122+
+$tmpDir = $relativePath . '/subDir.tmp';
123+
$dirToLinkTo = $workDir.'/'."linkme.tmp";
124+
125+
mkdir($workDir);
126+
-$cwd = getcwd();
127+
mkdir($dirToLinkTo);
128+
129+
$dirs = array(
66130
diff --git a/ext/zip/tests/gh18431.phpt b/ext/zip/tests/gh18431.phpt
67131
index d4eb89c36c6..dcd7db6f400 100644
68132
--- a/ext/zip/tests/gh18431.phpt

patches/8.4/tests.patch

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ Subject: Fix tests
1818
is not documented and should be probably resolved in a system-agnostic
1919
way at some point. On Solaris 11.4 unlink() works as expected,
2020
otherwise.
21+
22+
Added helper function to get relative path to fix some tests as they
23+
are creating directories and files all over the place on the system,
24+
when test fails.
2125
---
22-
ext/dom/tests/dom_xinclude.phpt | 4 ++--
23-
ext/standard/tests/file/copy_variation4.phpt | 12 +++++++++---
24-
ext/zip/tests/gh18431.phpt | 4 ++++
25-
ext/zip/tests/oo_addemptydir_error.phpt | 2 +-
26-
ext/zip/tests/oo_addglob2.phpt | 6 ++++++
27-
ext/zip/tests/oo_encryption.phpt | 6 ++++++
28-
6 files changed, 28 insertions(+), 6 deletions(-)
26+
ext/dom/tests/dom_xinclude.phpt | 4 ++--
27+
ext/standard/tests/file/copy_variation4.phpt | 12 ++++++++---
28+
ext/standard/tests/file/file.inc | 21 +++++++++++++++++++
29+
.../tests/file/unlink_variation10.phpt | 12 ++++++++---
30+
ext/zip/tests/gh18431.phpt | 4 ++++
31+
ext/zip/tests/oo_addemptydir_error.phpt | 2 +-
32+
ext/zip/tests/oo_addglob2.phpt | 6 ++++++
33+
ext/zip/tests/oo_encryption.phpt | 6 ++++++
34+
8 files changed, 58 insertions(+), 9 deletions(-)
2935

3036
diff --git a/ext/dom/tests/dom_xinclude.phpt b/ext/dom/tests/dom_xinclude.phpt
3137
index 0dfeb2dfb4a..410431de877 100644
@@ -67,6 +73,64 @@ index d467cb4ce9a..f31a1ddb117 100644
6773
--FILE--
6874
<?php
6975
/* Test copy() function: In creation of destination file names with empty string, nulls & bools
76+
diff --git a/ext/standard/tests/file/file.inc b/ext/standard/tests/file/file.inc
77+
index c972784f9da..c7665d2846d 100644
78+
--- a/ext/standard/tests/file/file.inc
79+
+++ b/ext/standard/tests/file/file.inc
80+
@@ -654,4 +654,25 @@ function compare_stats($stat1, $stat2, $fields, $op = "==", $flag = false ) {
81+
return $result;
82+
}
83+
84+
+/**
85+
+ * Get a relative path.
86+
+ */
87+
+function relativePath($from, $to)
88+
+{
89+
+ $from = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $from);
90+
+ $to = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $to);
91+
+
92+
+ $fromArray = explode(DIRECTORY_SEPARATOR, rtrim($from, DIRECTORY_SEPARATOR));
93+
+ $toArray = explode(DIRECTORY_SEPARATOR, rtrim($to, DIRECTORY_SEPARATOR));
94+
+
95+
+ while (count($fromArray) && count($toArray) && ($fromArray[0] == $toArray[0])) {
96+
+ array_shift($fromArray);
97+
+ array_shift($toArray);
98+
+ }
99+
+
100+
+ $relativePath = str_pad('', count($fromArray) * 3, '..' . DIRECTORY_SEPARATOR) . implode(DIRECTORY_SEPARATOR, $toArray);
101+
+
102+
+ return ($relativePath === '') ? '.' : $relativePath;
103+
+}
104+
+
105+
?>
106+
diff --git a/ext/standard/tests/file/unlink_variation10.phpt b/ext/standard/tests/file/unlink_variation10.phpt
107+
index 127b070d23a..a3355a99560 100644
108+
--- a/ext/standard/tests/file/unlink_variation10.phpt
109+
+++ b/ext/standard/tests/file/unlink_variation10.phpt
110+
@@ -10,14 +10,20 @@
111+
?>
112+
--FILE--
113+
<?php
114+
+
115+
+// include the file.inc for function relativePath().
116+
+include(__DIR__ . '/file.inc');
117+
+
118+
echo "*** Testing unlink() : variation ***\n";
119+
120+
-$workDir = "unlinkVar10.tmp";
121+
-$tmpDir = "subDir.tmp";
122+
+$cwd = getcwd();
123+
+$relativePath = relativePath($cwd, __DIR__);
124+
+
125+
+$workDir = $relativePath . '/unlinkVar10.tmp';
126+
+$tmpDir = $relativePath . '/subDir.tmp';
127+
$dirToLinkTo = $workDir.'/'."linkme.tmp";
128+
129+
mkdir($workDir);
130+
-$cwd = getcwd();
131+
mkdir($dirToLinkTo);
132+
133+
$dirs = array(
70134
diff --git a/ext/zip/tests/gh18431.phpt b/ext/zip/tests/gh18431.phpt
71135
index d4eb89c36c6..dcd7db6f400 100644
72136
--- a/ext/zip/tests/gh18431.phpt

patches/8.5/tests.patch

Lines changed: 71 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@ Subject: Fix tests
1818
is not documented and should be probably resolved in a system-agnostic
1919
way at some point. On Solaris 11.4 unlink() works as expected,
2020
otherwise.
21+
22+
Added helper function to get relative path to fix some tests as they
23+
are creating directories and files all over the place on the system,
24+
when test fails.
2125
---
22-
ext/dom/tests/dom_xinclude.phpt | 4 ++--
23-
ext/standard/tests/file/copy_variation4.phpt | 12 +++++++++---
24-
ext/zip/tests/gh18431.phpt | 4 ++++
25-
ext/zip/tests/oo_addemptydir_error.phpt | 2 +-
26-
ext/zip/tests/oo_addglob2.phpt | 6 ++++++
27-
ext/zip/tests/oo_encryption.phpt | 6 ++++++
28-
6 files changed, 28 insertions(+), 6 deletions(-)
26+
ext/dom/tests/dom_xinclude.phpt | 4 ++--
27+
ext/standard/tests/file/copy_variation4.phpt | 12 ++++++++---
28+
ext/standard/tests/file/file.inc | 21 +++++++++++++++++++
29+
.../tests/file/unlink_variation10.phpt | 12 ++++++++---
30+
ext/zip/tests/gh18431.phpt | 4 ++++
31+
ext/zip/tests/oo_addemptydir_error.phpt | 2 +-
32+
ext/zip/tests/oo_addglob2.phpt | 6 ++++++
33+
ext/zip/tests/oo_encryption.phpt | 6 ++++++
34+
8 files changed, 58 insertions(+), 9 deletions(-)
2935

3036
diff --git a/ext/dom/tests/dom_xinclude.phpt b/ext/dom/tests/dom_xinclude.phpt
3137
index 0dfeb2dfb4a..410431de877 100644
@@ -67,6 +73,64 @@ index d467cb4ce9a..f31a1ddb117 100644
6773
--FILE--
6874
<?php
6975
/* Test copy() function: In creation of destination file names with empty string, nulls & bools
76+
diff --git a/ext/standard/tests/file/file.inc b/ext/standard/tests/file/file.inc
77+
index c972784f9da..c7665d2846d 100644
78+
--- a/ext/standard/tests/file/file.inc
79+
+++ b/ext/standard/tests/file/file.inc
80+
@@ -654,4 +654,25 @@ function compare_stats($stat1, $stat2, $fields, $op = "==", $flag = false ) {
81+
return $result;
82+
}
83+
84+
+/**
85+
+ * Get a relative path.
86+
+ */
87+
+function relativePath($from, $to)
88+
+{
89+
+ $from = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $from);
90+
+ $to = str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $to);
91+
+
92+
+ $fromArray = explode(DIRECTORY_SEPARATOR, rtrim($from, DIRECTORY_SEPARATOR));
93+
+ $toArray = explode(DIRECTORY_SEPARATOR, rtrim($to, DIRECTORY_SEPARATOR));
94+
+
95+
+ while (count($fromArray) && count($toArray) && ($fromArray[0] == $toArray[0])) {
96+
+ array_shift($fromArray);
97+
+ array_shift($toArray);
98+
+ }
99+
+
100+
+ $relativePath = str_pad('', count($fromArray) * 3, '..' . DIRECTORY_SEPARATOR) . implode(DIRECTORY_SEPARATOR, $toArray);
101+
+
102+
+ return ($relativePath === '') ? '.' : $relativePath;
103+
+}
104+
+
105+
?>
106+
diff --git a/ext/standard/tests/file/unlink_variation10.phpt b/ext/standard/tests/file/unlink_variation10.phpt
107+
index 127b070d23a..a3355a99560 100644
108+
--- a/ext/standard/tests/file/unlink_variation10.phpt
109+
+++ b/ext/standard/tests/file/unlink_variation10.phpt
110+
@@ -10,14 +10,20 @@
111+
?>
112+
--FILE--
113+
<?php
114+
+
115+
+// include the file.inc for function relativePath().
116+
+include(__DIR__ . '/file.inc');
117+
+
118+
echo "*** Testing unlink() : variation ***\n";
119+
120+
-$workDir = "unlinkVar10.tmp";
121+
-$tmpDir = "subDir.tmp";
122+
+$cwd = getcwd();
123+
+$relativePath = relativePath($cwd, __DIR__);
124+
+
125+
+$workDir = $relativePath . '/unlinkVar10.tmp';
126+
+$tmpDir = $relativePath . '/subDir.tmp';
127+
$dirToLinkTo = $workDir.'/'."linkme.tmp";
128+
129+
mkdir($workDir);
130+
-$cwd = getcwd();
131+
mkdir($dirToLinkTo);
132+
133+
$dirs = array(
70134
diff --git a/ext/zip/tests/gh18431.phpt b/ext/zip/tests/gh18431.phpt
71135
index d4eb89c36c6..dcd7db6f400 100644
72136
--- a/ext/zip/tests/gh18431.phpt

0 commit comments

Comments
 (0)