[Nice-commit] Nice/src/nice/tools/testsuite TestNice.java,1.30,1.31 TestCase.java,1.31,1.32
Brought to you by:
bonniot
From: Daniel B. <bo...@us...> - 2005-02-23 16:58:23
|
Update of /cvsroot/nice/Nice/src/nice/tools/testsuite In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20726/src/nice/tools/testsuite Modified Files: TestNice.java TestCase.java Log Message: Allow native compilation of testcases using gcj, with a -gcc command-line option in TestNice. Index: TestCase.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/testsuite/TestCase.java,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** TestCase.java 5 Aug 2004 12:33:21 -0000 1.31 --- TestCase.java 23 Feb 2005 16:58:09 -0000 1.32 *************** *** 333,341 **** compilation.destinationDir = tempDir; compilation.runtimeFile = TestNice.getRuntime(); ! nice.tools.compiler.fun.compile ! (compilation, packageName, null, null, false); return output.statusCode; } ! /** * Runs the main method of the testcase. Only if main method exists and --- 333,372 ---- compilation.destinationDir = tempDir; compilation.runtimeFile = TestNice.getRuntime(); ! ! if (TestNice.getGcc() == null) ! nice.tools.compiler.fun.compile ! (compilation, packageName, null, null, false); ! else ! { ! compilation.output = new File(tempDir, "testcase.jar").getPath(); ! nice.tools.compiler.fun.compile ! (compilation, packageName, ! new File(tempDir, "testcase.exe").getPath(), ! TestNice.getGcc() + "/bin/gcj", ! false); ! } ! return output.statusCode; } ! ! public void runNative() throws TestSuiteException { ! try { ! String[] env = null; ! if (TestNice.getGcc() != null) ! env = new String[]{ "LD_LIBRARY_PATH=" + TestNice.getGcc() + "/lib" }; ! ! Process p = Runtime.getRuntime().exec(TestNice.getTempFolder() + "/testcase.exe", env); ! CharArrayWriter out = new CharArrayWriter(); ! int exitValue = nice.tools.compiler.dispatch.waitFor(p, out); ! // Print the output of the execution. ! System.out.println(out.toString()); ! if (exitValue != 0) ! throw new TestSuiteException("Exit code: " + exitValue); ! } ! catch(IOException e) { ! throw new TestSuiteException(e.getMessage()); ! } ! } ! /** * Runs the main method of the testcase. Only if main method exists and *************** *** 352,355 **** --- 383,394 ---- System.setErr(out); try { + + if (TestNice.getGcc() != null) + { + runNative(); + return; + } + + for(Iterator iter = _niceSourceFiles.iterator(); iter.hasNext();) { NiceSourceFile sourceFile = (NiceSourceFile)iter.next(); Index: TestNice.java =================================================================== RCS file: /cvsroot/nice/Nice/src/nice/tools/testsuite/TestNice.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** TestNice.java 2 Mar 2004 21:44:27 -0000 1.30 --- TestNice.java 23 Feb 2005 16:57:57 -0000 1.31 *************** *** 132,137 **** */ private static Output _output = new ConsoleOutput(); ! ! /** * TODO --- 132,145 ---- */ private static Output _output = new ConsoleOutput(); ! ! ! /** ! The <b>home</b> directory of gcc. ! If you want to use the system-wide version of gcc on a Unix machine, ! this should likely be set to "/usr". ! */ ! private static String _gcc = null; ! ! /** * TODO *************** *** 263,266 **** --- 271,276 ---- if ("-output".equalsIgnoreCase(s)) setOutput(args[i++]); + else if ("-gcc".equalsIgnoreCase(s)) + setGcc(args[i++]); else if ("-comment".equalsIgnoreCase(s)) _writeComments = true; *************** *** 279,283 **** /** * Sets the output of the test engine ! * * @param output TODO */ --- 289,293 ---- /** * Sets the output of the test engine ! * * @param output TODO */ *************** *** 287,291 **** return; } ! output = output.toLowerCase(); if (output.endsWith(".html") || output.endsWith(".htm")) --- 297,301 ---- return; } ! output = output.toLowerCase(); if (output.endsWith(".html") || output.endsWith(".htm")) *************** *** 299,302 **** --- 309,321 ---- + private static void setGcc(String gcc) { + _gcc = gcc; + + // When doing native compilation, we need a jarred runtime + if (_runtime == null) + _runtime = "share/java/nice.jar"; + } + + /** *************** *** 518,521 **** --- 537,546 ---- + static String getGcc() { + return _gcc; + } + + + /** * Returns whether comments should be written to output |