Commit: 75131b065772e0d24cd573b027c6e19344aa279d Author: Anatol Belski <a...@php.net> Mon, 17 Dec 2018 01:10:41 +0100 Parents: 6c334274d198bcef2bd8f99aa71cd734dec532c9 Branches: revamp_3
Link: http://git.php.net/?p=pftt2.git;a=commitdiff;h=75131b065772e0d24cd573b027c6e19344aa279d Log: Don't depend on a hardcoded location The most things have been done, some hardcoded places might be still to cleanup. Changed paths: M bin/pftt.cmd M bin/php_sdk.cmd M bin/set_env.cmd M src/com/mostc/pftt/host/AHost.java M src/com/mostc/pftt/host/AbstractRemoteTestPackRunner.java M src/com/mostc/pftt/host/Host.java M src/com/mostc/pftt/host/HostGroup.java M src/com/mostc/pftt/host/LocalHost.java M src/com/mostc/pftt/host/RemotePhptTestPackRunner.java M src/com/mostc/pftt/main/PfttAuto.java M src/com/mostc/pftt/main/PfttMain.java M src/com/mostc/pftt/runner/AbstractLocalApplicationTestPackRunner.java M src/com/mostc/pftt/runner/AbstractSimpleTestCaseRunner.java M src/com/mostc/pftt/scenario/LocalFileSystemScenario.java M src/com/mostc/pftt/scenario/OpcacheScenario.java M src/com/mostc/pftt/util/HostEnvUtil.java M src/com/mostc/pftt/util/WindowsSnapshotDownloadUtil.groovy
diff --git a/bin/pftt.cmd b/bin/pftt.cmd index e5607cb..fd149a6 100644 --- a/bin/pftt.cmd +++ b/bin/pftt.cmd @@ -3,7 +3,7 @@ REM script for running PFTT on Windows REM set important env vars IF DEFINED PFTT_SHELL GOTO :skip_set_env -CALL set_env +CALL %~dp0set_env.cmd :skip_set_env SET PFTT_LIB=%PFTT_HOME%\lib @@ -91,7 +91,7 @@ IF EXIST %JAVA_HOME%\lib\tools.jar ( ) ) -IF [%JAVA_EXE%] == [] ( +IF "%JAVA_EXE%" == "" ( REM check PATH last. it might find java.exe in \Windows\System32\java REM which elevate.exe can't find/execute for some weird reason WHERE java > pftt_cmd.tmp 2> NUL @@ -115,7 +115,7 @@ REM run with yjp if -pftt_profile console option is used SET pftt_args="str %*" SET pftt_temp=%pftt_args:pftt_profile=% IF NOT %pftt_args% EQU %pftt_temp% ( - %ELEVATOR% %JAVA_EXE% -Xmx512M -Xms256M -agentpath:"C:\Program Files (x86)\YourKit Java Profiler 12.0.5\bin\win64\yjpagent.dll" -classpath %CLASSPATH% com.mostc.pftt.main.PfttMain %ELEVATOR_OPTS%%* + %ELEVATOR% "%JAVA_EXE%" -Xmx512M -Xms256M -agentpath:"C:\Program Files (x86)\YourKit Java Profiler 12.0.5\bin\win64\yjpagent.dll" -classpath %CLASSPATH% com.mostc.pftt.main.PfttMain %ELEVATOR_OPTS%%* ) ELSE ( - %ELEVATOR% %JAVA_EXE% -Xmx512M -Xms256M -classpath %CLASSPATH% com.mostc.pftt.main.PfttMain %ELEVATOR_OPTS%%* + %ELEVATOR% "%JAVA_EXE%" -Xmx512M -Xms256M -classpath %CLASSPATH% com.mostc.pftt.main.PfttMain %ELEVATOR_OPTS%%* ) diff --git a/bin/php_sdk.cmd b/bin/php_sdk.cmd index 7d5b036..19f5041 100644 --- a/bin/php_sdk.cmd +++ b/bin/php_sdk.cmd @@ -1,5 +1,4 @@ @ECHO OFF -CALL \php-sdk\PFTT\current\bin\set_env -%PHP_DRIVE% -CD %PHP_SDK% -@ECHO ON \ No newline at end of file +CALL %~dp0set_env +CD %PFTT_JOB_WORK% +@ECHO ON diff --git a/bin/set_env.cmd b/bin/set_env.cmd index f181e69..1c5e8fb 100644 --- a/bin/set_env.cmd +++ b/bin/set_env.cmd @@ -1,34 +1,10 @@ @ECHO OFF +pushd %~dp0.. +SET PFTT_ROOT_DIR=%CD% +SET PFTT_HOME=%CD% +popd -REM user may set custom PHP_SDK instead of %SYSTEMDRIVE%\php-sdk -IF EXIST %~dp0%\internal\set_php_sdk.cmd ( - REM this must set PHP_SDK - CALL %~dp0%\internal\set_php_sdk.cmd - - ECHO Custom PHP_SDK: %PHP_SDK% - - REM get PHP_DRIVE from PHP_SDK - SET PHP_DRIVE=%PHP_SDK:~0,2% - ECHO Custom PHP_DRIVE: %PHP_DRIVE% - - REM see: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/percent.mspx?mfr=true - REM see: http://www.dostips.com/DtTipsStringManipulation.php#Snippets.MidString -) ELSE ( - REM system drive might not be C:, in such situations, - REM php-sdk might be on C: or it could be both - REM assume the one where PFTT is installed is the one to use (in such cases) - REM - IF EXIST %SYSTEMDRIVE%\php-sdk\PFTT\current ( - SET PHP_DRIVE=%SYSTEMDRIVE% - ) ELSE ( - SET PHP_DRIVE=C: - ) - SET PHP_SDK=%PHP_DRIVE%\php-sdk -) - -SET PFTT_ROOT_DIR=%PHP_SDK%\PFTT -SET PFTT_HOME=%PHP_SDK%\PFTT\current SET PFTT_BIN=%PFTT_HOME%\bin SET PFTT_BIN_INTERNAL=%PFTT_BIN%\internal SET PFTT_CONF=%PFTT_HOME%\conf @@ -41,6 +17,9 @@ SET PFTT_CACHE_WORKING=%PFTT_CACHE%\working SET PFTT_CACHE_DEP=%PFTT_CACHE%\working SET PFTT_DEP=%PFTT_CACHE_DEP% SET PFTT_WORKING=%PFTT_CACHE_WORKING% +SET PFTT_JOB_WORK=%PFTT_HOME%\job_work + +if not exist %PFTT_JOB_WORK% mkdir %PFTT_JOB_WORK% REM add PFTT to path. and GIT and Notepad++ if present SET PATH=%PFTT_BIN%;%PFTT_BIN_INTERNAL%;%PATH%;"%ProgramFiles(x86)%\Git\Bin";"%ProgramFiles%\Git\Bin" diff --git a/src/com/mostc/pftt/host/AHost.java b/src/com/mostc/pftt/host/AHost.java index d794027..5cb3542 100644 --- a/src/com/mostc/pftt/host/AHost.java +++ b/src/com/mostc/pftt/host/AHost.java @@ -40,7 +40,7 @@ import com.mostc.pftt.util.NTStatus; */ public abstract class AHost extends Host implements IProgramRunner { - protected String sys_info, os_name, tmp_dir, system_drive, home_dir, php_sdk_dir; + protected String sys_info, os_name, tmp_dir, system_drive, home_dir, job_work_dir; @Override public boolean isClosed() { @@ -278,7 +278,7 @@ public abstract class AHost extends Host implements IProgramRunner { // to avoid having to clean two directories if (tmp_dir==null) // be sure to terminate with directory sep - tmp_dir = joinIntoOnePath(getPhpSdkDir(), "temp") + mDirSeparator(); + tmp_dir = joinIntoOnePath(getJobWorkDir(), "temp") + mDirSeparator(); return tmp_dir; /*if (tmp_dir!=null) return tmp_dir; @@ -314,24 +314,23 @@ public abstract class AHost extends Host implements IProgramRunner { @SuppressWarnings("unused") @Override public String getPfttDir() { - if (DEV > 0) { - return isWindows() ? getPhpSdkDir() + "\\PFTT\\Dev-"+DEV+"\\" : getPhpSdkDir() + "/PFTT/dev-"+DEV+"/"; - } else { - return isWindows() ? getPhpSdkDir() + "\\PFTT\\Current\\" : getPhpSdkDir() + "/PFTT/current/"; - } + /* XXX should this depend on external env? */ + return System.getenv("PFTT_HOME"); } @Override - public String getPhpSdkDir() { - if (StringUtil.isNotEmpty(php_sdk_dir)) - return php_sdk_dir; - php_sdk_dir = System.getenv("PHP_SDK"); - if (StringUtil.isNotEmpty(php_sdk_dir)) - return php_sdk_dir; - if(isWindows()) - return php_sdk_dir = getSystemDrive() + "\\php-sdk\\"; + public String getJobWorkDir() { + /* XXX should this depend on external env? */ + if (StringUtil.isNotEmpty(job_work_dir)) + return job_work_dir; + job_work_dir = System.getenv("PFTT_JOB_WORK"); + //if (StringUtil.isNotEmpty(job_work_dir)) + return job_work_dir; + /* XXX obsolete, handle this later. */ + /*if(isWindows()) + return job_work_dir = getSystemDrive() + "\\php-sdk\\"; else - return php_sdk_dir = getHomeDir() + "/php-sdk/"; + return job_work_dir = getHomeDir() + "/php-sdk/";*/ } @Override public String getHomeDir() { diff --git a/src/com/mostc/pftt/host/AbstractRemoteTestPackRunner.java b/src/com/mostc/pftt/host/AbstractRemoteTestPackRunner.java index c5f892d..df85126 100644 --- a/src/com/mostc/pftt/host/AbstractRemoteTestPackRunner.java +++ b/src/com/mostc/pftt/host/AbstractRemoteTestPackRunner.java @@ -154,7 +154,7 @@ public abstract class AbstractRemoteTestPackRunner<A extends ActiveTestPack, S e @Override public void runAllTests(Config config, S test_pack) throws FileNotFoundException, IOException, Exception { // TODO - A active_test_pack = test_pack.install(tmgr.getConsoleManager(), this.storage_host, remote_host.getPhpSdkDir()+"/Remote", "", sapi_scenario); + A active_test_pack = test_pack.install(tmgr.getConsoleManager(), this.storage_host, remote_host.getJobWorkDir()+"/Remote", "", sapi_scenario); commonRunStart(); sendTestPack(active_test_pack); @@ -163,7 +163,7 @@ public abstract class AbstractRemoteTestPackRunner<A extends ActiveTestPack, S e @Override public void runTestList(S test_pack, List<T> test_cases) throws Exception { - A active_test_pack = test_pack.installNamed(null, this.storage_host, remote_host.getPhpSdkDir()+"/Remote", test_cases); + A active_test_pack = test_pack.installNamed(null, this.storage_host, remote_host.getJobWorkDir()+"/Remote", test_cases); commonRunStart(); sendTestPack(active_test_pack); diff --git a/src/com/mostc/pftt/host/Host.java b/src/com/mostc/pftt/host/Host.java index 505bd26..fb7a5c9 100644 --- a/src/com/mostc/pftt/host/Host.java +++ b/src/com/mostc/pftt/host/Host.java @@ -39,7 +39,7 @@ public abstract class Host { public abstract boolean equals(Object o); public boolean isSafePath(String path) { - if (path.equals(getPhpSdkDir())) + if (path.equals(getJobWorkDir())) // can't delete /php-sdk return false; String pftt_dir = getPfttDir(); @@ -382,7 +382,7 @@ public abstract class Host { public abstract String getUsername(); public abstract String getHomeDir(); - public abstract String getPhpSdkDir(); + public abstract String getJobWorkDir(); public abstract String getPfttDir(); public String getPfttBinDir() { diff --git a/src/com/mostc/pftt/host/HostGroup.java b/src/com/mostc/pftt/host/HostGroup.java index 3e31dbf..fb5e568 100644 --- a/src/com/mostc/pftt/host/HostGroup.java +++ b/src/com/mostc/pftt/host/HostGroup.java @@ -643,14 +643,14 @@ public class HostGroup extends Host implements List<Host> { c.collect(h, h.getHomeDir()); } @Override - public String getPhpSdkDir() { + public String getJobWorkDir() { for (Host h : this) - return h.getPhpSdkDir(); + return h.getJobWorkDir(); return null; } public void getPhpSdkDir(StringCollector c) { for (Host h : this) - c.collect(h, h.getPhpSdkDir()); + c.collect(h, h.getJobWorkDir()); } @Override public String getPfttDir() { diff --git a/src/com/mostc/pftt/host/LocalHost.java b/src/com/mostc/pftt/host/LocalHost.java index d4eab80..2c8fe64 100644 --- a/src/com/mostc/pftt/host/LocalHost.java +++ b/src/com/mostc/pftt/host/LocalHost.java @@ -889,7 +889,8 @@ public abstract class LocalHost extends AHost { } public static String getLocalPfttDir() { - if (isLocalhostWindows()) { + return System.getenv("PFTT_HOME"); + /*if (isLocalhostWindows()) { String php_sdk_dir = System.getenv("PHP_SDK"); if (null == php_sdk_dir) { String sd = System.getenv("SYSTEMDRIVE"); @@ -905,7 +906,7 @@ public abstract class LocalHost extends AHost { return System.getenv("HOME")+"/php-sdk/PFTT/dev-"+DEV+"/"; } else { return System.getenv("HOME")+"/php-sdk/PFTT/current/"; - } + }*/ } @Override diff --git a/src/com/mostc/pftt/host/RemotePhptTestPackRunner.java b/src/com/mostc/pftt/host/RemotePhptTestPackRunner.java index 713c17c..a589774 100644 --- a/src/com/mostc/pftt/host/RemotePhptTestPackRunner.java +++ b/src/com/mostc/pftt/host/RemotePhptTestPackRunner.java @@ -69,7 +69,7 @@ public class RemotePhptTestPackRunner extends AbstractRemoteTestPackRunner<PhptA test_pack.open(cm, config, FileSystemScenario.getFS(scenario_set, host), host); - PhpResultPackWriter tmgr = new PhpResultPackWriter(host, cm, new File(host.getPhpSdkDir()), build, test_pack, null); + PhpResultPackWriter tmgr = new PhpResultPackWriter(host, cm, new File(host.getJobWorkDir()), build, test_pack, null); RemotePhptTestPackRunner runner = new RemotePhptTestPackRunner(tmgr, scenario_set, build, host, host); diff --git a/src/com/mostc/pftt/main/PfttAuto.java b/src/com/mostc/pftt/main/PfttAuto.java index 6451b98..6c64583 100644 --- a/src/com/mostc/pftt/main/PfttAuto.java +++ b/src/com/mostc/pftt/main/PfttAuto.java @@ -146,7 +146,7 @@ public class PfttAuto { exit_thread.setDaemon(true); exit_thread.start(); - File most_recent_dir = getMostRecentDir(new File(host.getPhpSdkDir()+"/PFTT-Auto")); + File most_recent_dir = getMostRecentDir(new File(host.getJobWorkDir()+"/PFTT-Auto")); boolean b = false; for (BuildSpec bs : BUILD_SPECS) { @@ -222,7 +222,7 @@ public class PfttAuto { //new Mail("MSSQL", true, false, new Address[]{AddressParser.parseAddress("v-maf...@microsoft.com")}) ); - final File auto_dir = new File(host.getPhpSdkDir()+"/PFTT-MSSQL"); // TODO for MSSQL + final File auto_dir = new File(host.getJobWorkDir()+"/PFTT-MSSQL"); // TODO for MSSQL Config sql_config = Config.loadConfigFromFiles(cm, "mssql10", "mssql11", "cli", "opcache", "no_code_cache", "builtin_web"); @@ -284,7 +284,7 @@ public class PfttAuto { PhptSourceTestPack core_test_pack = new PhptSourceTestPack(test_pack_path); core_test_pack.open(cm, config, Scenario.LOCALFILESYSTEM_SCENARIO, host); - final File auto_dir = new File(host.getPhpSdkDir()+"/PFTT-Auto"); + final File auto_dir = new File(host.getJobWorkDir()+"/PFTT-Auto"); PhpResultPack base_pack = findBaseResultPack(core_test_pack, bs, auto_dir, cm, host); if (base_pack!=null && build.getBuildInfo(cm, host).equals(base_pack.getBuildInfo())) { return ET.NEWEST_ALREADY_TESTED; diff --git a/src/com/mostc/pftt/main/PfttMain.java b/src/com/mostc/pftt/main/PfttMain.java index d16be7a..2ef2672 100644 --- a/src/com/mostc/pftt/main/PfttMain.java +++ b/src/com/mostc/pftt/main/PfttMain.java @@ -315,9 +315,9 @@ public class PfttMain { protected File telem_dir() { File file; if (AHost.DEV > 0) { - file = new File(host.getPhpSdkDir(), "Dev-"+AHost.DEV); + file = new File(host.getJobWorkDir(), "Dev-"+AHost.DEV); } else { - file = new File(host.getPhpSdkDir()); + file = new File(host.getJobWorkDir()); } file.mkdirs(); return file; @@ -1137,7 +1137,7 @@ public class PfttMain { return build; } cm.println(EPrintType.CLUE, PfttMain.class, "Build: "+build); - build = new PhpBuild(host.getPhpSdkDir() + "/" + path); + build = new PhpBuild(host.getJobWorkDir() + "/" + path); if (build.open(cm, host)) { return build; } else { @@ -1157,7 +1157,7 @@ public class PfttMain { builds.add(build); } else { cm.println(EPrintType.CLUE, PfttMain.class, "Build: "+build); - build = new PhpBuild(host.getPhpSdkDir() + "/" + path); + build = new PhpBuild(host.getJobWorkDir() + "/" + path); // open all builds now to ensure they exist (rather than finding out // later when build is used (because that could be hours away if running // several scenario sets and several builds)) @@ -1182,7 +1182,7 @@ public class PfttMain { PhptSourceTestPack test_pack = new PhptSourceTestPack(path); if (test_pack.open(cm, config, fs, host)) return test_pack; - test_pack = new PhptSourceTestPack(host.getPhpSdkDir() + "/" + path); + test_pack = new PhptSourceTestPack(host.getJobWorkDir() + "/" + path); if (test_pack.open(cm, config, fs, host)) return test_pack; else diff --git a/src/com/mostc/pftt/runner/AbstractLocalApplicationTestPackRunner.java b/src/com/mostc/pftt/runner/AbstractLocalApplicationTestPackRunner.java index 6d0d7a3..ada348d 100644 --- a/src/com/mostc/pftt/runner/AbstractLocalApplicationTestPackRunner.java +++ b/src/com/mostc/pftt/runner/AbstractLocalApplicationTestPackRunner.java @@ -33,7 +33,7 @@ public abstract class AbstractLocalApplicationTestPackRunner<A extends ActiveTes nts_file_names = src_test_pack.getNonThreadSafeTestFileNames(); if (!(storage_dir instanceof SMBStorageDir)) { // TODO generalize - temp_base_dir = runner_host.getPhpSdkDir()+"/temp/"; + temp_base_dir = runner_host.getJobWorkDir()+"/temp/"; active_test_pack = src_test_pack.installInPlace(cm, runner_host); diff --git a/src/com/mostc/pftt/runner/AbstractSimpleTestCaseRunner.java b/src/com/mostc/pftt/runner/AbstractSimpleTestCaseRunner.java index 814bb50..472aa10 100644 --- a/src/com/mostc/pftt/runner/AbstractSimpleTestCaseRunner.java +++ b/src/com/mostc/pftt/runner/AbstractSimpleTestCaseRunner.java @@ -37,7 +37,7 @@ public abstract class AbstractSimpleTestCaseRunner extends AbstractApplicationUn } // */ - String my_temp_dir = host.getPhpSdkDir()+"/temp/"+t.getName(); + String my_temp_dir = host.getJobWorkDir()+"/temp/"+t.getName(); fs.createDirs(my_temp_dir); final String template_file = my_temp_dir+"/test.php"; diff --git a/src/com/mostc/pftt/scenario/LocalFileSystemScenario.java b/src/com/mostc/pftt/scenario/LocalFileSystemScenario.java index b0d54db..dd20388 100644 --- a/src/com/mostc/pftt/scenario/LocalFileSystemScenario.java +++ b/src/com/mostc/pftt/scenario/LocalFileSystemScenario.java @@ -35,11 +35,11 @@ public class LocalFileSystemScenario extends FileSystemScenario { } @Override public String getLocalPath(AHost host) { - return host.getPhpSdkDir(); + return host.getJobWorkDir(); } @Override public String getRemotePath(AHost host) { - return host.getPhpSdkDir(); + return host.getJobWorkDir(); } @Override public boolean closeIfEmpty(ConsoleManager cm, AHost local_host, ActiveTestPack active_test_pack) { @@ -94,7 +94,7 @@ public class LocalFileSystemScenario extends FileSystemScenario { @Override public ITestPackStorageDir setup(ConsoleManager cm, Host host, PhpBuild build, ScenarioSet scenario_set) { try { - host.mCreateDirs(host.getPhpSdkDir()); + host.mCreateDirs(host.getJobWorkDir()); return LOCAL_DIR; } catch ( Exception ex ) { cm.addGlobalException(EPrintType.CANT_CONTINUE, LocalFileSystemScenario.class, "createStorageDir", ex, ""); diff --git a/src/com/mostc/pftt/scenario/OpcacheScenario.java b/src/com/mostc/pftt/scenario/OpcacheScenario.java index 69f8895..a466879 100644 --- a/src/com/mostc/pftt/scenario/OpcacheScenario.java +++ b/src/com/mostc/pftt/scenario/OpcacheScenario.java @@ -383,7 +383,7 @@ public class OpcacheScenario extends CodeCacheScenario { host.mDeleteIfExistsElevated(test_pack.getStorageDirectory()+"\\ZendOptimizer+.MemoryBase@"+host.getUsername()); } host.mDeleteIfExistsElevated(build.getBuildPath()+"\\ZendOptimizer+.MemoryBase@"+host.getUsername()); - host.mDeleteIfExistsElevated(host.getPhpSdkDir()+"\\ZendOptimizer+.MemoryBase@"+host.getUsername()); + host.mDeleteIfExistsElevated(host.getJobWorkDir()+"\\ZendOptimizer+.MemoryBase@"+host.getUsername()); host.mDeleteIfExistsElevated(host.getPfttDir()+"\\ZendOptimizer+.MemoryBase@"+host.getUsername()); host.mDeleteIfExistsElevated(host.getSystemRoot()+"\\ZendOptimizer+.MemoryBase@"+host.getUsername()); host.mDeleteIfExistsElevated(host.getSystemDrive()+"\\ZendOptimizer+.MemoryBase@"+host.getUsername()); diff --git a/src/com/mostc/pftt/util/HostEnvUtil.java b/src/com/mostc/pftt/util/HostEnvUtil.java index bc07af8..98d0e52 100644 --- a/src/com/mostc/pftt/util/HostEnvUtil.java +++ b/src/com/mostc/pftt/util/HostEnvUtil.java @@ -116,9 +116,9 @@ public final class HostEnvUtil { } // - cm.println(EPrintType.IN_PROGRESS, HostEnvUtil.class, "creating File Share for "+host.getPhpSdkDir()+"..."); + //cm.println(EPrintType.IN_PROGRESS, HostEnvUtil.class, "creating File Share for "+host.getJobWorkDir()+"..."); // share PHP-SDK over network. this also will share C$, G$, etc... - host.execElevated(cm, HostEnvUtil.class, "NET SHARE PHP_SDK="+host.getPhpSdkDir()+" /Grant:"+host.getUsername()+",Full", AHost.ONE_MINUTE); + //host.execElevated(cm, HostEnvUtil.class, "NET SHARE PHP_SDK="+host.getJobWorkDir()+" /Grant:"+host.getUsername()+",Full", AHost.ONE_MINUTE); } installVCRuntime(fs, host, cm, build); diff --git a/src/com/mostc/pftt/util/WindowsSnapshotDownloadUtil.groovy b/src/com/mostc/pftt/util/WindowsSnapshotDownloadUtil.groovy index 8b8980e..5dcb5fc 100644 --- a/src/com/mostc/pftt/util/WindowsSnapshotDownloadUtil.groovy +++ b/src/com/mostc/pftt/util/WindowsSnapshotDownloadUtil.groovy @@ -59,7 +59,7 @@ final class WindowsSnapshotDownloadUtil { } else if (local_path.toLowerCase().endsWith(".zip")) { local_path = local_path.substring(0, local_path.length()-".zip".length()); } - return new File(host.getPhpSdkDir()+"/"+local_path); + return new File(host.getJobWorkDir()+"/"+local_path); } static URL getDownloadURL(EBuildBranch branch) {