Commit:    a6c2d9985e122d90b3d4c17de47cf0d9d78d0c3c
Author:    Matt Ficken <v-maf...@microsoft.com>         Fri, 14 Jun 2013 
13:13:22 -0700
Parents:   6559b74b30ff295f92dc1b94571be138204df75b
Branches:  master

Link:       
http://git.php.net/?p=pftt2.git;a=commitdiff;h=a6c2d9985e122d90b3d4c17de47cf0d9d78d0c3c

Log:
adding Timeout Status feature


Former-commit-id: 150229c8f127441a2c436324b6735686f230b44f

Changed paths:
  M  src/com/mostc/pftt/host/AHost.java
  M  src/com/mostc/pftt/host/LocalHost.java
  M  src/com/mostc/pftt/host/SSHHost.java
  M  src/com/mostc/pftt/main/PfttMain.java
  M  src/com/mostc/pftt/model/app/EPhpUnitTestStatus.java
  M  src/com/mostc/pftt/model/core/EPhptTestStatus.java
  M  src/com/mostc/pftt/results/AbstractPhpUnitRW.java
  M  src/com/mostc/pftt/results/AbstractPhptRW.java
  M  src/com/mostc/pftt/results/PhpUnitResultReader.java
  M  src/com/mostc/pftt/results/PhpUnitResultWriter.java
  M  src/com/mostc/pftt/results/PhptResultReader.java
  M  src/com/mostc/pftt/results/PhptTallyFile.groovy
  M  src/com/mostc/pftt/results/PhptTestResult.java
  M  src/com/mostc/pftt/runner/AbstractPhpUnitTestCaseRunner.java
  M  src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java
  M  src/com/mostc/pftt/runner/CliPhpUnitTestCaseRunner.java
  M  src/com/mostc/pftt/runner/CliPhptTestCaseRunner.java
  M  src/com/mostc/pftt/runner/HttpPhpUnitTestCaseRunner.java
  M  src/com/mostc/pftt/runner/HttpPhptTestCaseRunner.java

diff --git a/src/com/mostc/pftt/host/AHost.java 
b/src/com/mostc/pftt/host/AHost.java
index c55fd3e..eb6bc79 100644
--- a/src/com/mostc/pftt/host/AHost.java
+++ b/src/com/mostc/pftt/host/AHost.java
@@ -381,6 +381,7 @@ public abstract class AHost extends Host implements 
IProgramRunner {
                        close(cm, false);
                }
                public abstract boolean isRunning();
