continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r570544 - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/configuration/ continuum-api/src/main/java/org/apache/maven/continuum/execution/ continuum-core/src/main/java/org/apache/maven/continuum/ continuum-...
Date Tue, 28 Aug 2007 19:47:52 GMT
Author: evenisse
Date: Tue Aug 28 12:47:51 2007
New Revision: 570544

URL: http://svn.apache.org/viewvc?rev=570544&view=rev
Log:
[CONTINUUM-1411] backup surefire reports in a continuum directory to continue to see them
in build results

Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
    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/DefaultContinuum.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.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
    maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
    maven/continuum/trunk/continuum-notifiers/continuum-notifier-wagon/src/test/java/org/apache/maven/continuum/wagon/MockConfigurationService.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SurefireReportAction.java

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java?rev=570544&r1=570543&r2=570544&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
(original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
Tue Aug 28 12:47:51 2007
@@ -62,6 +62,9 @@
 
     File getBuildOutputFile( int buildId, int projectId )
         throws ConfigurationException;
+    
+    File getTestReportsDirectory( int buildId, int projectId )
+        throws ConfigurationException;
 
     // ----------------------------------------------------------------------
     //

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=570544&r1=570543&r2=570544&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
Tue Aug 28 12:47:51 2007
@@ -20,6 +20,7 @@
  */
 
 import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.scm.TestResult;
 
@@ -47,6 +48,6 @@
     List getDeployableArtifacts( File workingDirectory, BuildDefinition buildDefinition )
         throws ContinuumBuildExecutorException;
 
-    TestResult getTestResults( Project project )
+    TestResult getTestResults( Project project, int buildResultId )
         throws ContinuumBuildExecutorException;
 }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=570544&r1=570543&r2=570544&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Tue Aug 28 12:47:51 2007
@@ -1057,7 +1057,34 @@
     public void removeBuildResult( int buildId )
         throws ContinuumException
     {
-        store.removeBuildResult( getBuildResult( buildId ) );
+        BuildResult buildResult = getBuildResult( buildId );
+        store.removeBuildResult( buildResult );
+        
+        // cleanup some files
+        try
+        {
+            File buildOutputDirectory = getConfiguration().getBuildOutputDirectory( buildResult.getProject().getId()
);
+            File buildDirectory = new File( buildOutputDirectory, Integer.toString( buildId
) );
+
+            if ( buildDirectory.exists() )
+            {
+                FileUtils.deleteDirectory( buildDirectory );
+            }
+            File buildOutputFile = getConfiguration().getBuildOutputFile( buildId, buildResult.getProject().getId()
);
+            if ( buildOutputFile.exists() )
+            {
+                buildOutputFile.delete();
+            }
+        }
+        catch ( ConfigurationException e )
+        {
+            getLogger().info( "skip error during cleanup build files " + e.getMessage(),
e );
+        }
+        catch ( IOException e )
+        {
+            getLogger().info( "skip IOException during cleanup build files " + e.getMessage(),
e );
+        }
+        
     }
 
     public String getBuildOutput( int projectId, int buildId )

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java?rev=570544&r1=570543&r2=570544&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
(original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
Tue Aug 28 12:47:51 2007
@@ -167,6 +167,8 @@
     //
     // ----------------------------------------------------------------------
 
+
+
     public File getBuildOutputDirectory( int projectId )
     {
         File dir = new File( getBuildOutputDirectory(), Integer.toString( projectId ) );
@@ -182,6 +184,15 @@
         return dir;
     }
 
+    public File getTestReportsDirectory( int buildId, int projectId )
+        throws ConfigurationException
+    {
+        File ouputDirectory = getBuildOutputDirectory( projectId );
+        
+        return new File( ouputDirectory.getPath() + File.separatorChar + buildId + File.separatorChar
+ "surefire-reports" );
+
+    }    
+    
     public File getBuildOutputFile( int buildId, int projectId )
         throws ConfigurationException
     {

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=570544&r1=570543&r2=570544&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
Tue Aug 28 12:47:51 2007
@@ -181,7 +181,7 @@
 
             try
             {
-                TestResult testResult = buildExecutor.getTestResults( project );
+                TestResult testResult = buildExecutor.getTestResults( project, buildResult.getId()
);
                 buildResult.setTestResult( testResult );
             }
             catch ( Throwable t )

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=570544&r1=570543&r2=570544&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
Tue Aug 28 12:47:51 2007
@@ -298,7 +298,7 @@
         return workingDirectoryService.getWorkingDirectory( project );
     }
 
-    public TestResult getTestResults( Project project )
+    public TestResult getTestResults( Project project, int buildResultId )
         throws ContinuumBuildExecutorException
     {
         return null;

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=570544&r1=570543&r2=570544&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
Tue Aug 28 12:47:51 2007
@@ -21,6 +21,8 @@
 
 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;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutor;
@@ -38,6 +40,7 @@
 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 org.codehaus.plexus.util.xml.pull.MXParser;
 import org.codehaus.plexus.util.xml.pull.XmlPullParser;
@@ -88,6 +91,11 @@
      * @plexus.requirement
      */
     private MavenProjectHelper projectHelper;
+    
+    /**
+     * @plexus.requirement
+     */    
+    private ConfigurationService configurationService;
 
     // ----------------------------------------------------------------------
     //
@@ -293,13 +301,26 @@
         return artifacts;
     }
 
-    public TestResult getTestResults( Project project )
+    public TestResult getTestResults( Project project, int buildId )
         throws ContinuumBuildExecutorException
     {
-        return getTestResults( getWorkingDirectory( project ) );
+        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 );
+        }
+        return getTestResults( getWorkingDirectory( project ), backupDirectory );
     }
 
