Author: krosenvold Date: Mon May 9 16:33:56 2011 New Revision: 1101098 URL: http://svn.apache.org/viewvc?rev=1101098&view=rev Log: [SUREFIRE-735] message when fork fails
Added IT to ensure console output from failing fork is output Removed > from output Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire735ForkFailWithRedirectConsoleOutputIT.java (with props) maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/pom.xml (with props) maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test1.java (with props) maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test2.java (with props) maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test3.java (with props) Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java Modified: maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java?rev=1101098&r1=1101097&r2=1101098&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/output/ForkClient.java Mon May 9 16:33:56 2011 @@ -66,7 +66,6 @@ public class ForkClient { try { - //System.out.println("Recv:" + s.substring( 0, s.length() )); if ( s.length() == 0 ) { return; @@ -75,7 +74,7 @@ public class ForkClient int commma = s.indexOf( ",", 3 ); if ( commma < 0 ) { - System.out.println( ">" + s ); + System.out.println( s ); return; } final Integer channelNumber = new Integer( Integer.parseInt( s.substring( 2, commma ), 16 ) ); @@ -141,12 +140,12 @@ public class ForkClient ( (ConsoleLogger) reporter ).info( createConsoleMessage( remaining ) ); break; default: - System.out.println( ">" + s ); + System.out.println( s ); } } catch ( NumberFormatException e ) { - System.out.println( ">" + s ); + System.out.println( s ); } catch ( ReporterException e ) { Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire735ForkFailWithRedirectConsoleOutputIT.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire735ForkFailWithRedirectConsoleOutputIT.java?rev=1101098&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire735ForkFailWithRedirectConsoleOutputIT.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire735ForkFailWithRedirectConsoleOutputIT.java Mon May 9 16:33:56 2011 @@ -0,0 +1,42 @@ +package org.apache.maven.surefire.its; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.maven.it.VerificationException; + +/** + * @author Kristian Rosenvold + */ +public class Surefire735ForkFailWithRedirectConsoleOutputIT + extends SurefireVerifierTestClass +{ + + public Surefire735ForkFailWithRedirectConsoleOutputIT() + { + super( "/fork-fail" ); + } + + public void testVMStartFail() + throws Exception + { + failNever(); + executeTest(); + verifyTextInLog( "Invalid maximum heap size: -Xmxxxx712743m" ); + } +} Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/Surefire735ForkFailWithRedirectConsoleOutputIT.java ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/pom.xml?rev=1101098&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/pom.xml (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/pom.xml Mon May 9 16:33:56 2011 @@ -0,0 +1,62 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>fork-fail</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Test for failing fork</name> + + <properties><argLine>-Xmxxxx712743m</argLine></properties> + <build> + <plugins> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + <forkMode>once</forkMode> + <argLine>${argLine}</argLine> + <redirectTestOutputToFile>true</redirectTestOutputToFile> + </configuration> + </plugin> + </plugins> + </build> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + +</project> Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test1.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test1.java?rev=1101098&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test1.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test1.java Mon May 9 16:33:56 2011 @@ -0,0 +1,34 @@ +package forkMode; + +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.lang.management.ManagementFactory; + +import junit.framework.TestCase; + +public class Test1 + extends TestCase +{ + + public void test1() throws IOException { + dumpPidFile(this); + } + + public static void dumpPidFile(TestCase test) throws IOException { + String fileName = test.getName() + "-pid"; + File target = new File("target"); + if (! (target.exists() && target.isDirectory()) ) { + target = new File ("."); + } + File pidFile = new File(target, fileName); + FileWriter fw = new FileWriter(pidFile); + // DGF little known trick... this is guaranteed to be unique to the PID + // In fact, it usually contains the pid and the local host name! + String pid = ManagementFactory.getRuntimeMXBean().getName(); + fw.write( pid ); + fw.flush(); + fw.close(); + } + +} Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test1.java ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test2.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test2.java?rev=1101098&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test2.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test2.java Mon May 9 16:33:56 2011 @@ -0,0 +1,15 @@ +package forkMode; + +import java.io.IOException; + +import junit.framework.TestCase; + +public class Test2 + extends TestCase +{ + + public void test2() throws IOException { + Test1.dumpPidFile(this); + } + +} Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test2.java ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test3.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test3.java?rev=1101098&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test3.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test3.java Mon May 9 16:33:56 2011 @@ -0,0 +1,15 @@ +package forkMode; + +import java.io.IOException; + +import junit.framework.TestCase; + +public class Test3 + extends TestCase +{ + + public void test3() throws IOException { + Test1.dumpPidFile(this); + } + +} Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-fail/src/test/java/forkMode/Test3.java ------------------------------------------------------------------------------ svn:eol-style = native