+               public abstract boolean isTimedOut();
                /** returns if process crashed.
                 * 
                 * if debugger was attached to process and debugger closed, then
diff --git a/src/com/mostc/pftt/host/LocalHost.java 
b/src/com/mostc/pftt/host/LocalHost.java
index 16de2d5..d4166a4 100644
--- a/src/com/mostc/pftt/host/LocalHost.java
+++ b/src/com/mostc/pftt/host/LocalHost.java
@@ -265,7 +265,7 @@ public class LocalHost extends AHost {
                protected InputStream stdout, stderr;
                protected String image_name;
                protected Charset charset;
-               protected final AtomicBoolean run = new AtomicBoolean(true), 
wait = new AtomicBoolean(true);
+               protected final AtomicBoolean run = new AtomicBoolean(true), 
wait = new AtomicBoolean(true), timedout = new AtomicBoolean(false);
                
                public LocalExecHandle(Process process, OutputStream stdin, 
InputStream stdout, InputStream stderr, String[] cmd_array) {
                        this.process = new AtomicReference<Process>(process);
@@ -580,6 +580,11 @@ public class LocalHost extends AHost {
                        if (b!=null)
                                b.cancel();
                }
+
+               @Override
+               public boolean isTimedOut() {
+                       return timedout.get();
+               }
                
        } // end public class LocalExecHandle
        
@@ -748,6 +753,7 @@ public class LocalHost extends AHost {
                        // go further trying to kill the process
                        //
                        // LocalHostExecHandle#close checks for WerFault.exe 
blocking on Windows
+                       h.timedout.set(true);
                        h.close(cm, true);
                }
                
diff --git a/src/com/mostc/pftt/host/SSHHost.java 
b/src/com/mostc/pftt/host/SSHHost.java
index 4f733b1..30f582c 100644
--- a/src/com/mostc/pftt/host/SSHHost.java
+++ b/src/com/mostc/pftt/host/SSHHost.java
@@ -419,6 +419,7 @@ public class SSHHost extends RemoteHost {
        protected class SSHExecHandle extends ExecHandle {
                protected final SessionChannelClient session;
                protected final ByteArrayOutputStream out;
+               protected final AtomicBoolean timedout = new 
AtomicBoolean(false);
                
                protected SSHExecHandle(SessionChannelClient session, 
ByteArrayOutputStream out) {
                        this.session = session;
@@ -465,9 +466,14 @@ public class SSHHost extends RemoteHost {
 
                @Override
                public void run(ConsoleManager cm, StringBuilder output_sb, 
Charset charset, int timeout_sec, final TestPackRunnerThread thread, int 
slow_sec, int suspend_seconds) throws IOException, InterruptedException {
-                       do_run(session, charset, timeout_sec, thread, slow_sec);
+                       do_run(this, session, charset, timeout_sec, thread, 
slow_sec);
                        output_sb.append(out.toString());
                }
+
+               @Override
+               public boolean isTimedOut() {
+                       return timedout.get();
+               }
                
        } // end protected class SSHExecHandle
        
@@ -480,7 +486,7 @@ public class SSHHost extends RemoteHost {
                //
                final SessionChannelClient session = 
createSessionChannelClient(cmd, env, chdir, stdin_post, out);
                
-               do_run(session, charset, timeout_sec, thread, slow_sec);
+               do_run(null, session, charset, timeout_sec, thread, slow_sec);
                
                
                //
@@ -494,12 +500,14 @@ public class SSHHost extends RemoteHost {
                return eo;
        } // end public ExecOutput execOut
        
-       protected void do_run(final SessionChannelClient session, Charset 
charset, int timeout_sec, final TestPackRunnerThread thread, int slow_sec) 
throws InvalidStateException, InterruptedException {
+       protected void do_run(final SSHExecHandle h, final SessionChannelClient 
session, Charset charset, int timeout_sec, final TestPackRunnerThread thread, 
int slow_sec) throws InvalidStateException, InterruptedException {
                final AtomicBoolean run = new AtomicBoolean(true);
                if (timeout_sec>NO_TIMEOUT) {
                        timer.schedule(new TimerTask() {
                                        public void run() {
                                                try {
+                                                       if (h!=null)
+                                                               
h.timedout.set(true);
                                                        run.set(false);
                                                        
                                                        session.close();
diff --git a/src/com/mostc/pftt/main/PfttMain.java 
b/src/com/mostc/pftt/main/PfttMain.java
index 3a94984..c143ba9 100644
--- a/src/com/mostc/pftt/main/PfttMain.java
+++ b/src/com/mostc/pftt/main/PfttMain.java
@@ -78,12 +78,8 @@ import 
com.mostc.pftt.util.WindowsSnapshotDownloadUtil.FindBuildTestPackPair;
 // the php test tool that you'd actually want to use
 // doesn't resort to brittle shell scripts
 
-// TODO http request to web server to make sure its running (instead of just 
tcp socket)
-// TODO for SKIP and XSKIP tests, include output and sapi-output in result-pack
-// TODO mysql, postgresql scenario
-// TODO create TIMEOUT status for PHPT and phpunit tests
-//      modify evaluation critieria to mark those tests as TIMEOUT
-//      add TIMEOUT status to report pages (list at end of report ; highlight 
summary in yellow if TIMEOUT > 0)
+// TODO mysql, postgresql, curl scenario
+// TODO conf/ini/no_dynamic_extensions
 // TODO valgrind gdb?
 // TODO linux installer
  
@@ -111,9 +107,6 @@ import 
com.mostc.pftt.util.WindowsSnapshotDownloadUtil.FindBuildTestPackPair;
 //                     cache/working/dev instead of cache/working
 //            aa -c dev/symfony-2.3
 //                  dev/ indicates conf/dev for config file
-//       rctest should have an rc_hosts config file
-//          -store example in conf/internal_examples
-//              -so rctest will just use that unless/until user creates one in 
conf/internal
 // TODO include Selenium WebDriver in javadoc
 // TODO WincacheUScenario 
 //     -and APCUScenario
@@ -128,7 +121,7 @@ import 
com.mostc.pftt.util.WindowsSnapshotDownloadUtil.FindBuildTestPackPair;
 //          -as big as wordpress +INTERNATIONALIZATION
 //          -note: ui tests from joomla may be BRITTLE (maybe thats why 
they're just run by 1 guy on his laptop once in a while)
 //               not suited to our purposes => compatibility
-//                 not atomic/small -a few really big tests that test lots of 
options
+//                 not atomic/small -a few really big tests that test lots of 
actions
 //
 // TODO progress indicator for `release_get`
 // TODO iis and iis-express
diff --git a/src/com/mostc/pftt/model/app/EPhpUnitTestStatus.java 
b/src/com/mostc/pftt/model/app/EPhpUnitTestStatus.java
index d2d6e28..31aa09b 100644
--- a/src/com/mostc/pftt/model/app/EPhpUnitTestStatus.java
+++ b/src/com/mostc/pftt/model/app/EPhpUnitTestStatus.java
@@ -14,9 +14,9 @@ import com.mostc.pftt.model.core.EPhptTestStatus;
  * 
  * @see PhpUnitTemplate and @see PhpUnitResultWriter - to see how PFTT 
translates to/from PhpUnit's original statuses and this modified set
  * 
- * PFTT adds these 4 statuses to the PhpUnit standard, to convert to standard:
+ * PFTT adds these 5 statuses to the PhpUnit standard, to convert to standard:
  * XSKIP - add XSKIP count to SKIP count
- * CRASH - add CRASH count to FAILURE count
+ * CRASH, TIMEOUT - add CRASH count and TIMEOUT count to FAILURE count
  * BORK, TEST_EXCEPTION - add TEST_EXCEPTION count and BORK to UNSUPPORTED 
count
  *
  */
