Commit: 7de71d947b1ba0c3b4326fbbc0781d91100fab0c Author: Holly Li (WIPRO LIMITED) <v-hu...@microsoft.com> Thu, 16 May 2019 04:31:10 +0200 Committer: Christoph M. Becker <cmbecke...@gmx.de> Thu, 16 May 2019 09:36:35 +0200 Parents: f110243fba1379413a205e3beb7e46623f496dc2 Branches: master
Link: http://git.php.net/?p=pftt2.git;a=commitdiff;h=7de71d947b1ba0c3b4326fbbc0781d91100fab0c Log: Add {TMP} support on PFTT (closes #27) also replace regex replace with string replace Bugs: https://bugs.php.net/27 Changed paths: M src/com/mostc/pftt/model/core/PhpBuild.java M src/com/mostc/pftt/model/core/PhpIni.java M src/com/mostc/pftt/model/core/PhptTestCase.java M src/com/mostc/pftt/scenario/FileSystemScenario.java Diff: diff --git a/src/com/mostc/pftt/model/core/PhpBuild.java b/src/com/mostc/pftt/model/core/PhpBuild.java index 036999c..238b601 100644 --- a/src/com/mostc/pftt/model/core/PhpBuild.java +++ b/src/com/mostc/pftt/model/core/PhpBuild.java @@ -367,8 +367,9 @@ public class PhpBuild extends SAPIManager { return ini; } String path = getDefaultPhpIniPath(fs, host, type); + String tmp = host.getTempDir(); if (host.mExists(path)) - ini = new PhpIni(host.mGetContents(path), build_path); + ini = new PhpIni(host.mGetContents(path), build_path, tmp); else ini = RequiredExtensionsSmokeTest.createDefaultIniCopy(cm, fs, host, this); diff --git a/src/com/mostc/pftt/model/core/PhpIni.java b/src/com/mostc/pftt/model/core/PhpIni.java index 98297e4..7354eca 100644 --- a/src/com/mostc/pftt/model/core/PhpIni.java +++ b/src/com/mostc/pftt/model/core/PhpIni.java @@ -9,6 +9,8 @@ import java.util.regex.Pattern; import javax.annotation.Nullable; +import org.apache.commons.lang.SystemUtils; + import com.github.mattficken.io.ArrayUtil; import com.github.mattficken.io.StringUtil; import com.mostc.pftt.host.AHost; @@ -121,7 +123,7 @@ public class PhpIni { } public PhpIni(String ini_str) { - this(ini_str, ""); + this(ini_str, "", ""); // "" => replace {PWD} with "" } @@ -140,15 +142,15 @@ public class PhpIni { return o; } - static final Pattern PAT_PWD = Pattern.compile("\\{PWD\\}"); - static final Pattern PAT_BS = Pattern.compile("\\\\"); - static final Pattern PAT_FS = Pattern.compile("/"); - public PhpIni(String ini_str, String pwd) { + static final String PH_PWD = "{PWD}"; + static final String PH_TMP = "{TMP}"; + public PhpIni(String ini_str, String pwd, String tmp) { this(); - if (pwd!=null&&ini_str.contains("{PWD}")) { - ini_str = StringUtil.replaceAll(PAT_PWD, pwd, ini_str); - - // CRITICAL: ensure that correct \\s are used for paths on Windows + if (pwd!=null&&ini_str.contains(PH_PWD)) { + ini_str = ini_str.replace(PH_PWD, pwd); + } + if (tmp!=null&&ini_str.contains(PH_TMP)) { + ini_str = ini_str.replace(PH_TMP, tmp); } // read ini string, line by line for (String line : StringUtil.splitLines(ini_str)) { diff --git a/src/com/mostc/pftt/model/core/PhptTestCase.java b/src/com/mostc/pftt/model/core/PhptTestCase.java index 2712846..9ebb82e 100644 --- a/src/com/mostc/pftt/model/core/PhptTestCase.java +++ b/src/com/mostc/pftt/model/core/PhptTestCase.java @@ -1,5 +1,6 @@ package com.mostc.pftt.model.core; +import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.io.PrintWriter; @@ -124,7 +125,7 @@ public class PhptTestCase extends TestCase { private String bork_info, unsupported_info; private PhptTestCase parent; private WeakReference<PhpIni> ini; - private WeakReference<String> ini_pwd, contents; + private WeakReference<String> ini_pwd, ini_tmp, contents; private SoftReference<RE> expected_re; private PhptSourceTestPack test_pack; private CharsetICU common_charset; @@ -394,21 +395,28 @@ public class PhptTestCase extends TestCase { public PhpIni getINI(PhptActiveTestPack active_test_pack, AHost host) { PhpIni this_ini; String this_ini_pwd; - String ini_pwd = active_test_pack.getStorageDirectory()+"/"+FileSystemScenario.dirname(name); - if (this.ini_pwd!=null) { + String this_ini_tmp; + String dirName = FileSystemScenario.osDirName(name); + String ini_pwd = active_test_pack.getStorageDirectory()+File.separator+dirName; + String ini_tmp = host.getTempDir(); + if (this.ini_pwd!=null && this.ini_tmp != null) { this_ini_pwd = this.ini_pwd.get(); - if (this_ini_pwd != null && this_ini_pwd.equals(ini_pwd)) { + this_ini_tmp = this.ini_tmp.get(); + if (this_ini_pwd != null && this_ini_pwd.equals(ini_pwd) + && this_ini_tmp !=null && this_ini_tmp.equals(ini_tmp)) { // cache ini (speed), but replace it in case the PWD changes if (this.ini!=null) { this_ini = this.ini.get(); if (this_ini!=null) return this_ini; } - } + } } - + this_ini_pwd = ini_pwd; + this_ini_tmp = ini_tmp; this.ini_pwd = new WeakReference<String>(this_ini_pwd); + this.ini_tmp = new WeakReference<String>(this_ini_tmp); String ini_str = section_text.get(EPhptSection.INI); if (StringUtil.isEmpty(ini_str)) { @@ -416,8 +424,8 @@ public class PhptTestCase extends TestCase { this.ini = new WeakReference<PhpIni>(this_ini); return this_ini; } - - this_ini = new PhpIni(ini_str, ini_pwd); + + this_ini = new PhpIni(ini_str, ini_pwd, ini_tmp); this.ini = new WeakReference<PhpIni>(this_ini); return this_ini; } diff --git a/src/com/mostc/pftt/scenario/FileSystemScenario.java b/src/com/mostc/pftt/scenario/FileSystemScenario.java index cf58e31..61214ab 100644 --- a/src/com/mostc/pftt/scenario/FileSystemScenario.java +++ b/src/com/mostc/pftt/scenario/FileSystemScenario.java @@ -9,6 +9,8 @@ import java.util.List; import java.util.Random; import java.util.regex.Pattern; +import org.apache.commons.lang.SystemUtils; + import com.github.mattficken.io.ByLineReader; import com.github.mattficken.io.CharsetDeciderDecoder; import com.github.mattficken.io.IOUtil; @@ -91,6 +93,17 @@ public abstract class FileSystemScenario extends AbstractSerialScenario { } } + public static String osDirName(String path) + { + if(SystemUtils.IS_OS_WINDOWS) + { + String winPath = toWindowsPath(path); + return dirname(winPath); + } + String unixPath = toUnixPath(path); + return dirname(unixPath); + } + /** returns the filename from a directory path * * @param path