com pftt2: Fix for issue #2 and resolved "Could not load file" error.: src/com/mostc/pftt/host/Host.java src/com/mostc/pftt/main/PfttMain.java
src/com/mostc/pftt/model/core/PhptTestCase.java
| From: | Anatol Belski | Date: | Fri, 29 Mar 2019 09:23:11 +0000 |
| Subject: | com pftt2: Fix for issue #2 and resolved "Could not load file" error.: src/com/mostc/pftt/host/Host.java src/com/mostc/pftt/main/PfttMain.java src/com/mostc/pftt/model/core/PhptTestCase.java |
||
| Groups: | php.qa | ||
| Request: | Send a blank email to php-qa+get-68457@lists.php.net to get a copy of this message | ||
Commit: 580251a04904cbff6d2be1c5dc3917ce94c249fa
Author: Allen Truong <v-altruo@microsoft.com> Thu, 21 Mar 2019 14:39:28 -0700
Committer: Anatol Belski <ab@php.net> Fri, 29 Mar 2019 10:23:11 +0100
Parents: bd4281cbd61344ebc09102f2a2de226d3f796dfa
Branches: master
Link: http://git.php.net/?p=pftt2.git;a=commitdiff;h=580251a04904cbff6d2be1c5dc3917ce94c249fa
Log:
Fix for issue #2 and resolved "Could not load file" error.
Updated with suggestions for issue #2
Updated for issue #2. Moved code around and normalized paths if tool is running on windows machine
Bugs:
https://bugs.php.net/2
Changed paths:
M src/com/mostc/pftt/host/Host.java
M src/com/mostc/pftt/main/PfttMain.java
M src/com/mostc/pftt/model/core/PhptTestCase.java
Diff:
diff --git a/src/com/mostc/pftt/host/Host.java b/src/com/mostc/pftt/host/Host.java
index fb7a5c9..edecc47 100644
--- a/src/com/mostc/pftt/host/Host.java
+++ b/src/com/mostc/pftt/host/Host.java
@@ -39,24 +39,32 @@ public abstract class Host {
public abstract boolean equals(Object o);
public boolean isSafePath(String path) {
- if (path.equals(getJobWorkDir()))
- // can't delete /php-sdk
- return false;
String pftt_dir = getPfttDir();
- if (path.startsWith(pftt_dir)) {
- // don't delete anything in PFTT dir unless its in cache/working
- if (!path.startsWith(pftt_dir+"/cache/working/"))
- return false;
- }
+ String job_work_dir = getJobWorkDir();
+
if (isWindows()) {
+ path = path.toLowerCase().replace("\\", "/");
+ pftt_dir = pftt_dir.toLowerCase().replace("\\", "/");
+ job_work_dir = job_work_dir.toLowerCase().replace("\\", "/");
+
// don't mess with windows
- if (path.equals(getSystemDrive()+"\\Windows"))
+ if (path.equals(getSystemDrive().toLowerCase()+"/windows"))
return false;
} else {
// these dirs aren't safe to mess with
if
(path.startsWith("/usr/")||path.startsWith("/var/")||path.startsWith("/lib/")||path.startsWith("/sbin/")||path.startsWith("/boot/"))
return false;
}
+
+ if (path.equals(job_work_dir))
+ // can't delete /php-sdk
+ return false;
+
+ if (path.startsWith(pftt_dir)) {
+ // don't delete anything in PFTT dir unless it is in job_work
+ if (!path.startsWith(job_work_dir))
+ return false;
+ }
return true;
}
diff --git a/src/com/mostc/pftt/main/PfttMain.java b/src/com/mostc/pftt/main/PfttMain.java
index 2ef2672..941163e 100644
--- a/src/com/mostc/pftt/main/PfttMain.java
+++ b/src/com/mostc/pftt/main/PfttMain.java
@@ -353,7 +353,7 @@ public class PfttMain {
System.out.println(" == Commands ==");
table = new AlignedTable(2, 85)
.addRow("core_all <build[,build2]> <test-pack>", "runs all tests in
given test pack")
- .addRow("core_named <build> <test-pack> <test name fragment>",
"runs named tests or tests matching name pattern")
+ .addRow("core_named <build> <test-pack> <test name fragment>",
"runs named tests or tests matching name pattern. Test name fragment is path from test-pack
root to test file")
.addRow("core_list <build[,build2]> <test-pack> <file>", "runs
list of tests stored in file")
.addRow("app_all <build[,build2]>", "runs all application tests specified
in a Scenario config file against build")
.addRow("app_named <build[,build2]> <test name fragment>", "runs
named application tests (tests specified in a Scenario config file)")
diff --git a/src/com/mostc/pftt/model/core/PhptTestCase.java
b/src/com/mostc/pftt/model/core/PhptTestCase.java
index 51d8758..2712846 100644
--- a/src/com/mostc/pftt/model/core/PhptTestCase.java
+++ b/src/com/mostc/pftt/model/core/PhptTestCase.java
@@ -767,6 +767,16 @@ public class PhptTestCase extends TestCase {
return ext_name;
String[] parts = name.split("/");
+
+ try {
+ ext_name = parts[1];
+ } catch (ArrayIndexOutOfBoundsException e) {
+ System.err.println(e);
+ System.err.println("Extension name not found.");
+ System.err.println("Make sure <test fragment> argument is (folder in test-pack
dir)/.../test.phpt");
+ System.exit(0);
+ }
+
return ext_name = parts[1];
}