@@ -212,6 +212,21 @@ public enum EPhpUnitTestStatus {
                public EPhptTestStatus toPhptStatus() {
                        return EPhptTestStatus.XSKIP;
                }
+       },
+       /** PFTT PhpUnit Extension: test failed to respond with the maximum 
amount of time.
+        * 
+        * This keeps those tests from being counted as an ordinary FAILURE or 
CRASH, so they can be counted separately as TIMEIMOUT.
+        * 
+        */
+       TIMEOUT {
+               @Override
+               public boolean isNotPass() {
+                       return true;
+               }
+               @Override
+               public EPhptTestStatus toPhptStatus() {
+                       return EPhptTestStatus.TIMEOUT;
+               }
        };
        
        /** is the test a failure, error, etc... 
diff --git a/src/com/mostc/pftt/model/core/EPhptTestStatus.java 
b/src/com/mostc/pftt/model/core/EPhptTestStatus.java
index d7fd0d0..9c0e00a 100644
--- a/src/com/mostc/pftt/model/core/EPhptTestStatus.java
+++ b/src/com/mostc/pftt/model/core/EPhptTestStatus.java
@@ -8,9 +8,10 @@ import com.mostc.pftt.results.PhptTestResult;
  * @see EPhpUnitTestStatus - the Application test format
  * @author Matt Ficken
  * 
- * PFTT adds 3 statuses to the PHPT standard, to convert to standard:
+ * PFTT adds 4 statuses to the PHPT standard, to convert to standard:
  * XSKIP - add XSKIP count to SKIP count
  * CRASH - add CRASH count to FAIL count
+ * TIMEOUT - add TIMEOUT count to FAIL count
  * TEST_EXCEPTION - add TEST_EXCEPTION count to UNSUPPORTED count
  *
  */
