You are viewing a plain text version of this content. The canonical link for it is here.
Posted to surefire-commits@maven.apache.org by st...@apache.org on 2010/03/16 18:31:30 UTC

svn commit: r923888 - in /maven/surefire/trunk: maven-failsafe-plugin/src/it/working-directory/ maven-failsafe-plugin/src/it/working-directory/src/ maven-failsafe-plugin/src/it/working-directory/src/test/ maven-failsafe-plugin/src/it/working-directory/...

Author: stephenc
Date: Tue Mar 16 17:31:30 2010
New Revision: 923888

URL: http://svn.apache.org/viewvc?rev=923888&view=rev
Log:
SUREFIRE-607 Submitted by Peter Janes

o Updated patch to reflect the move from failsafe-maven-plugin to maven-failsafe-plugin.

o Updated Integration Test in patch to comply with failsafe naming convention

o Ported patch to maven-surefire-plugin

o Added integration test to surefire-integration-tests

Added:
    maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/
    maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/pom.xml   (with props)
    maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/src/
    maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/src/test/
    maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/src/test/java/
    maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/src/test/java/MyIT.java   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryMissingIT.java   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/pom.xml   (with props)
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/src/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/src/test/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/src/test/java/
    maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/src/test/java/MyTest.java   (with props)
Modified:
    maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
    maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java

Added: maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/pom.xml?rev=923888&view=auto
==============================================================================
--- maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/pom.xml (added)
+++ maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/pom.xml Tue Mar 16 17:31:30 2010
@@ -0,0 +1,57 @@
+<?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>localhost</groupId>
+  <artifactId>working-directory-test</artifactId>
+  <version>1.0</version>
+  <name>Run tests in a nonexistent working directory</name>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>@project.groupId@</groupId>
+        <artifactId>@project.artifactId@</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>integration-test</id>
+            <goals>
+              <goal>integration-test</goal>
+            </goals>
+            <configuration>
+              <workingDirectory>${project.build.directory}/failsafe-working-directory</workingDirectory>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/src/test/java/MyIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/src/test/java/MyIT.java?rev=923888&view=auto
==============================================================================
--- maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/src/test/java/MyIT.java (added)
+++ maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/src/test/java/MyIT.java Tue Mar 16 17:31:30 2010
@@ -0,0 +1,7 @@
+import junit.framework.TestCase;
+
+public class MyIT extends TestCase {
+    public void testSomething() {
+        assertTrue(true);
+    }
+}

Propchange: maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/src/test/java/MyIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/maven-failsafe-plugin/src/it/working-directory/src/test/java/MyIT.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java?rev=923888&r1=923887&r2=923888&view=diff
==============================================================================
--- maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java (original)
+++ maven/surefire/trunk/maven-failsafe-plugin/src/main/java/org/apache/maven/plugin/failsafe/IntegrationTestMojo.java Tue Mar 16 17:31:30 2010
@@ -686,6 +686,19 @@ public class IntegrationTestMojo
             return false;
         }
 
+        if ( !workingDirectory.exists() )
+        {
+            if ( !workingDirectory.mkdirs() )
+            {
+                throw new MojoFailureException( "Cannot create workingDirectory " + workingDirectory );
+            }
+        }
+
+        if ( !workingDirectory.isDirectory() )
+        {
+            throw new MojoFailureException( "workingDirectory " + workingDirectory + " exists and is not a directory" );
+        }
+
         if ( useSystemClassLoader != null && ForkConfiguration.FORK_NEVER.equals( forkMode ) )
         {
             getLog().warn( "useSystemClassloader setting has no effect when not forking" );

Modified: maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java?rev=923888&r1=923887&r2=923888&view=diff
==============================================================================
--- maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java (original)
+++ maven/surefire/trunk/maven-surefire-plugin/src/main/java/org/apache/maven/plugin/surefire/SurefirePlugin.java Tue Mar 16 17:31:30 2010
@@ -650,6 +650,19 @@ public class SurefirePlugin
             return false;
         }
 
+        if ( !workingDirectory.exists() )
+        {
+            if ( !workingDirectory.mkdirs() )
+            {
+                throw new MojoFailureException( "Cannot create workingDirectory " + workingDirectory );
+            }
+        }
+
+        if ( !workingDirectory.isDirectory() )
+        {
+            throw new MojoFailureException( "workingDirectory " + workingDirectory + " exists and is not a directory" );
+        }
+
         if ( useSystemClassLoader != null && ForkConfiguration.FORK_NEVER.equals( forkMode ) )
         {
             getLog().warn( "useSystemClassloader setting has no effect when not forking" );

Added: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryMissingIT.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryMissingIT.java?rev=923888&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryMissingIT.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryMissingIT.java Tue Mar 16 17:31:30 2010
@@ -0,0 +1,39 @@
+package org.apache.maven.surefire.its;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Properties;
+
+import org.apache.maven.it.Verifier;
+import org.apache.maven.it.util.ResourceExtractor;
+
+/**
+ * Test when the configured working directory does not exist, SUREFIRE-607
+ * 
+ * @author <a href="mailto:stephenc@apache.org">Stephen Connolly</a>
+ * 
+ */
+public class WorkingDirectoryMissingIT
+    extends AbstractSurefireIntegrationTestClass
+{
+
+    private File testDir;
+
+    public void setUp()
+        throws IOException
+    {
+        testDir = ResourceExtractor.simpleExtractResources( getClass(), "/working-directory-missing" );
+    }
+
+    public void testWorkingDirectory()
+        throws Exception
+    {
+        Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+        this.executeGoal( verifier, "test" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+    }
+
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryMissingIT.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/WorkingDirectoryMissingIT.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/pom.xml
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/pom.xml?rev=923888&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/pom.xml (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/pom.xml Tue Mar 16 17:31:30 2010
@@ -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>localhost</groupId>
+  <artifactId>working-directory-test</artifactId>
+  <version>1.0</version>
+  <name>Run tests in a nonexistent working directory</name>
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.2</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>${surefire.version}</version>
+        <configuration>
+          <workingDirectory>${project.build.directory}/surefire-working-directory</workingDirectory>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/pom.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/src/test/java/MyTest.java
URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/src/test/java/MyTest.java?rev=923888&view=auto
==============================================================================
--- maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/src/test/java/MyTest.java (added)
+++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/src/test/java/MyTest.java Tue Mar 16 17:31:30 2010
@@ -0,0 +1,7 @@
+import junit.framework.TestCase;
+
+public class MyTest extends TestCase {
+    public void testSomething() {
+        assertTrue(true);
+    }
+}

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/src/test/java/MyTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/working-directory-missing/src/test/java/MyTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain