continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r587035 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/execution/ continuum-core/src/main/java/org/apache/maven/continuum/core/action/ continuum-core/src/main/java/org/apache/maven/continuum/execution/ c...
Date Mon, 22 Oct 2007 08:45:17 GMT
Author: evenisse
Date: Mon Oct 22 01:45:16 2007
New Revision: 587035

URL: http://svn.apache.org/viewvc?rev=587035&view=rev
Log:
[CONTINUUM-1532] Re-add backup of test result files deleted by mistake in previous patch

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java?rev=587035&r1=587034&r2=587035&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/execution/ContinuumBuildExecutor.java
Mon Oct 22 01:45:16 2007
@@ -45,4 +45,6 @@
 
     List getDeployableArtifacts( Project project, File workingDirectory, BuildDefinition
buildDefinition )
         throws ContinuumBuildExecutorException;
+
+    void backupTestFiles( Project project, int buildId );
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java?rev=587035&r1=587034&r2=587035&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/core/action/ExecuteBuilderContinuumAction.java
Mon Oct 22 01:45:16 2007
@@ -164,16 +164,11 @@
             store.updateProject( project );
 
             notifier.goalsCompleted( project, buildDefinition, buildResult );
-        }
-    }
-
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
 
-    private boolean isNew( Project project )
-    {
-        return project.getState() == ContinuumProjectState.NEW ||
-            project.getState() == ContinuumProjectState.CHECKEDOUT;
+            // ----------------------------------------------------------------------
+            // Backup test result files
+            // ----------------------------------------------------------------------
+            buildExecutor.backupTestFiles( project, buildResult.getId() );
+        }
     }
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java?rev=587035&r1=587034&r2=587035&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/AbstractBuildExecutor.java
Mon Oct 22 01:45:16 2007
@@ -244,6 +244,11 @@
         return jdk.getVarValue();
     }
 
+    public void backupTestFiles( Project project, int buildId )
+    {
+        //Nothing to do, by default
+    }
+
     protected Map<String, String> getEnvironmentVariables( BuildDefinition buildDefinition
)
     {
         Profile profile = buildDefinition.getProfile();

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java?rev=587035&r1=587034&r2=587035&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java
Mon Oct 22 01:45:16 2007
@@ -21,6 +21,7 @@
 
 import org.apache.maven.artifact.Artifact;
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
+import org.apache.maven.continuum.configuration.ConfigurationException;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.execution.AbstractBuildExecutor;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutionResult;
@@ -36,9 +37,12 @@
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.MavenProjectHelper;
 import org.apache.maven.project.artifact.ProjectArtifactMetadata;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.StringUtils;
 
 import java.io.File;
+import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -283,6 +287,51 @@
         }
 
         return artifacts;
+    }
+
+    public void backupTestFiles( Project project, int buildId )
+    {
+        getLogger().info( "Backup surefire files." );
+        File backupDirectory = null;
+        try
+        {
+            backupDirectory = configurationService.getTestReportsDirectory( buildId, project.getId()
);
+            if ( !backupDirectory.exists() )
+            {
+                backupDirectory.mkdirs();
+            }
+        }
+        catch ( ConfigurationException e )
+        {
+            getLogger().info( "error on surefire backup directory creation skip backup "
+ e.getMessage(), e );
+        }
+        backupTestFiles( getWorkingDirectory( project ), backupDirectory );
+    }
+
+    private void backupTestFiles( File workingDir, File backupDirectory )
+    {
+        DirectoryScanner scanner = new DirectoryScanner();
+        scanner.setBasedir( workingDir );
+        scanner.setIncludes(
+            new String[]{"**/target/surefire-reports/TEST-*.xml", "**/target/surefire-it-reports/TEST-*.xml"}
);
+        scanner.scan();
+
+        String[] testResultFiles = scanner.getIncludedFiles();
+        for ( String testResultFile : testResultFiles )
+        {
+            File xmlFile = new File( workingDir, testResultFile );
+            try
+            {
+                if ( backupDirectory != null )
+                {
+                    FileUtils.copyFileToDirectory( xmlFile, backupDirectory );
+                }
+            }
+            catch ( IOException e )
+            {
+                getLogger().info( "failed to backup unit report file " + xmlFile.getPath()
);
+            }
+        }
     }
 
     protected Map<String, String> getEnvironments( BuildDefinition buildDefinition
)



Mime
View raw message