@@ -108,6 +109,17 @@ public enum EPhptTestStatus {
                public EPhpUnitTestStatus toPhpUnit(EPhptTestStatus status) {
                        return EPhpUnitTestStatus.TEST_EXCEPTION;
                }
+       },
+       /** PFTT Extension: test failed to respond within the maximum amount of 
time.
+        * 
+        * This keeps those tests from being counted as an ordinary FAIL or 
CRASH, so they can be counted separately as TIMEIMOUT.
+        * 
+        */
+       TIMEOUT {
+               @Override
+               public EPhpUnitTestStatus toPhpUnit(EPhptTestStatus status) {
+                       return EPhpUnitTestStatus.TIMEOUT;
+               }
        };
 
        /** returns the approximate equivalent EPhpUnitTestStatus for PHP 
application testing.
diff --git a/src/com/mostc/pftt/results/AbstractPhpUnitRW.java 
b/src/com/mostc/pftt/results/AbstractPhpUnitRW.java
index 31d5785..823c3ea 100644
--- a/src/com/mostc/pftt/results/AbstractPhpUnitRW.java
+++ b/src/com/mostc/pftt/results/AbstractPhpUnitRW.java
@@ -13,6 +13,7 @@ public abstract class AbstractPhpUnitRW extends 
AbstractTestResultRW {
                                count(EPhpUnitTestStatus.ERROR) +
                                count(EPhpUnitTestStatus.WARNING) +
                                count(EPhpUnitTestStatus.NOTICE) +
+                               count(EPhpUnitTestStatus.TIMEOUT) +
                                count(EPhpUnitTestStatus.DEPRECATED) +
                                count(EPhpUnitTestStatus.CRASH);
        }
diff --git a/src/com/mostc/pftt/results/AbstractPhptRW.java 
b/src/com/mostc/pftt/results/AbstractPhptRW.java
index 1952927..193b4d1 100644
--- a/src/com/mostc/pftt/results/AbstractPhptRW.java
+++ b/src/com/mostc/pftt/results/AbstractPhptRW.java
@@ -10,7 +10,7 @@ public abstract class AbstractPhptRW extends 
AbstractTestResultRW {
        public abstract String getTestPackVersion();
        @Override
        public float passRate() {
-               return 100.0f * ((float)count(EPhptTestStatus.PASS)) / 
((float)(count(EPhptTestStatus.PASS) + count(EPhptTestStatus.CRASH) + 
count(EPhptTestStatus.FAIL)));
+               return 100.0f * ((float)count(EPhptTestStatus.PASS)) / 
((float)(count(EPhptTestStatus.PASS) + count(EPhptTestStatus.CRASH) + 
count(EPhptTestStatus.FAIL) + count(EPhptTestStatus.TIMEOUT)));
        }
        public abstract int count(EPhptTestStatus status);
        public abstract List<String> getTestNames(EPhptTestStatus status);
diff --git a/src/com/mostc/pftt/results/PhpUnitResultReader.java 
b/src/com/mostc/pftt/results/PhpUnitResultReader.java
index 38e32a4..2c5630e 100644
--- a/src/com/mostc/pftt/results/PhpUnitResultReader.java
+++ b/src/com/mostc/pftt/results/PhpUnitResultReader.java
@@ -59,7 +59,7 @@ public class PhpUnitResultReader extends AbstractPhpUnitRW {
                try {
                        parser.setInput(fr);
                        
-                       
+                               
                        String tag_name = "";
                        main_loop:
                        while(true) {
@@ -79,6 +79,9 @@ public class PhpUnitResultReader extends AbstractPhpUnitRW {
                                                test_pack_name_and_version = 
parser.getAttributeValue(null, "test_pack_name_and_version");
                                                
                                                
status_list_map.put(EPhpUnitTestStatus.PASS, new 
StatusListEntry(Integer.parseInt(parser.getAttributeValue(null, "pass"))));
+                                               if 
(parser.getAttributeValue(null, "timeout")!=null) {
+                                                       
status_list_map.put(EPhpUnitTestStatus.TIMEOUT, new 
StatusListEntry(Integer.parseInt(parser.getAttributeValue(null, "timeout"))));
+                                               }
                                                
status_list_map.put(EPhpUnitTestStatus.FAILURE, new 
StatusListEntry(Integer.parseInt(parser.getAttributeValue(null, "failure"))));
                                                
status_list_map.put(EPhpUnitTestStatus.ERROR, new 
StatusListEntry(Integer.parseInt(parser.getAttributeValue(null, "error"))));
                                                
status_list_map.put(EPhpUnitTestStatus.CRASH, new 
StatusListEntry(Integer.parseInt(parser.getAttributeValue(null, "crash"))));
diff --git a/src/com/mostc/pftt/results/PhpUnitResultWriter.java 
b/src/com/mostc/pftt/results/PhpUnitResultWriter.java
index dbd69f1..2510892 100644
--- a/src/com/mostc/pftt/results/PhpUnitResultWriter.java
+++ b/src/com/mostc/pftt/results/PhpUnitResultWriter.java
@@ -252,6 +252,7 @@ public class PhpUnitResultWriter extends AbstractPhpUnitRW {
                serial.attribute(null, "percent_total", Integer.toString( 
getTestCount() ));
                serial.attribute(null, "pass", 
Integer.toString(count(EPhpUnitTestStatus.PASS)));
                serial.attribute(null, "pass_percent", Float.toString( 
passRate() ));
+               serial.attribute(null, "timeout", 
Integer.toString(count(EPhpUnitTestStatus.TIMEOUT)));
                serial.attribute(null, "failure", 
Integer.toString(count(EPhpUnitTestStatus.FAILURE)));
                serial.attribute(null, "failure_percent", Float.toString( 
100.0f * (((float)count(EPhpUnitTestStatus.FAILURE))/((float)getTestCount()))));
                serial.attribute(null, "error", 
Integer.toString(count(EPhpUnitTestStatus.ERROR)));
diff --git a/src/com/mostc/pftt/results/PhptResultReader.java 
b/src/com/mostc/pftt/results/PhptResultReader.java
index 39772b9..9cb0ed8 100644
--- a/src/com/mostc/pftt/results/PhptResultReader.java
+++ b/src/com/mostc/pftt/results/PhptResultReader.java
@@ -32,6 +32,7 @@ public class PhptResultReader extends AbstractPhptRW {
                PhptTallyFile tally = PhptTallyFile.open(new 
File(dir+"/tally.xml"));
                this.os_name = tally.os_name; 
                status_list_map.put(EPhptTestStatus.PASS, new 
StatusListEntry(tally.pass));
+               status_list_map.put(EPhptTestStatus.TIMEOUT, new 
StatusListEntry(tally.timeout));
                status_list_map.put(EPhptTestStatus.FAIL, new 
StatusListEntry(tally.fail));
                status_list_map.put(EPhptTestStatus.CRASH, new 
StatusListEntry(tally.crash));
                status_list_map.put(EPhptTestStatus.SKIP, new 
StatusListEntry(tally.skip));
@@ -117,12 +118,14 @@ public class PhptResultReader extends AbstractPhptRW {
 
        @Override
        public int count(EPhptTestStatus status) {
-               return status_list_map.get(status).count;
+               StatusListEntry e = status_list_map.get(status); 
+               return e == null ? 0 : e.count;
        }
 
        @Override
        public List<String> getTestNames(EPhptTestStatus status) {
-               return status_list_map.get(status).test_names;
+               StatusListEntry e = status_list_map.get(status); 
+               return e == null ? new java.util.ArrayList<String>(0) : 
e.test_names;
        }
 
        @Override
diff --git a/src/com/mostc/pftt/results/PhptTallyFile.groovy 
b/src/com/mostc/pftt/results/PhptTallyFile.groovy
index 6810833..faeba97 100644
--- a/src/com/mostc/pftt/results/PhptTallyFile.groovy
+++ b/src/com/mostc/pftt/results/PhptTallyFile.groovy
@@ -2,7 +2,7 @@ package com.mostc.pftt.results
 
 class PhptTallyFile {
        public String os_name
-       public int pass, fail, crash, skip, xskip, xfail, xfail_works, 
unsupported, bork, exception
+       public int pass, fail, crash, skip, xskip, xfail, xfail_works, 
unsupported, bork, exception, timeout
          
        static PhptTallyFile open(File file) {
                def root = new XmlSlurper().parse(file);
@@ -10,6 +10,8 @@ class PhptTallyFile {
                        def tally = new PhptTallyFile()
                        tally.os_name = e['@os_name']
                        tally.pass = Integer.parseInt(e['@pass'].text())
+                       if 
(e['@timeout'].text()!=null&&e['@timeout'].text().length()>0)
+                               tally.timeout = 
Integer.parseInt(e['@timeout'].text())
                        tally.fail = Integer.parseInt(e['@fail'].text())
                        tally.crash = Integer.parseInt(e['@crash'].text())
                        tally.skip = Integer.parseInt(e['@skip'].text())
diff --git a/src/com/mostc/pftt/results/PhptTestResult.java 
b/src/com/mostc/pftt/results/PhptTestResult.java
index 66de938..6202173 100644
--- a/src/com/mostc/pftt/results/PhptTestResult.java
+++ b/src/com/mostc/pftt/results/PhptTestResult.java
@@ -226,7 +226,7 @@ public class PhptTestResult {
        }
        
        public void serialize(XmlSerializer serial) throws 
IllegalArgumentException, IllegalStateException, IOException {
-               serialize(serial, shouldStoreAllInfo(status), null);
+               serialize(serial, 
shouldStoreAllInfo(status)||status==EPhptTestStatus.SKIP, null);
        }
        
        public void serialize(XmlSerializer serial, boolean include_all, String 
stylesheet) throws IllegalArgumentException, IllegalStateException, IOException 
{
diff --git a/src/com/mostc/pftt/runner/AbstractPhpUnitTestCaseRunner.java 
b/src/com/mostc/pftt/runner/AbstractPhpUnitTestCaseRunner.java
index a54e205..7ceb24f 100644
--- a/src/com/mostc/pftt/runner/AbstractPhpUnitTestCaseRunner.java
+++ b/src/com/mostc/pftt/runner/AbstractPhpUnitTestCaseRunner.java
@@ -25,7 +25,6 @@ import com.mostc.pftt.results.ITestResultReceiver;
 import com.mostc.pftt.results.PhpUnitTestResult;
 import com.mostc.pftt.runner.LocalPhpUnitTestPackRunner.PhpUnitThread;
 import com.mostc.pftt.scenario.AbstractSAPIScenario;
-import com.mostc.pftt.scenario.ScenarioSet;
 import com.mostc.pftt.scenario.ScenarioSetSetup;
 
 /** runs a single PhpUnitTestCase
@@ -64,7 +63,7 @@ public abstract class AbstractPhpUnitTestCaseRunner extends 
AbstractTestCaseRunn
        protected final PhpUnitTestCase test_case;
        protected final String my_temp_dir;
        protected final PhpIni ini;
-       protected boolean is_crashed;
+       protected boolean is_crashed, is_timeout;
        protected final boolean reflection_only;
 
        public AbstractPhpUnitTestCaseRunner(AbstractSAPIScenario 
sapi_scenario, PhpUnitThread thread, ITestResultReceiver tmgr, Map<String, 
String> globals, Map<String, String> env, ConsoleManager cm, AHost host, 
ScenarioSetSetup scenario_set, PhpBuild build, PhpUnitTestCase test_case, 
String my_temp_dir, Map<String,String> constants, String include_path, String[] 
include_files, PhpIni ini, boolean reflection_only) {
@@ -173,7 +172,7 @@ public abstract class AbstractPhpUnitTestCaseRunner extends 
AbstractTestCaseRunn
                        status = EPhpUnitTestStatus.TEST_EXCEPTION;
                        
                        tmgr.addResult(host, scenario_set, new 
PhpUnitTestResult(test_case, status, scenario_set, host, output, ini, 
run_time_micros, getSAPIOutput(), getSAPIConfig()));
-               } else if (is_crashed) {
+               } else if (is_crashed&&!is_timeout) {
                        if (PAT_CLASS_NOT_FOUND.matcher(output).find()) {
                                status = EPhpUnitTestStatus.UNSUPPORTED;
                                
@@ -257,7 +256,7 @@ public abstract class AbstractPhpUnitTestCaseRunner extends 
AbstractTestCaseRunn
                        }
                        //
                        
-                       if (status==null) {
+                       if (status==null||is_timeout) {
                                // if test had a 'Fatal Error', it might not 
have been able to print the status code at all
                                // (otherwise it should always have a status 
code)
                                status = EPhpUnitTestStatus.ERROR;
diff --git a/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java 
b/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java
index 20b9f11..b2ff102 100644
--- a/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java
+++ b/src/com/mostc/pftt/runner/AbstractPhptTestCaseRunner2.java
@@ -28,7 +28,6 @@ import com.mostc.pftt.results.ITestResultReceiver;
 import com.mostc.pftt.results.PhptTestResult;
 import com.mostc.pftt.runner.LocalPhptTestPackRunner.PhptThread;
 import com.mostc.pftt.scenario.AbstractSAPIScenario;
-import com.mostc.pftt.scenario.ScenarioSet;
 import com.mostc.pftt.scenario.ScenarioSetSetup;
 import com.mostc.pftt.util.ErrorUtil;
 import com.mostc.pftt.util.GZIPOutputStreamLevel;
@@ -50,6 +49,9 @@ public abstract class AbstractPhptTestCaseRunner2 extends 
AbstractPhptTestCaseRu
        protected String skipif_file, test_dir, base_file_name, test_file, 
test_clean, content_type;
        protected PhpIni ini;
        protected boolean not_crashed = true; // @see HttpTestCaseRunner
+       // if is_timeout, test output is still processed the same, only marked 
as TIMEOUT if it would have normally been marked FAIL
+       // (so its possible a test could timeout but still be marked PASS)
+       protected boolean is_timeout = false;
        
        public abstract String getIniActual() throws Exception;
        
@@ -76,7 +78,7 @@ public abstract class AbstractPhptTestCaseRunner2 extends 
AbstractPhptTestCaseRu
                        return;
                
                current_section = EPhptSection.SKIPIF; // @see #getSAPIOutput
-               if (skipif_file == null || ( !evalSkipIf(executeSkipIf()) && 
not_crashed) ) {
+               if (skipif_file == null || ( !evalSkipIf(executeSkipIf()) && 
not_crashed && !is_timeout) ) {
                        current_section = EPhptSection.TEST; // @see 
#getSAPIOutput
                        // no SKIPIF section or executed SKIPIF says to execute 
the TEST section
                        prepareTest();
@@ -215,15 +217,15 @@ public abstract class AbstractPhptTestCaseRunner2 extends 
AbstractPhptTestCaseRu
                        if (host.isWindows()) {
                                if ( (lc_output.contains("only 
")&&(lc_output.contains(" linux")||lc_output.contains(" non 
windows")||lc_output.contains(" non-windows")))||(lc_output.contains("not 
")&&lc_output.contains(" windows")))
                                        // can"t run this test on this OS
-                                       twriter.addResult(host, scenario_set, 
new PhptTestResult(host, EPhptTestStatus.XSKIP, test_case, output, null, null, 
null, ini, null, null, null, null, null, null, null));
+                                       twriter.addResult(host, scenario_set, 
new PhptTestResult(host, 
is_timeout?EPhptTestStatus.TIMEOUT:EPhptTestStatus.XSKIP, test_case, output, 
null, null, null, ini, null, null, null, null, null, null, null));
                                else
-                                       twriter.addResult(host, scenario_set, 
new PhptTestResult(host, EPhptTestStatus.SKIP, test_case, output, null, null, 
null, ini, null, null, null, null, null, null, null));
+                                       twriter.addResult(host, scenario_set, 
new PhptTestResult(host, 
is_timeout?EPhptTestStatus.TIMEOUT:EPhptTestStatus.SKIP, test_case, output, 
null, null, null, ini, null, null, null, null, null, null, null));
                        } else {
                                if ( (lc_output.contains("only 
")&&lc_output.contains(" windows"))||(lc_output.contains("not 
")&&lc_output.contains(" linux")))
                                        // can"t run this test on this OS
-                                       twriter.addResult(host, scenario_set, 
new PhptTestResult(host, EPhptTestStatus.XSKIP, test_case, output, null, null, 
null, ini, null, null, null, null, null, null, null));
+                                       twriter.addResult(host, scenario_set, 
new PhptTestResult(host, 
is_timeout?EPhptTestStatus.TIMEOUT:EPhptTestStatus.XSKIP, test_case, output, 
null, null, null, ini, null, null, null, null, null, null, null));
                                else
-                                       twriter.addResult(host, scenario_set, 
new PhptTestResult(host, EPhptTestStatus.SKIP, test_case, output, null, null, 
null, ini, null, null, null, null, null, null, null));
+                                       twriter.addResult(host, scenario_set, 
new PhptTestResult(host, 
is_timeout?EPhptTestStatus.TIMEOUT:EPhptTestStatus.SKIP, test_case, output, 
null, null, null, ini, null, null, null, null, null, null, null));
                        }
                        
                        // skip this test
@@ -562,14 +564,14 @@ public abstract class AbstractPhptTestCaseRunner2 extends 
AbstractPhptTestCaseRu
 
                PhptTestResult result;
                if (test_case.isXFail()) {
-                       result = notifyNotPass(new PhptTestResult(host, 
EPhptTestStatus.XFAIL_WORKS, test_case, output, null, null, charset, ini, env, 
splitCmdString(), stdin_post, getShellScript(), null, null, 
preoverride_actual));
+                       result = notifyNotPass(new PhptTestResult(host, 
is_timeout?EPhptTestStatus.TIMEOUT:EPhptTestStatus.XFAIL_WORKS, test_case, 
output, null, null, charset, ini, env, splitCmdString(), stdin_post, 
getShellScript(), null, null, preoverride_actual));
                } else {
-                       result = notifyNotPass(notifyFail(new 
PhptTestResult(host, EPhptTestStatus.FAIL, test_case, output, actual_lines, 
expected_lines, charset, ini, env, splitCmdString(), stdin_post, 
getShellScript(), diff, expectf, preoverride_actual, getSAPIOutput(), 
getSAPIConfig())));
+                       result = notifyNotPass(notifyFail(new 
PhptTestResult(host, is_timeout?EPhptTestStatus.TIMEOUT:EPhptTestStatus.FAIL, 
test_case, output, actual_lines, expected_lines, charset, ini, env, 
splitCmdString(), stdin_post, getShellScript(), diff, expectf, 
preoverride_actual, getSAPIOutput(), getSAPIConfig())));
                }
                
                //
                // set result#regex_compiler_dump and result#regex_output dump 
if test result is FAIL or XFAIL_WORKS and test has an EXPECTF or EXPECTREGEX 
section
-               if (test_case.containsSection(EPhptSection.EXPECTF) || 
test_case.containsSection(EPhptSection.EXPECTREGEX)) {
+               if (!is_timeout && 
(test_case.containsSection(EPhptSection.EXPECTF) || 
test_case.containsSection(EPhptSection.EXPECTREGEX))) {
                        // test may be failing due to a bad regular expression 
in test or bug in regular expression engine
                        //
                        // get a debug dump from the regular expression engine 
to save with the result
diff --git a/src/com/mostc/pftt/runner/CliPhpUnitTestCaseRunner.java 
b/src/com/mostc/pftt/runner/CliPhpUnitTestCaseRunner.java
index c44725e..58621b5 100644
--- a/src/com/mostc/pftt/runner/CliPhpUnitTestCaseRunner.java
+++ b/src/com/mostc/pftt/runner/CliPhpUnitTestCaseRunner.java
@@ -12,7 +12,6 @@ import com.mostc.pftt.results.ConsoleManager;
 import com.mostc.pftt.results.ITestResultReceiver;
 import com.mostc.pftt.runner.LocalPhpUnitTestPackRunner.PhpUnitThread;
 import com.mostc.pftt.scenario.CliScenario;
-import com.mostc.pftt.scenario.ScenarioSet;
 import com.mostc.pftt.scenario.ScenarioSetSetup;
 import com.mostc.pftt.util.NTStatus;
 
@@ -52,6 +51,7 @@ public class CliPhpUnitTestCaseRunner extends 
AbstractPhpUnitTestCaseRunner {
                output_str = output_sb.toString();
                
                is_crashed = running_test_handle.isCrashed();
+               is_timeout = running_test_handle.isTimedOut();
        }
        
        @Override
diff --git a/src/com/mostc/pftt/runner/CliPhptTestCaseRunner.java 
b/src/com/mostc/pftt/runner/CliPhptTestCaseRunner.java
index 95b2b43..8de4866 100644
--- a/src/com/mostc/pftt/runner/CliPhptTestCaseRunner.java
+++ b/src/com/mostc/pftt/runner/CliPhptTestCaseRunner.java
@@ -248,7 +248,10 @@ public class CliPhptTestCaseRunner extends 
AbstractPhptTestCaseRunner2 {
                        output_str = doExecuteTest();
                }
                
-               if (running_test_handle.isCrashed()) {
+               if (running_test_handle.isTimedOut()) {
+                       is_timeout = true;
+                       
+               } else if (running_test_handle.isCrashed()) {
                        not_crashed = false; // @see #runTest
                        
                        int exit_code = running_test_handle.getExitCode();
diff --git a/src/com/mostc/pftt/runner/HttpPhpUnitTestCaseRunner.java 
b/src/com/mostc/pftt/runner/HttpPhpUnitTestCaseRunner.java
index d208c21..9c4688d 100644
--- a/src/com/mostc/pftt/runner/HttpPhpUnitTestCaseRunner.java
+++ b/src/com/mostc/pftt/runner/HttpPhpUnitTestCaseRunner.java
@@ -275,6 +275,7 @@ public class HttpPhpUnitTestCaseRunner extends 
AbstractPhpUnitTestCaseRunner {
                                getMaxTestRuntimeSeconds(),
                                new Runnable() {
                                        public void run() {
+                                               is_timeout = true;
                                                if (web!=null)
                                                        web.close(cm);
                                        }
diff --git a/src/com/mostc/pftt/runner/HttpPhptTestCaseRunner.java 
b/src/com/mostc/pftt/runner/HttpPhptTestCaseRunner.java
index c65144b..a0521d5 100644
--- a/src/com/mostc/pftt/runner/HttpPhptTestCaseRunner.java
+++ b/src/com/mostc/pftt/runner/HttpPhptTestCaseRunner.java
@@ -350,6 +350,8 @@ public class HttpPhptTestCaseRunner extends 
AbstractPhptTestCaseRunner2 {
                                PhptTestCase.MAX_TEST_TIME_SECONDS,
                                new Runnable() {
                                                public void run() {
+                                                       is_timeout = true;
+                                                       
                                                        
DebuggingHttpClientConnection conn = HttpPhptTestCaseRunner.this.conn.get();
                                                        if (conn!=null) {
                                                                try {
@@ -457,6 +459,8 @@ public class HttpPhptTestCaseRunner extends 
AbstractPhptTestCaseRunner2 {
                                PhptTestCase.MAX_TEST_TIME_SECONDS,
                                new Runnable() {
                                        public void run() {
+                                               is_timeout = true;
+                                               
                                                DebuggingHttpClientConnection 
conn = HttpPhptTestCaseRunner.this.conn.get();
                                                if (conn!=null) {
                                                        try {

Reply via email to