Commit: d20cc9a7717da6d4e19f9e8ecbc6e26b6c0d8850 Author: Matt Ficken <v-maf...@microsoft.com> Fri, 26 Jul 2013 00:04:51 -0700 Parents: 9c3074b9b5968439e5ea24a24a89dcfc077ccf2b Branches: master
Link: http://git.php.net/?p=pftt2.git;a=commitdiff;h=d20cc9a7717da6d4e19f9e8ecbc6e26b6c0d8850 Log: result-pack format changes Former-commit-id: f3f1e1428aee4a568bd1895e5c289437959f2a21 Changed paths: M src/com/mostc/pftt/results/ITestResultReceiver.java M src/com/mostc/pftt/results/LocalConsoleManager.java M src/com/mostc/pftt/results/PhpResultPack.java M src/com/mostc/pftt/results/PhpResultPackReader.java M src/com/mostc/pftt/results/PhpResultPackWriter.java M src/com/mostc/pftt/results/PhpUnitResultWriter.java M src/com/mostc/pftt/results/PhpUnitTestResult.java M src/com/mostc/pftt/results/PhptResultReader.java
diff --git a/src/com/mostc/pftt/results/ITestResultReceiver.java b/src/com/mostc/pftt/results/ITestResultReceiver.java index 7676339..e33cf75 100644 --- a/src/com/mostc/pftt/results/ITestResultReceiver.java +++ b/src/com/mostc/pftt/results/ITestResultReceiver.java @@ -4,19 +4,20 @@ import com.mostc.pftt.host.AHost; import com.mostc.pftt.model.TestCase; import com.mostc.pftt.model.app.PhpUnitSourceTestPack; import com.mostc.pftt.model.app.PhpUnitTestCase; +import com.mostc.pftt.model.core.PhptSourceTestPack; import com.mostc.pftt.model.core.PhptTestCase; import com.mostc.pftt.model.ui.UITestPack; import com.mostc.pftt.scenario.ScenarioSetSetup; public interface ITestResultReceiver { - public void addResult(AHost this_host, ScenarioSetSetup this_scenario_set, PhptTestResult result); + public void addResult(AHost this_host, ScenarioSetSetup this_scenario_set, PhptSourceTestPack src_test_pack, PhptTestResult result); public void addResult(AHost host, ScenarioSetSetup scenario_set, PhpUnitTestResult result); public void addGlobalException(AHost host, String text); public void addTestException(AHost this_host, ScenarioSetSetup this_scenario_set, TestCase test_file, Throwable ex, Object a); public void addTestException(AHost this_host, ScenarioSetSetup this_scenario_set, TestCase test_case, Throwable ex, Object a, Object b); - public void setTotalCount(int size); - public void notifyStart(AHost this_host, ScenarioSetSetup this_scenario_set, PhptTestCase test_case); + + public void notifyStart(AHost this_host, ScenarioSetSetup this_scenario_set, PhptSourceTestPack src_test_pack, PhptTestCase test_case); public void notifyStart(AHost host, ScenarioSetSetup scenario_set, PhpUnitSourceTestPack src_test_pack, PhpUnitTestCase test_case); public void notifyStart(AHost host, ScenarioSetSetup scenario_set, UITestPack test_pack, String web_browser_name_and_version, String test_name); } diff --git a/src/com/mostc/pftt/results/LocalConsoleManager.java b/src/com/mostc/pftt/results/LocalConsoleManager.java index 636d248..686e0f6 100644 --- a/src/com/mostc/pftt/results/LocalConsoleManager.java +++ b/src/com/mostc/pftt/results/LocalConsoleManager.java @@ -192,7 +192,7 @@ public class LocalConsoleManager implements ConsoleManager { last_clue_msg = new WeakReference<String>(string); break; case TIP: - doPrintMultiline("PFTT: ", string); + doPrintMultiline("TIP: ", string); break; default: doPrintMultiline("PFTT: "+ctx_str+": ", string); diff --git a/src/com/mostc/pftt/results/PhpResultPack.java b/src/com/mostc/pftt/results/PhpResultPack.java index c6e4308..72dc4ed 100644 --- a/src/com/mostc/pftt/results/PhpResultPack.java +++ b/src/com/mostc/pftt/results/PhpResultPack.java @@ -55,7 +55,8 @@ public abstract class PhpResultPack { public abstract File getResultPackPath(); public abstract void close(); - public abstract AbstractPhptRW getPHPT(AHost host, ScenarioSetSetup scenario_set); + public abstract AbstractPhptRW getPHPT(AHost host, ScenarioSetSetup scenario_set, String test_pack_name); + public abstract Collection<AbstractPhptRW> getPHPT(AHost host, String test_pack_name); public abstract Collection<AbstractPhptRW> getPHPT(AHost host); public abstract Collection<AbstractPhptRW> getPHPT(); public abstract Collection<AbstractPhpUnitRW> getPhpUnit(AHost host, ScenarioSetSetup scenario_set); diff --git a/src/com/mostc/pftt/results/PhpResultPackReader.java b/src/com/mostc/pftt/results/PhpResultPackReader.java index 3b7ce28..abd828a 100644 --- a/src/com/mostc/pftt/results/PhpResultPackReader.java +++ b/src/com/mostc/pftt/results/PhpResultPackReader.java @@ -76,15 +76,32 @@ public class PhpResultPackReader extends PhpResultPack { continue; String scenario_set_name = scenario_dir.getName(); - PhptResultReader phpt_reader = new PhptResultReader(); - phpt_reader.open(cm, scenario_dir, scenario_set_name, reader.build_info, reader.test_pack_branch, reader.test_pack_version); - HashMap<String,AbstractPhptRW> map_a = reader.phpt_reader_map.get(host_name); + HashMap<String,HashMap<String,AbstractPhptRW>> map_a = reader.phpt_reader_map.get(host_name); if (map_a==null) { - map_a = new HashMap<String,AbstractPhptRW>(7); + map_a = new HashMap<String,HashMap<String,AbstractPhptRW>>(3); reader.phpt_reader_map.put(host_name, map_a); } - map_a.put(scenario_set_name, phpt_reader); + File[] dirs2 = scenario_dir.listFiles(); + if (dirs2==null) + continue; + for ( File test_pack_dir : dirs2 ) { + HashMap<String,AbstractPhptRW> map_b = map_a.get(scenario_set_name); + if (map_b==null) { + map_b = new HashMap<String,AbstractPhptRW>(7); + map_a.put(scenario_set_name, map_b); + } + + PhptResultReader phpt_reader = new PhptResultReader(); + try { + phpt_reader.open(cm, test_pack_dir, scenario_set_name, reader.build_info, reader.test_pack_branch, reader.test_pack_version); + } catch ( Exception ex ) { + ex.printStackTrace(); + continue; + } + + map_b.put(test_pack_dir.getName(), phpt_reader); + } } } } // end protected static void readPhpt @@ -179,7 +196,7 @@ public class PhpResultPackReader extends PhpResultPack { } // end protected static void readPhpUnit // // - protected final HashMap<String,HashMap<String,AbstractPhptRW>> phpt_reader_map; + protected final HashMap<String,HashMap<String,HashMap<String,AbstractPhptRW>>> phpt_reader_map; protected final HashMap<String,HashMap<String,HashMap<String,AbstractPhpUnitRW>>> php_unit_reader_map; protected final HashMap<String,HashMap<String,HashMap<String,HashMap<String,UITestReader>>>> ui_test_reader_map; PhpBuildInfo build_info; @@ -191,7 +208,7 @@ public class PhpResultPackReader extends PhpResultPack { super(host); this.file = file; ui_test_reader_map = new HashMap<String,HashMap<String,HashMap<String,HashMap<String,UITestReader>>>>(3); - phpt_reader_map = new HashMap<String,HashMap<String,AbstractPhptRW>>(3); + phpt_reader_map = new HashMap<String,HashMap<String,HashMap<String,AbstractPhptRW>>>(3); php_unit_reader_map = new HashMap<String,HashMap<String,HashMap<String,AbstractPhpUnitRW>>>(3); } @@ -201,19 +218,39 @@ public class PhpResultPackReader extends PhpResultPack { } @Override - public AbstractPhptRW getPHPT(AHost host, ScenarioSetSetup scenario_set) { - return getPHPT(host.getName(), scenario_set); + public AbstractPhptRW getPHPT(AHost host, ScenarioSetSetup scenario_set, String test_pack_name) { + return getPHPT(host.getName(), scenario_set, test_pack_name); } - public AbstractPhptRW getPHPT(String host_name, ScenarioSetSetup scenario_set) { + public AbstractPhptRW getPHPT(String host_name, ScenarioSetSetup scenario_set, String test_pack_name) { host_name = host_name.toLowerCase(); - HashMap<String,AbstractPhptRW> map_a = phpt_reader_map.get(host_name); - if (map_a==null) { - map_a = new HashMap<String,AbstractPhptRW>(); - phpt_reader_map.put(host_name, map_a); - } + HashMap<String,HashMap<String,AbstractPhptRW>> map_a = phpt_reader_map.get(host_name); + if (map_a==null) + return null; String scenario_set_name = scenario_set.getNameWithVersionInfo().toLowerCase(); - return map_a.get(scenario_set_name); + HashMap<String,AbstractPhptRW> map_b = map_a.get(scenario_set_name); + if (map_b==null) + return null; + return map_b.get(test_pack_name); + } + + @Override + public Collection<AbstractPhptRW> getPHPT(AHost host, String test_pack_name) { + return getPHPT(host.getName(), test_pack_name); + } + + public Collection<AbstractPhptRW> getPHPT(String host_name, String test_pack_name) { + host_name = host_name.toLowerCase(); + HashMap<String,HashMap<String,AbstractPhptRW>> map_a = phpt_reader_map.get(host_name); + LinkedList<AbstractPhptRW> out = new LinkedList<AbstractPhptRW>(); + if (map_a!=null) { + HashMap<String,AbstractPhptRW> map_b = map_a.get(test_pack_name); + if (map_b!=null) { + for ( AbstractPhptRW b : map_b.values() ) + out.add(b); + } + } + return out; } @Override @@ -223,12 +260,13 @@ public class PhpResultPackReader extends PhpResultPack { public Collection<AbstractPhptRW> getPHPT(String host_name) { host_name = host_name.toLowerCase(); - HashMap<String,AbstractPhptRW> map_a = phpt_reader_map.get(host_name); - if (map_a==null) { - map_a = new HashMap<String,AbstractPhptRW>(); - phpt_reader_map.put(host_name, map_a); + HashMap<String,HashMap<String,AbstractPhptRW>> map_a = phpt_reader_map.get(host_name); + LinkedList<AbstractPhptRW> out = new LinkedList<AbstractPhptRW>(); + if (map_a!=null) { + for ( HashMap<String,AbstractPhptRW> b : map_a.values() ) + out.addAll(b.values()); } - return map_a.values(); + return out; } @Override @@ -236,7 +274,8 @@ public class PhpResultPackReader extends PhpResultPack { LinkedList<AbstractPhptRW> out = new LinkedList<AbstractPhptRW>(); for ( String host_name : phpt_reader_map.keySet() ) { for ( String scenario_set_name : phpt_reader_map.get(host_name).keySet() ) { - out.add(phpt_reader_map.get(host_name).get(scenario_set_name)); + for ( String test_pack_name : phpt_reader_map.get(host_name).get(scenario_set_name).keySet() ) + out.add(phpt_reader_map.get(host_name).get(scenario_set_name).get(test_pack_name)); } } return out; diff --git a/src/com/mostc/pftt/results/PhpResultPackWriter.java b/src/com/mostc/pftt/results/PhpResultPackWriter.java index ddd34bf..03320f0 100644 --- a/src/com/mostc/pftt/results/PhpResultPackWriter.java +++ b/src/com/mostc/pftt/results/PhpResultPackWriter.java @@ -42,7 +42,7 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec protected File telem_dir; protected final LocalHost local_host; protected final HashMap<AHost,HashMap<String,UITestScenarioSetGroup>> ui_test_writer_map; - protected final HashMap<AHost,HashMap<ScenarioSetSetup,PhptResultWriter>> phpt_writer_map; + protected final HashMap<AHost,HashMap<ScenarioSetSetup,HashMap<String,PhptResultWriter>>> phpt_writer_map; protected final HashMap<AHost,HashMap<String,PhpUnitScenarioSetGroup>> phpunit_writer_map; protected PrintWriter global_exception_writer; protected LocalConsoleManager cm; @@ -113,7 +113,7 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec this.config = config; ui_test_writer_map = new HashMap<AHost,HashMap<String,UITestScenarioSetGroup>>(16); - phpt_writer_map = new HashMap<AHost,HashMap<ScenarioSetSetup,PhptResultWriter>>(16); + phpt_writer_map = new HashMap<AHost,HashMap<ScenarioSetSetup,HashMap<String,PhptResultWriter>>>(3); phpunit_writer_map = new HashMap<AHost,HashMap<String,PhpUnitScenarioSetGroup>>(16); cm.w = this; @@ -192,6 +192,16 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec } + protected abstract class PhptQueueEntry extends HSResultQueueEntry { + protected final PhptSourceTestPack src_test_pack; + + protected PhptQueueEntry(AHost this_host, ScenarioSetSetup this_scenario_set_setup, PhptSourceTestPack src_test_pack) { + super(this_host, this_scenario_set_setup); + this.src_test_pack = src_test_pack; + } + + } + protected abstract class UIQueueEntry extends HSResultQueueEntry { protected final String web_browser_name_and_version; protected final UITestPack test_pack; @@ -322,18 +332,18 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec return b; } // end protected UITestScenarioSetGroup getCreateUITestWriter - protected class PhptResultQueueEntry extends HSResultQueueEntry { + protected class PhptResultQueueEntry extends PhptQueueEntry { protected final PhptTestResult this_result; - protected PhptResultQueueEntry(AHost this_host, ScenarioSetSetup this_scenario_set_setup, PhptTestResult this_result) { - super(this_host, this_scenario_set_setup); + protected PhptResultQueueEntry(AHost this_host, ScenarioSetSetup this_scenario_set_setup, PhptSourceTestPack src_test_pack, PhptTestResult this_result) { + super(this_host, this_scenario_set_setup, src_test_pack); this.this_result = this_result; } @Override public void handle() throws IOException { config.processPhptTestResult(cm, this_result); - PhptResultWriter w = getCreatePhptResultWriter(this_host, this_scenario_set_setup); + PhptResultWriter w = getCreatePhptResultWriter(this_host, this_scenario_set_setup, src_test_pack); w.writeResult(cm, this_host, this_scenario_set_setup, this_result); this_result.extra = null; @@ -353,19 +363,30 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec } // end protected class PhptResultQueueEntry - protected PhptResultWriter getCreatePhptResultWriter(AHost this_host, ScenarioSetSetup this_scenario_set_setup) throws IOException { - HashMap<ScenarioSetSetup,PhptResultWriter> smap = phpt_writer_map.get(this_host); - PhptResultWriter w; - if (smap==null) { - smap = new HashMap<ScenarioSetSetup,PhptResultWriter>(); - w = new PhptResultWriter(phpt_telem_dir(this_host, this_scenario_set_setup), this_host, this_scenario_set_setup, build_info, test_pack_branch, test_pack_version); - phpt_writer_map.put(this_host, smap); - smap.put(this_scenario_set_setup, w); + protected PhptResultWriter getCreatePhptResultWriter(AHost this_host, ScenarioSetSetup this_scenario_set_setup, PhptSourceTestPack test_pack) throws IOException { + return getCreatePhptResultWriter(this_host, this_scenario_set_setup, test_pack.getNameAndVersionString()); + } + + protected PhptResultWriter getCreatePhptResultWriter(AHost this_host, ScenarioSetSetup this_scenario_set_setup, String test_pack_name) throws IOException { + HashMap<ScenarioSetSetup,HashMap<String,PhptResultWriter>> a = phpt_writer_map.get(this_host); + HashMap<String,PhptResultWriter> b; + PhptResultWriter w = null; + if (a==null) { + a = new HashMap<ScenarioSetSetup,HashMap<String,PhptResultWriter>>(); + b = new HashMap<String,PhptResultWriter>(); + phpt_writer_map.put(this_host, a); + a.put(this_scenario_set_setup, b); + w = new PhptResultWriter(phpt_telem_dir(this_host, this_scenario_set_setup, test_pack_name), this_host, this_scenario_set_setup, build_info, test_pack_branch, test_pack_version); + b.put(test_pack_name, w); } else { - w = smap.get(this_scenario_set_setup); + b = a.get(this_scenario_set_setup); + if (b==null) + a.put(this_scenario_set_setup, b = new HashMap<String,PhptResultWriter>()); + else + w = b.get(test_pack_name); if (w==null) { - w = new PhptResultWriter(phpt_telem_dir(this_host, this_scenario_set_setup), this_host, this_scenario_set_setup, build_info, test_pack_branch, test_pack_version); - smap.put(this_scenario_set_setup, w); + w = new PhptResultWriter(phpt_telem_dir(this_host, this_scenario_set_setup, test_pack_name), this_host, this_scenario_set_setup, build_info, test_pack_branch, test_pack_version); + b.put(test_pack_name, w); } } return w; @@ -393,8 +414,6 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec PhpUnitResultWriter w = sg.getWriter(this_scenario_set_setup); w.writeResult(cm.phpunit_gui!=null, this_result); - this_result.extra = null; - this_result.code_coverage = null; // show on console // TODO @@ -461,17 +480,17 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec return b; } // end protected PhpUnitScenarioSetGroup getCreatePhpUnitResultWriter - protected class PhptTestStartQueueEntry extends HSResultQueueEntry { + protected class PhptTestStartQueueEntry extends PhptQueueEntry { protected final String test_name; - public PhptTestStartQueueEntry(AHost host, ScenarioSetSetup scenario_set_setup, String test_name) { - super(host, scenario_set_setup); + public PhptTestStartQueueEntry(AHost host, ScenarioSetSetup scenario_set_setup, PhptSourceTestPack src_test_pack, String test_name) { + super(host, scenario_set_setup, src_test_pack); this.test_name = test_name; } @Override public void handle() throws IllegalArgumentException, IllegalStateException, IOException { - getCreatePhptResultWriter(this_host, this_scenario_set_setup).notifyStart(test_name); + getCreatePhptResultWriter(this_host, this_scenario_set_setup, src_test_pack).notifyStart(test_name); } } // end protected class PhptTestStartQueueEntry @@ -521,8 +540,8 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec } // end protected class UITestStartQueueEntry @Override - public void notifyStart(AHost host, ScenarioSetSetup scenario_set_setup, PhptTestCase test_case) { - results.add(new PhptTestStartQueueEntry(host, scenario_set_setup, test_case.getName())); + public void notifyStart(AHost host, ScenarioSetSetup scenario_set_setup, PhptSourceTestPack src_test_pack, PhptTestCase test_case) { + results.add(new PhptTestStartQueueEntry(host, scenario_set_setup, src_test_pack, test_case.getName())); } @Override @@ -558,7 +577,7 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec public void addTestException(AHost this_host, ScenarioSetSetup this_scenario_set_setup, TestCase test_case, Throwable ex, Object a, Object b) { ex.printStackTrace(); // XXX provide to ConsoleManager } - public void addTestException(AHost this_host, ScenarioSetSetup this_scenario_set_setup, PhptTestCase test_case, Throwable ex, Object a, Object b) { + public void addTestException(AHost this_host, ScenarioSetSetup this_scenario_set_setup, PhptSourceTestPack src_test_pack, PhptTestCase test_case, Throwable ex, Object a, Object b) { String ex_str = ErrorUtil.toString(ex); if (a!=null) ex_str += " a="+a; @@ -570,32 +589,38 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec } // count exceptions as a result (the worst kind of failure, a pftt failure) - addResult(this_host, this_scenario_set_setup, new PhptTestResult(host, EPhptTestStatus.TEST_EXCEPTION, test_case, ex_str, null, null, null, null, null, null, null, null, null, null, null)); + addResult(this_host, this_scenario_set_setup, src_test_pack, new PhptTestResult(host, EPhptTestStatus.TEST_EXCEPTION, test_case, ex_str, null, null, null, null, null, null, null, null, null, null, null)); } @Override - public void addResult(AHost this_host, ScenarioSetSetup this_scenario_set_setup, PhptTestResult result) { + public void addResult(AHost this_host, ScenarioSetSetup this_scenario_set_setup, PhptSourceTestPack src_test_pack, PhptTestResult result) { // enqueue result to be handled by another thread to avoid delaying every phpt thread - results.add(new PhptResultQueueEntry(this_host, this_scenario_set_setup, result)); + results.add(new PhptResultQueueEntry(this_host, this_scenario_set_setup, src_test_pack, result)); } // TODO rename these protected File ui_test_telem_dir(AHost this_host, ScenarioSetSetup this_scenario_set_setup, UITestPack test_pack, String web_browser_name_and_version) { if (this_scenario_set_setup==null) - return new File(host.joinIntoOnePath(telem_dir.getAbsolutePath(), this_host.getName(), "UI-Test", test_pack.getNameAndVersionInfo().intern())); + return new File(this_host.joinIntoOnePath(telem_dir.getAbsolutePath(), this_host.getName(), "UI-Test", test_pack.getNameAndVersionInfo().intern())); else - return new File(host.joinIntoOnePath(telem_dir.getAbsolutePath(), this_host.getName(), "UI-Test", test_pack.getNameAndVersionInfo().intern(), StringUtil.max(this_scenario_set_setup.getNameWithVersionInfo(), 70), web_browser_name_and_version)); + return new File(this_host.joinIntoOnePath(telem_dir.getAbsolutePath(), this_host.getName(), "UI-Test", test_pack.getNameAndVersionInfo().intern(), StringUtil.max(this_scenario_set_setup.getNameWithVersionInfo(), 70), web_browser_name_and_version)); } protected File phpunit_telem_dir(AHost this_host, ScenarioSetSetup this_scenario_set_setup, PhpUnitSourceTestPack test_pack) { if (this_scenario_set_setup==null) - return new File(host.joinIntoOnePath(telem_dir.getAbsolutePath(), this_host.getName(), "PhpUnit", test_pack.getNameAndVersionString().intern())); + return new File(this_host.joinIntoOnePath(telem_dir.getAbsolutePath(), this_host.getName(), "PhpUnit", test_pack.getNameAndVersionString().intern())); else - return new File(host.joinIntoOnePath(telem_dir.getAbsolutePath(), this_host.getName(), "PhpUnit", test_pack.getNameAndVersionString().intern(), StringUtil.max(this_scenario_set_setup.getNameWithVersionInfo(), 70))); + return new File(this_host.joinIntoOnePath(telem_dir.getAbsolutePath(), this_host.getName(), "PhpUnit", test_pack.getNameAndVersionString().intern(), StringUtil.max(this_scenario_set_setup.getNameWithVersionInfo(), 70))); } - protected File phpt_telem_dir(AHost this_host, ScenarioSetSetup this_scenario_set_setup) { - return new File(host.joinIntoOnePath(telem_dir.getAbsolutePath(), this_host.getName(), "PHPT", StringUtil.max(this_scenario_set_setup.getNameWithVersionInfo(), 70))); + protected File phpt_telem_dir(AHost this_host, ScenarioSetSetup this_scenario_set_setup, String test_pack_name) { + return new File(this_host.joinIntoOnePath( + telem_dir.getAbsolutePath(), + this_host.getName(), + "PHPT", + test_pack_name, + this_scenario_set_setup==null?"":StringUtil.max(this_scenario_set_setup.getNameWithVersionInfo(), 70) + )); } @Override @@ -612,21 +637,21 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec results.add(new PhpUnitResultQueueEntry(host, scenario_set_setup, result)); } - protected class NotifyPhptFinishedEntry extends HSResultQueueEntry { + protected class NotifyPhptFinishedEntry extends PhptQueueEntry { - protected NotifyPhptFinishedEntry(AHost this_host, ScenarioSetSetup this_scenario_set_setup) { - super(this_host, this_scenario_set_setup); + protected NotifyPhptFinishedEntry(AHost this_host, ScenarioSetSetup this_scenario_set_setup, PhptSourceTestPack src_test_pack) { + super(this_host, this_scenario_set_setup, src_test_pack); } @Override public void handle() throws IllegalArgumentException, IllegalStateException, IOException { - getCreatePhptResultWriter(this_host, this_scenario_set_setup).close(); + getCreatePhptResultWriter(this_host, this_scenario_set_setup, src_test_pack).close(); } } - public void notifyPhptFinished(AHost host, ScenarioSetSetup scenario_set) { - results.add(new NotifyPhptFinishedEntry(host, scenario_set)); + public void notifyPhptFinished(AHost host, ScenarioSetSetup scenario_set, PhptSourceTestPack src_test_pack) { + results.add(new NotifyPhptFinishedEntry(host, scenario_set, src_test_pack)); } protected class NotifyPhpUnitFinishedEntry extends PhpUnitQueueEntry { @@ -724,11 +749,26 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec ex.printStackTrace(); } } // end protected void doClose + + @Override + public Collection<AbstractPhptRW> getPHPT(AHost host, String test_pack_name) { + HashMap<ScenarioSetSetup,HashMap<String,PhptResultWriter>> map_a = phpt_writer_map.get(host); + if (map_a==null) + return null; + ArrayList<AbstractPhptRW> out = new ArrayList<AbstractPhptRW>(map_a.size()); + for ( HashMap<String,PhptResultWriter> b : map_a.values() ) { + for ( String c : b.keySet() ) { + if (c.equalsIgnoreCase(test_pack_name)) + out.add(b.get(c)); + } + } + return out; + } @Override - public AbstractPhptRW getPHPT(AHost host, ScenarioSetSetup scenario_set) { + public AbstractPhptRW getPHPT(AHost host, ScenarioSetSetup scenario_set, String test_pack_name) { try { - return getCreatePhptResultWriter(host, scenario_set); + return getCreatePhptResultWriter(host, scenario_set, test_pack_name); } catch (IOException e) { e.printStackTrace(); } @@ -737,11 +777,12 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec @Override public Collection<AbstractPhptRW> getPHPT(AHost host) { - HashMap<ScenarioSetSetup,PhptResultWriter> map_a = phpt_writer_map.get(host); + HashMap<ScenarioSetSetup,HashMap<String,PhptResultWriter>> map_a = phpt_writer_map.get(host); if (map_a==null) return null; ArrayList<AbstractPhptRW> out = new ArrayList<AbstractPhptRW>(map_a.size()); - out.addAll(map_a.values()); + for ( HashMap<String,PhptResultWriter> b : map_a.values() ) + out.addAll(b.values()); return out; } @@ -750,7 +791,7 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec LinkedList<AbstractPhptRW> out = new LinkedList<AbstractPhptRW>(); for ( AHost host : phpt_writer_map.keySet() ) { for ( ScenarioSetSetup scenario_set : phpt_writer_map.get(host).keySet() ) { - out.add(phpt_writer_map.get(host).get(scenario_set)); + out.addAll(phpt_writer_map.get(host).get(scenario_set).values()); } } return out; @@ -793,11 +834,7 @@ public class PhpResultPackWriter extends PhpResultPack implements ITestResultRec } return out; } - @Override - public void setTotalCount(int size) { - // TODO temp get rid of method - } - + @Override public PhpBuildInfo getBuildInfo() { return build_info; diff --git a/src/com/mostc/pftt/results/PhpUnitResultWriter.java b/src/com/mostc/pftt/results/PhpUnitResultWriter.java index 3270310..78b0ec4 100644 --- a/src/com/mostc/pftt/results/PhpUnitResultWriter.java +++ b/src/com/mostc/pftt/results/PhpUnitResultWriter.java @@ -43,7 +43,7 @@ import com.mostc.pftt.scenario.ScenarioSetSetup; @NotThreadSafe public class PhpUnitResultWriter extends AbstractPhpUnitRW { - protected final KXmlSerializer serial; + protected final KXmlSerializer main_serial, extra_serial; protected final File dir; protected final OutputStream out; protected final PrintWriter all_csv_pw, started_pw; @@ -76,12 +76,14 @@ public class PhpUnitResultWriter extends AbstractPhpUnitRW { File file = new File(dir+"/"+StringUtil.max("phpunit_"+test_pack.getName()+"_"+scenario_set_setup.getNameWithVersionInfo(), 40)+".xml"); // XXX write host, scenario_set and build to file (do in #writeTally or #close) - serial = new KXmlSerializer(); + main_serial = new KXmlSerializer(); + extra_serial = new KXmlSerializer(); - serial.setOutput(out = new BufferedOutputStream(new FileOutputStream(file)), null); + main_serial.setOutput(out = new BufferedOutputStream(new FileOutputStream(file)), "utf-8"); // setup serializer to indent XML (pretty print) so its easy for people to read - serial.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); + main_serial.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); + extra_serial.setFeature("http://xmlpull.org/v1/doc/features.html#indent-output", true); status_list_map = new HashMap<EPhpUnitTestStatus,StatusListEntry>(); for ( EPhpUnitTestStatus status : EPhpUnitTestStatus.values() ) { @@ -157,14 +159,13 @@ public class PhpUnitResultWriter extends AbstractPhpUnitRW { output_by_name.put(test_name, result.output); } - // write file header String test_suite_name = result.test_case.getPhpUnitDist()!=null && result.test_case.getPhpUnitDist().getPath()!=null ? result.test_case.getPhpUnitDist().getPath().getPath() : null; if (is_first_result) { - serial.startDocument("utf-8", null); - serial.setPrefix("pftt", "pftt"); - serial.startTag(null, "testsuites"); + main_serial.startDocument("utf-8", null); + main_serial.setPrefix("pftt", "pftt"); + main_serial.startTag(null, "testsuites"); writeTestSuiteStart(test_suite_name); is_first_result = false; @@ -176,8 +177,27 @@ public class PhpUnitResultWriter extends AbstractPhpUnitRW { // // write result itself - result.serial(serial); - result.extra = null; + result.serial(main_serial); + + // + if ((result.code_coverage!=null||result.extra!=null)&&PhpUnitTestResult.shouldStoreAllInfo(result.status)) { + // store this data in a separate file + File f = new File(dir, result.getName().replace("::", "_").replace("(", "_").replace(")", "").replace(".php", "")+".xml"); + f.getParentFile().mkdirs(); // ensure directory exists + FileWriter fw = new FileWriter(f); + extra_serial.setOutput(fw); + extra_serial.startDocument("utf-8", Boolean.TRUE); + extra_serial.startTag("pftt", "phpUnitTestResult"); + if (result.extra!=null) + result.extra.serial(extra_serial); + if (result.code_coverage!=null) + result.code_coverage.serial(extra_serial); + extra_serial.endTag("pftt", "phpUnitTestResult"); + extra_serial.endDocument(); + extra_serial.flush(); + fw.close(); + } + // // store name, status and run-time in CSV format all_csv_pw.print("'"); @@ -194,13 +214,13 @@ public class PhpUnitResultWriter extends AbstractPhpUnitRW { } private void writeTestSuiteStart(String test_suite_name) throws IllegalArgumentException, IllegalStateException, IOException { - serial.startTag(null, "testsuite"); + main_serial.startTag(null, "testsuite"); if (StringUtil.isNotEmpty(test_suite_name)) - serial.attribute(null, "name", test_suite_name); + main_serial.attribute(null, "name", test_suite_name); } private void writeTestSuiteEnd() throws IllegalArgumentException, IllegalStateException, IOException { - serial.endTag(null, "testsuite"); + main_serial.endTag(null, "testsuite"); } @Override @@ -220,18 +240,18 @@ public class PhpUnitResultWriter extends AbstractPhpUnitRW { writeTestSuiteEnd(); writeTally(); - serial.endTag(null, "testsuites"); - serial.endDocument(); + main_serial.endTag(null, "testsuites"); + main_serial.endDocument(); - serial.flush(); + main_serial.flush(); out.close(); // @see PhpUnitReader#readTally { FileWriter fw = new FileWriter(new File(dir.getAbsolutePath()+"/tally.xml")); - serial.setOutput(fw); + main_serial.setOutput(fw); writeTally(); // write again - this file is smaller and faster to read - serial.flush(); + main_serial.flush(); fw.close(); } // @@ -245,38 +265,38 @@ public class PhpUnitResultWriter extends AbstractPhpUnitRW { } // end public void close private void writeTally() throws IllegalArgumentException, IllegalStateException, IOException { - serial.startTag("pftt", "tally"); + main_serial.startTag("pftt", "tally"); - serial.attribute(null, "test_pack_name_and_version", test_pack_name_and_version); - serial.attribute(null, "os_name", host.getOSNameLong()); - serial.attribute(null, "test_count", Integer.toString(test_count)); - 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))); - serial.attribute(null, "error_percent", Float.toString( 100.0f * (((float)count(EPhpUnitTestStatus.ERROR))/((float)getTestCount())))); - serial.attribute(null, "crash", Integer.toString(count(EPhpUnitTestStatus.CRASH))); - serial.attribute(null, "crash_percent", Float.toString( 100.0f * (((float)count(EPhpUnitTestStatus.CRASH))/((float)getTestCount())))); - serial.attribute(null, "skip", Integer.toString(count(EPhpUnitTestStatus.SKIP))); - serial.attribute(null, "xskip", Integer.toString(count(EPhpUnitTestStatus.XSKIP))); - serial.attribute(null, "warning", Integer.toString(count(EPhpUnitTestStatus.WARNING))); - serial.attribute(null, "notice", Integer.toString(count(EPhpUnitTestStatus.NOTICE))); - serial.attribute(null, "deprecated", Integer.toString(count(EPhpUnitTestStatus.DEPRECATED))); - serial.attribute(null, "not_implemented", Integer.toString(count(EPhpUnitTestStatus.NOT_IMPLEMENTED))); - serial.attribute(null, "unsupported", Integer.toString(count(EPhpUnitTestStatus.UNSUPPORTED))); - serial.attribute(null, "test_exception", Integer.toString(count(EPhpUnitTestStatus.TEST_EXCEPTION))); - serial.attribute(null, "bork", Integer.toString(count(EPhpUnitTestStatus.BORK))); + main_serial.attribute(null, "test_pack_name_and_version", test_pack_name_and_version); + main_serial.attribute(null, "os_name", host.getOSNameLong()); + main_serial.attribute(null, "test_count", Integer.toString(test_count)); + main_serial.attribute(null, "percent_total", Integer.toString( getTestCount() )); + main_serial.attribute(null, "pass", Integer.toString(count(EPhpUnitTestStatus.PASS))); + main_serial.attribute(null, "pass_percent", Float.toString( passRate() )); + main_serial.attribute(null, "timeout", Integer.toString(count(EPhpUnitTestStatus.TIMEOUT))); + main_serial.attribute(null, "failure", Integer.toString(count(EPhpUnitTestStatus.FAILURE))); + main_serial.attribute(null, "failure_percent", Float.toString( 100.0f * (((float)count(EPhpUnitTestStatus.FAILURE))/((float)getTestCount())))); + main_serial.attribute(null, "error", Integer.toString(count(EPhpUnitTestStatus.ERROR))); + main_serial.attribute(null, "error_percent", Float.toString( 100.0f * (((float)count(EPhpUnitTestStatus.ERROR))/((float)getTestCount())))); + main_serial.attribute(null, "crash", Integer.toString(count(EPhpUnitTestStatus.CRASH))); + main_serial.attribute(null, "crash_percent", Float.toString( 100.0f * (((float)count(EPhpUnitTestStatus.CRASH))/((float)getTestCount())))); + main_serial.attribute(null, "skip", Integer.toString(count(EPhpUnitTestStatus.SKIP))); + main_serial.attribute(null, "xskip", Integer.toString(count(EPhpUnitTestStatus.XSKIP))); + main_serial.attribute(null, "warning", Integer.toString(count(EPhpUnitTestStatus.WARNING))); + main_serial.attribute(null, "notice", Integer.toString(count(EPhpUnitTestStatus.NOTICE))); + main_serial.attribute(null, "deprecated", Integer.toString(count(EPhpUnitTestStatus.DEPRECATED))); + main_serial.attribute(null, "not_implemented", Integer.toString(count(EPhpUnitTestStatus.NOT_IMPLEMENTED))); + main_serial.attribute(null, "unsupported", Integer.toString(count(EPhpUnitTestStatus.UNSUPPORTED))); + main_serial.attribute(null, "test_exception", Integer.toString(count(EPhpUnitTestStatus.TEST_EXCEPTION))); + main_serial.attribute(null, "bork", Integer.toString(count(EPhpUnitTestStatus.BORK))); if (ini!=null) { - serial.startTag("pftt", "ini"); - serial.text(ini.toString()); - serial.endTag("pftt", "ini"); + main_serial.startTag("pftt", "ini"); + main_serial.text(ini.toString()); + main_serial.endTag("pftt", "ini"); } - serial.endTag("pftt", "tally"); + main_serial.endTag("pftt", "tally"); } // end private void writeTally @Override diff --git a/src/com/mostc/pftt/results/PhpUnitTestResult.java b/src/com/mostc/pftt/results/PhpUnitTestResult.java index fc1f7a9..390d3ab 100644 --- a/src/com/mostc/pftt/results/PhpUnitTestResult.java +++ b/src/com/mostc/pftt/results/PhpUnitTestResult.java @@ -168,19 +168,9 @@ public class PhpUnitTestResult implements ISerializer { serial.endTag(null, "SAPIConfig"); } - if (code_coverage!=null) { - code_coverage.serial(serial); - } - } else { - if (code_coverage!=null) { - code_coverage.serial(serial); - } } // - if (extra!=null) - extra.serial(serial); - serial.endTag(null, "testcase"); } // end public void serial diff --git a/src/com/mostc/pftt/results/PhptResultReader.java b/src/com/mostc/pftt/results/PhptResultReader.java index 20c1f36..c38943f 100644 --- a/src/com/mostc/pftt/results/PhptResultReader.java +++ b/src/com/mostc/pftt/results/PhptResultReader.java @@ -153,6 +153,7 @@ public class PhptResultReader extends AbstractPhptRW { e.test_names.remove("ext/mbstring/tests/mb_output_handler_pattern-13.phpt"); e.test_names.remove("ext/mbstring/tests/mb_output_handler_pattern-14.phpt"); e.test_names.remove("tests/basic/027.phpt"); + e.test_names.remove("ext/mysql/tests/bug53649.phpt"); e.test_names.remove("ext/iconv/tests/ob_iconv_handler.phpt"); e.test_names.remove("ext/mbstring/tests/mb_decode_numericentity.phpt"); }