From: <cr...@us...> - 2009-02-22 01:26:14
|
Revision: 5058 http://jnode.svn.sourceforge.net/jnode/?rev=5058&view=rev Author: crawley Date: 2009-02-22 01:26:11 +0000 (Sun, 22 Feb 2009) Log Message: ----------- Final changes to get the harness working on the JNode platform. Modified Paths: -------------- trunk/shell/descriptors/org.jnode.test.shell.xml trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java Modified: trunk/shell/descriptors/org.jnode.test.shell.xml =================================================================== --- trunk/shell/descriptors/org.jnode.test.shell.xml 2009-02-22 01:24:56 UTC (rev 5057) +++ trunk/shell/descriptors/org.jnode.test.shell.xml 2009-02-22 01:26:11 UTC (rev 5058) @@ -40,7 +40,7 @@ <extension point="org.jnode.security.permissions"> <permission class="java.lang.RuntimePermission" name="setIO"/> <permission class="java.lang.RuntimePermission" name="exitVM"/> - <permission class="java.util.PropertyPermission" name="*" actions="read"/> + <permission class="java.util.PropertyPermission" name="*" actions="read,write"/> <permission class="org.jnode.security.JNodePermission" name="loadPlugin"/> <permission class="java.io.FilePermission" name="<<ALL FILES>>" actions="read"/> <permission class="java.io.FilePermission" name="/jnode/tmp/test" actions="read,write,delete"/> Modified: trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java 2009-02-22 01:24:56 UTC (rev 5057) +++ trunk/shell/src/test/org/jnode/test/shell/harness/ClassTestRunner.java 2009-02-22 01:26:11 UTC (rev 5058) @@ -41,6 +41,7 @@ Method method = commandClass.getMethod("main", String[].class); String[] args = spec.getArgs().toArray(new String[0]); method.invoke(null, (Object) args); + flush(); return check() ? 0 : 1; } Modified: trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java 2009-02-22 01:24:56 UTC (rev 5057) +++ trunk/shell/src/test/org/jnode/test/shell/harness/CommandTestRunner.java 2009-02-22 01:26:11 UTC (rev 5058) @@ -46,6 +46,7 @@ sb.append(" ").append(shell.escapeWord(arg)); } int rc = shell.runCommand(sb.toString()); + flush(); return check(rc) ? 0 : 1; } Modified: trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-02-22 01:24:56 UTC (rev 5057) +++ trunk/shell/src/test/org/jnode/test/shell/harness/ScriptTestRunner.java 2009-02-22 01:26:11 UTC (rev 5058) @@ -59,6 +59,7 @@ } int rc = getShell().runCommandFile(tempScriptFile, spec.getCommand(), spec.getArgs().toArray(new String[0])); + flush(); return check(rc) ? 0 : 1; } Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java 2009-02-22 01:24:56 UTC (rev 5057) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestEmu.java 2009-02-22 01:26:11 UTC (rev 5058) @@ -30,8 +30,8 @@ import org.jnode.shell.ShellUtils; /** - * This class performs Emu and CommandShell initialization without exposing - * the Emu APIs at the class loader level. + * This class performs Emu and CommandShell initialization without any static + * dependencies on the Emu class. * * @author cr...@jn... */ Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-02-22 01:24:56 UTC (rev 5057) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestHarness.java 2009-02-22 01:26:11 UTC (rev 5058) @@ -29,6 +29,8 @@ import net.n3.nanoxml.XMLException; +import org.jnode.util.ProxyStream; + /** * This is the entry point class for the command test harness. Its * purpose is to run 'black box' tests on commands and the like. @@ -260,10 +262,17 @@ /** * Save the System streams so that they can be restored. */ + @SuppressWarnings({ "unchecked" }) private void setup() { - savedIn = System.in; - savedOut = System.out; - savedErr = System.err; + if (System.in instanceof ProxyStream<?>) { + savedIn = ((ProxyStream<InputStream>) System.in).getProxiedStream(); + savedOut = ((ProxyStream<PrintStream>) System.out).getProxiedStream(); + savedErr = ((ProxyStream<PrintStream>) System.err).getProxiedStream(); + } else { + savedIn = System.in; + savedOut = System.out; + savedErr = System.err; + } } public void report(String message) { @@ -277,6 +286,12 @@ } } + public void reportDebug(String message) { + if (debug) { + report(message); + } + } + public boolean expect(Object actual, Object expected, String desc) { if (expected.equals(actual)) { return true; Modified: trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java =================================================================== --- trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java 2009-02-22 01:24:56 UTC (rev 5057) +++ trunk/shell/src/test/org/jnode/test/shell/harness/TestRunnerBase.java 2009-02-22 01:26:11 UTC (rev 5058) @@ -37,6 +37,7 @@ import org.jnode.shell.CommandShell; import org.jnode.shell.ShellException; import org.jnode.test.shell.harness.TestSpecification.FileSpecification; +import org.jnode.util.ProxyStream; /** * This base class supplies functions for getting hold of "the shell" for @@ -88,13 +89,16 @@ this.harness = harness; this.usingEmu = TestEmu.initEmu(harness.getRoot()); } - + public CommandShell getShell() throws ShellException { - CommandShell shell = TestEmu.getShell(); - if (shell == null) { - shell = new TestCommandShell(System.in, System.out, System.err); - shell.configureShell(); - } +// CommandShell shell = TestEmu.getShell(); +// if (shell == null) { +// shell = new TestCommandShell(System.in, System.out, System.err); +// shell.configureShell(); +// } +// return shell; + CommandShell shell = new TestCommandShell(System.in, System.out, System.err); + shell.configureShell(); return shell; } @@ -110,6 +114,7 @@ } } + @SuppressWarnings("unchecked") @Override public void setup() throws IOException, TestRunnerException { ensurePluginsLoaded(spec.getTestSet()); @@ -119,13 +124,25 @@ System.setIn(new ByteArrayInputStream(spec.getInputContent().toString().getBytes())); outBucket = new ByteArrayOutputStream(); errBucket = new ByteArrayOutputStream(); + OutputStream out, err; if (harness.isDebug()) { - System.setOut(new PrintStream(new TeeStream(outBucket, System.out))); - System.setErr(new PrintStream(new TeeStream(errBucket, System.err))); + if (System.out instanceof ProxyStream<?>) { + out = ((ProxyStream<PrintStream>) System.out).getProxiedStream(); + err = ((ProxyStream<PrintStream>) System.err).getProxiedStream(); + } else { + out = System.out; + err = System.err; + } + out = new TeeStream(outBucket, out); + err = new TeeStream(errBucket, err); } else { - System.setOut(new PrintStream(outBucket)); - System.setErr(new PrintStream(errBucket)); + out = outBucket; + err = errBucket; } + + System.setOut(new PrintStream(out)); + System.setErr(new PrintStream(err)); + for (FileSpecification fs : spec.getFiles()) { File tempFile = harness.tempFile(fs.getFile()); if (fs.isInput()) { @@ -142,6 +159,12 @@ } } + protected void flush() { + System.out.flush(); + System.err.flush(); + } + + protected boolean checkFiles() throws IOException { boolean ok = true; for (FileSpecification fs : spec.getFiles()) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |