Return-Path: Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 69379 invoked from network); 25 Feb 2001 14:33:41 -0000 Received: from mercury.sun.com (192.9.25.1) by h31.sny.collab.net with SMTP; 25 Feb 2001 14:33:41 -0000 Received: from sunpraha.Czech.Sun.COM ([129.156.76.4]) by mercury.Sun.COM (8.9.3+Sun/8.9.3) with ESMTP id GAA26976 for ; Sun, 25 Feb 2001 06:33:41 -0800 (PST) Received: from czech.sun.com ([129.156.76.101]) by sunpraha.Czech.Sun.COM (8.9.3+Sun/8.9.3/ENSMAIL,v2.1p1) with ESMTP id PAA17030 for ; Sun, 25 Feb 2001 15:33:40 +0100 (CET) Message-ID: <3A991835.34EE5CAE@czech.sun.com> Date: Sun, 25 Feb 2001 15:35:33 +0100 From: Vitezslav Stejskal Organization: SUN Microsystems Czech s.r.o. X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U) X-Accept-Language: cs,en MIME-Version: 1.0 To: ant-dev Subject: [PATCH] for Ant's JUnit task Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N Hi all, I realized troubles with junit task running in separate (fork="yes") JVM. The JUnitTestRunner's main function executed on separate JVM instantiates JUnitTest object and sets it up from arguments passed through the command line. Everything looks fine untill you need to know the output file originally set for the test (outfile attribute in test element of junit task). I needed it in my own formatter, which writes links to files produced by the test and tries to make them relative to the location, where the output file is palced to. As long as I get the instance of JUnitTest object to my formatter I read the output file by the call of JUnitTest.getOutfile, which works fine, when running in the same JVM, where the original junit task was created, but stops to work when task is forked (call of getOutfile always returns null). I used following code in JUnitTask and JUnitTestRunner classes to pass absolute path of output file to the JUnitTest object in forked JVM. Could you, please, include it in the Ant's source code repository, to make it available in next version. Thanks, Vita ---- file: org\apache\tools\ant\taskdefs\optional\junit\JUnitTask.java function: public void execute() CommandlineJava cmd = (CommandlineJava) commandline.clone(); cmd.setClassname("org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner"); // PATCH - begin File fff = project.resolveFile(test.getOutfile()); cmd.createArgument().setValue(test.getName() + "," + fff.getAbsolutePath()); // PATCH - end cmd.createArgument().setValue("haltOnError=" + test.getHaltonerror()); cmd.createArgument().setValue("haltOnFailure=" + test.getHaltonfailure()); if (summary) { log("Running " + test.getName(), Project.MSG_INFO); cmd.createArgument().setValue("formatter=org.apache.tools.ant.taskdefs.optional.junit.SummaryJUnitResultFormatter"); } ---- file: org\apache\tools\ant\taskdefs\optional\junit\JUnitTestRunner.java function: public static void main(String args[]) // PATCH - begin StringTokenizer tok = new StringTokenizer(args[0], ","); JUnitTest t = new JUnitTest(tok.nextToken()); if (tok.hasMoreTokens()) t.setOutfile(tok.nextToken()); // PATCH - end JUnitTestRunner runner = new JUnitTestRunner(t, haltError, haltFail); transferFormatters(runner); runner.run(); System.exit(runner.getRetCode()); -- Vitezslav Stejskal, Software engineer SUN Microsystems Czech s.r.o. e-mail: vitezslav.stejskal@czech.sun.com tel: +420 2 3300-9232