[ https://jira.codehaus.org/browse/SUREFIRE-887?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Kristian Rosenvold closed SUREFIRE-887. --------------------------------------- Resolution: Fixed Fix Version/s: 2.12.2 Assignee: Kristian Rosenvold Fixed in r1369548. Please note this applies only to file-name level filtering. If you use "groups" or similar and it resolves to 0 tests, it will fork no matter > Do not hold forked surefire for debug if there are no tests > ----------------------------------------------------------- > > Key: SUREFIRE-887 > URL: https://jira.codehaus.org/browse/SUREFIRE-887 > Project: Maven Surefire > Issue Type: Improvement > Components: Maven Failsafe Plugin, Maven Surefire Plugin > Affects Versions: 2.12 > Reporter: Marvin Froeder > Assignee: Kristian Rosenvold > Fix For: 2.12.2 > > > This is something a bit annoying. > When I enable debug (by either using -Dmaven.surefire.debug=true or > -Dmaven.failsafe.debug=true) surefire will hold maven execution until a > debugger is connected to the forked process. > The problem is that time to time there are no tests to be executed! > So my patch just skips launching the forked VM if there are no tests to be > executed! > {noformat} > Index: > maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java > =================================================================== > --- > maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java > (revision 1361154) > +++ > maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkStarter.java > (working copy) > @@ -31,6 +31,7 @@ > import java.util.concurrent.Future; > import java.util.concurrent.ThreadPoolExecutor; > import java.util.concurrent.TimeUnit; > + > import org.apache.maven.plugin.surefire.CommonReflector; > import org.apache.maven.plugin.surefire.StartupReportConfiguration; > import org.apache.maven.plugin.surefire.booterclient.output.ForkClient; > @@ -47,6 +48,8 @@ > import org.apache.maven.surefire.providerapi.SurefireProvider; > import org.apache.maven.surefire.report.RunStatistics; > import org.apache.maven.surefire.suite.RunResult; > +import org.apache.maven.surefire.testset.DirectoryScannerParameters; > +import org.apache.maven.surefire.util.DefaultDirectoryScanner; > import org.codehaus.plexus.util.cli.CommandLineException; > import org.codehaus.plexus.util.cli.CommandLineTimeOutException; > import org.codehaus.plexus.util.cli.CommandLineUtils; > @@ -66,6 +69,7 @@ > * @author Dan Fabulich > * @author Carlos Sanchez > * @author Kristian Rosenvold > + * @author <a href='mailto:marvin[at]marvinformatics[dot]com'>Marvin > Froeder</a> > * @version $Id$ > */ > public class ForkStarter > @@ -106,6 +110,12 @@ > final String requestedForkMode = forkConfiguration.getForkMode(); > try > { > + > + if ( Boolean.FALSE.equals( hasTestToRun() ) ) > + { > + return new RunResult( 0, 0, 0, 0 ); > + } > + > if ( ForkConfiguration.FORK_ONCE.equals( requestedForkMode ) ) > { > final ForkClient forkClient = > @@ -134,6 +144,24 @@ > return result; > } > > + private Boolean hasTestToRun() > + { > + // verify if there are tests to be executed > + DirectoryScannerParameters params = > providerConfiguration.getDirScannerParams(); > + if ( params == null ) > + { > + //unknow > + return null; > + } > + > + DefaultDirectoryScanner scanner = > + new DefaultDirectoryScanner( params.getTestClassesDirectory(), > params.getIncludes(), params.getExcludes(), > + params.getSpecificTests() ); > + > + String[] tests = scanner.collectTests(); > + return tests.length != 0; > + } > + > private RunResult runSuitesForkPerTestSet( final Properties properties, > int forkCount ) > throws SurefireBooterForkException > { > Index: > surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java > =================================================================== > --- > surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java > (revision 1361154) > +++ > surefire-api/src/main/java/org/apache/maven/surefire/util/DefaultDirectoryScanner.java > (working copy) > @@ -108,7 +108,7 @@ > return testClass; > } > > - String[] collectTests() > + public String[] collectTests() > { > String[] tests = EMPTY_STRING_ARRAY; > if ( basedir.exists() ) > Index: > surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java > =================================================================== > --- > surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java > (revision 1361154) > +++ > surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/fixture/SurefireLauncher.java > (working copy) > @@ -42,6 +42,7 @@ > * Thread safe only for running in "classes" mode. > * > * @author Kristian Rosenvold > + * @author <a href='mailto:marvin[at]marvinformatics[dot]com'>Marvin > Froeder</a> > */ > public class SurefireLauncher > { > @@ -466,4 +467,10 @@ > { > return surefireVerifier; > } > + > + public SurefireLauncher debugSurefire( ) > + { > + return addGoal( "-Dmaven.surefire.debug=true" ); > + } > + > } > Index: > surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/NonStopDebugIT.java > =================================================================== > --- > surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/NonStopDebugIT.java > (revision 0) > +++ > surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/NonStopDebugIT.java > (revision 0) > @@ -0,0 +1,36 @@ > +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.surefire.its.fixture.SurefireIntegrationTestCase; > + > +/** > + * Do not hold surefire execution if debug mode is on but there are no tests. > + * > + * @author <a href='mailto:marvin[at]marvinformatics[dot]com'>Marvin > Froeder</a> > + */ > +public class NonStopDebugIT > + extends SurefireIntegrationTestCase > +{ > + public void testArgLine() > + { > + unpack( "/notests" > ).debugSurefire().executeTest().verifyErrorFreeLog(); > + } > +} > Index: surefire-integration-tests/src/test/resources/notests/pom.xml > =================================================================== > --- surefire-integration-tests/src/test/resources/notests/pom.xml > (revision 0) > +++ surefire-integration-tests/src/test/resources/notests/pom.xml > (revision 0) > @@ -0,0 +1,49 @@ > +<?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>notests</artifactId> > + <version>1.0-SNAPSHOT</version> > + > + <dependencies> > + <dependency> > + <groupId>junit</groupId> > + <artifactId>junit</artifactId> > + <version>4.8.1</version> > + <scope>test</scope> > + </dependency> > + </dependencies> > + > + <build> > + <plugins> > + <plugin> > + <groupId>org.apache.maven.plugins</groupId> > + <artifactId>maven-surefire-plugin</artifactId> > + <version>${surefire.version}</version> > + </plugin> > + </plugins> > + </build> > + > +</project> > {noformat} -- This message is automatically generated by JIRA. If you think it was sent incorrectly, please contact your JIRA administrators: https://jira.codehaus.org/secure/ContactAdministrators!default.jspa For more information on JIRA, see: http://www.atlassian.com/software/jira