-    private TestResult getTestResults( File workingDir )
+    private TestResult getTestResults( File workingDir, File backupDirectory )
         throws ContinuumBuildExecutorException
     {
         DirectoryScanner scanner = new DirectoryScanner();
@@ -316,6 +337,16 @@
         for ( int i = 0; i < testResultFiles.length; i++ )
         {
             File xmlFile = new File( workingDir, testResultFiles[i] );
+            try
+            {
+            if (backupDirectory != null)
+            {
+                FileUtils.copyFileToDirectory( xmlFile, backupDirectory );
+            }
+            } catch (IOException e)
+            {
+                getLogger().info( "failed to backup unit report file " + xmlFile.getPath()
);
+            }
             SuiteResult suite = new SuiteResult();
             try
             {

Modified: maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml?rev=570544&r1=570543&r2=570544&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
Tue Aug 28 12:47:51 2007
@@ -101,7 +101,10 @@
           <role>org.apache.maven.project.MavenProjectHelper</role>
         </requirement>
         <requirement>
-          <role>org.apache.maven.continuum.installation.InstallationService</role>
 
+          <role>org.apache.maven.continuum.installation.InstallationService</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.continuum.configuration.ConfigurationService</role>
         </requirement>
       </requirements>
     </component>
@@ -128,8 +131,8 @@
           <role>org.apache.maven.continuum.utils.WorkingDirectoryService</role>
         </requirement>
         <requirement>
-          <role>org.apache.maven.continuum.installation.InstallationService</role>
 
-        </requirement>          
+          <role>org.apache.maven.continuum.installation.InstallationService</role>
+        </requirement>
       </requirements>
     </component>
 
@@ -149,8 +152,8 @@
           <role>org.apache.maven.continuum.utils.WorkingDirectoryService</role>
         </requirement>
         <requirement>
-          <role>org.apache.maven.continuum.installation.InstallationService</role>
 
-        </requirement>          
+          <role>org.apache.maven.continuum.installation.InstallationService</role>
+        </requirement>
       </requirements>
       <configuration>
         <default-executable>ant</default-executable>
@@ -172,8 +175,8 @@
           <role>org.apache.maven.continuum.utils.WorkingDirectoryService</role>
         </requirement>
         <requirement>
-          <role>org.apache.maven.continuum.installation.InstallationService</role>
 
-        </requirement>          
+          <role>org.apache.maven.continuum.installation.InstallationService</role>
+        </requirement>
       </requirements>
     </component>
 

Modified: maven/continuum/trunk/continuum-notifiers/continuum-notifier-wagon/src/test/java/org/apache/maven/continuum/wagon/MockConfigurationService.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-notifiers/continuum-notifier-wagon/src/test/java/org/apache/maven/continuum/wagon/MockConfigurationService.java?rev=570544&r1=570543&r2=570544&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-notifiers/continuum-notifier-wagon/src/test/java/org/apache/maven/continuum/wagon/MockConfigurationService.java
(original)
+++ maven/continuum/trunk/continuum-notifiers/continuum-notifier-wagon/src/test/java/org/apache/maven/continuum/wagon/MockConfigurationService.java
Tue Aug 28 12:47:51 2007
@@ -71,6 +71,19 @@
         return new File( basedir, "src/test/resources" + "/" + "working-directory" );
     }
 
+    public File getTestReportsDirectory( int buildId, int projectId )
+        throws ConfigurationException
+    {
+        File dir = getBuildOutputDirectory( projectId );
+
+        if ( !dir.exists() && !dir.mkdirs() )
+        {
+            throw new ConfigurationException( "Could not make the build output directory:
" + "'"
+                + dir.getAbsolutePath() + "'." );
+        }
+        return new File( dir.getPath() + File.separatorChar + buildId + File.separatorChar
+ "surefire-reports " );
+    }
+
     public File getApplicationHome()
     {
         return null;
@@ -176,4 +189,4 @@
         throws ConfigurationStoringException
     {
     }
-}
\ No newline at end of file
+}

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java?rev=570544&r1=570543&r2=570544&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/BuildResultAction.java
Tue Aug 28 12:47:51 2007
@@ -75,10 +75,20 @@
         //todo get this working for other types of test case rendering other then just surefire
         // check if there are surefire results to display
         project = getContinuum().getProject( getProjectId() );
-        hasSurefireResults = FileUtils.fileExists( project.getWorkingDirectory() + "/target/surefire-reports"
);
 
         buildResult = getContinuum().getBuildResult( getBuildId() );
 
+        // directory contains files ?
+        File surefireReportsDirectory = getContinuum().getConfiguration().getTestReportsDirectory(
buildId, projectId );
+        File[] files = surefireReportsDirectory.listFiles();
+        if ( files == null )
+        {
+            hasSurefireResults = false;
+        }
+        else
+        {
+            hasSurefireResults = files.length > 0;
+        }
         changeSet = getContinuum().getChangesSinceLastSuccess( getProjectId(), getBuildId()
);
 
         File buildOutputFile = getContinuum().getConfiguration().getBuildOutputFile( getBuildId(),
getProjectId() );

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SurefireReportAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SurefireReportAction.java?rev=570544&r1=570543&r2=570544&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SurefireReportAction.java
(original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/SurefireReportAction.java
Tue Aug 28 12:47:51 2007
@@ -20,7 +20,9 @@
  */
 
 import org.apache.maven.continuum.ContinuumException;
+import org.apache.maven.continuum.configuration.ConfigurationException;
 import org.apache.maven.continuum.model.project.Project;
+import org.apache.maven.continuum.model.scm.TestResult;
 import org.apache.maven.continuum.web.exception.AuthorizationRequiredException;
 import org.codehaus.plexus.util.DirectoryScanner;
 import org.codehaus.plexus.util.StringUtils;
@@ -66,7 +68,7 @@
     private Project project;
 
     public String execute()
-        throws ContinuumException
+        throws ContinuumException, ConfigurationException
     {
         try
         {
@@ -79,8 +81,7 @@
 
         project = getProjectById( projectId );
 
-        //@todo maven-surefire-report reportsDirectory should be detected ?
-        File reportsDirectory = new File( project.getWorkingDirectory() + "/target/surefire-reports"
);
+        File reportsDirectory = getContinuum().getConfiguration().getTestReportsDirectory(
buildId, projectId );
 
         parseReports( reportsDirectory );
 
@@ -137,6 +138,7 @@
 
         for ( Iterator suites = suiteList.iterator(); suites.hasNext(); )
         {
+            
             ReportTestSuite suite = (ReportTestSuite) suites.next();
 
             totalTests += suite.getNumberOfTests();
@@ -761,4 +763,5 @@
     {
         return getProjectById( projectId ).getProjectGroup().getName();
     }
+
 }



Mime
View raw message