SF.net SVN: ccnet:[6830] trunk/project

1 view
Skip to first unread message

dna...@users.sourceforge.net

unread,
Feb 2, 2010, 6:11:24 PM2/2/10
to ccnet-c...@googlegroups.com
Revision: 6830
http://ccnet.svn.sourceforge.net/ccnet/?rev=6830&view=rev
Author: dnauck
Date: 2010-02-02 23:11:24 +0000 (Tue, 02 Feb 2010)

Log Message:
-----------
CCNET-1809: Delete temp. Logfiles after merging them

* IIntegrationResult: remove unused methods
* IntegrationResult: adjust to interfaces changes
* FileTaskResult: add IFileSystem for better testing, overload .ctor with IFileSystem
* MergeFilesTask: create FileTaskResult directly and set deleteAfterMerge property and IFileSystem
* MergeFileTaskTest: adjust to MergeFilesTask changes

Modified Paths:
--------------
trunk/project/UnitTests/Core/Tasks/MergeFileTaskTest.cs
trunk/project/core/IIntegrationResult.cs
trunk/project/core/IntegrationResult.cs
trunk/project/core/tasks/FileTaskResult.cs
trunk/project/core/tasks/MergeFilesTask.cs

Modified: trunk/project/UnitTests/Core/Tasks/MergeFileTaskTest.cs
===================================================================
--- trunk/project/UnitTests/Core/Tasks/MergeFileTaskTest.cs 2010-02-02 22:25:43 UTC (rev 6829)
+++ trunk/project/UnitTests/Core/Tasks/MergeFileTaskTest.cs 2010-02-02 23:11:24 UTC (rev 6830)
@@ -188,6 +188,7 @@
// Mock the file system
var fileSystem = mocks.StrictMock<IFileSystem>();
Expect.Call(fileSystem.FileExists(Path.Combine(working, "text.xml"))).Return(true);
+ Expect.Call(fileSystem.FileExists(Path.Combine(working, "text.xml"))).Return(true);
Expect.Call(fileSystem.FileExists(Path.Combine(working, "text.txt"))).Return(true);
Expect.Call(fileSystem.FileExists(Path.Combine(working, "blank.txt"))).Return(false);
Expect.Call(() => { fileSystem.EnsureFolderExists(targetFolder); });
@@ -213,6 +214,11 @@

// Mock the result
var result = mocks.StrictMock<IIntegrationResult>();
+ Expect.Call(() =>
+ {
+ result.AddTaskResult((ITaskResult) null);
+ }).IgnoreArguments();
+
var buildProgress = mocks.StrictMock<BuildProgressInformation>(artefact, "Project1");
SetupResult.For(result.BuildProgressInformation)
.Return(buildProgress);
@@ -222,8 +228,16 @@
Expect.Call(() => { buildProgress.SignalStartRunTask("Merging Files"); });
buildProgress.Expect(bpi => bpi.AddTaskInformation(null)).IgnoreArguments();
buildProgress.Expect(bpi => bpi.AddTaskInformation(null)).IgnoreArguments();
- Expect.Call(() => { result.AddTaskResultFromFile(Path.Combine(working, "text.xml"), false); });

+ //var testFile = new FileInfo(Path.Combine(working, "text.xml"));
+ //Expect.Call(fileSystem.FileExists(testFile.FullName)).Return(true);
+ //Expect.Call(() =>
+ // {
+ // result.AddTaskResult(new FileTaskResult(
+ // testFile, false,
+ // fileSystem) {WrapInCData = false});
+ // });
+
// Run the test
mocks.ReplayAll();
task.Run(result);

Modified: trunk/project/core/IIntegrationResult.cs
===================================================================
--- trunk/project/core/IIntegrationResult.cs 2010-02-02 22:25:43 UTC (rev 6829)
+++ trunk/project/core/IIntegrationResult.cs 2010-02-02 23:11:24 UTC (rev 6830)
@@ -54,8 +54,6 @@
string TaskOutput { get; }
void AddTaskResult(string result);
void AddTaskResult(ITaskResult result);
- void AddTaskResultFromFile(string filename);
- void AddTaskResultFromFile(string filename, bool wrapInCData);
bool HasModifications();
bool ShouldRunBuild();

Modified: trunk/project/core/IntegrationResult.cs
===================================================================
--- trunk/project/core/IntegrationResult.cs 2010-02-02 22:25:43 UTC (rev 6829)
+++ trunk/project/core/IntegrationResult.cs 2010-02-02 23:11:24 UTC (rev 6830)
@@ -308,18 +308,6 @@
Status = result.CheckIfSuccess() ? IntegrationStatus.Success : IntegrationStatus.Failure;
}

- public void AddTaskResultFromFile(string filename)
- {
- AddTaskResultFromFile(filename, false);
- }
-
- public void AddTaskResultFromFile(string filename, bool wrapInCData)
- {
- var result = new FileTaskResult(filename);
- result.WrapInCData = wrapInCData;
- AddTaskResult(result);
- }
-
public void MarkStartTime()
{
StartTime = DateTime.Now;

Modified: trunk/project/core/tasks/FileTaskResult.cs
===================================================================
--- trunk/project/core/tasks/FileTaskResult.cs 2010-02-02 22:25:43 UTC (rev 6829)
+++ trunk/project/core/tasks/FileTaskResult.cs 2010-02-02 23:11:24 UTC (rev 6830)
@@ -1,3 +1,5 @@
+using ThoughtWorks.CruiseControl.Core.Util;
+
namespace ThoughtWorks.CruiseControl.Core.Tasks
{
using System;
@@ -16,6 +18,7 @@
/// </summary>
private readonly FileInfo dataSource;
private bool deleteAfterMerge = true;
+ private readonly IFileSystem fileSystem;
#endregion

#region Constructors
@@ -52,15 +55,27 @@
/// </summary>
/// <param name="file">The <see cref="FileInfo"/>.</param>
/// <param name="deleteAfterMerge">Delete file after merging.</param>
- public FileTaskResult(FileInfo file, bool deleteAfterMerge)
+ public FileTaskResult(FileInfo file, bool deleteAfterMerge) :
+ this(file, deleteAfterMerge, new SystemIoFileSystem())
{
- if (!file.Exists)
+ }
+
+ /// <summary>
+ /// Initializes a new instance of the <see cref="FileTaskResult"/> class from a <see cref="FileInfo"/>.
+ /// </summary>
+ /// <param name="file">The <see cref="FileInfo"/>.</param>
+ /// <param name="deleteAfterMerge">Delete file after merging.</param>
+ /// <param name="fileSystem">IFileSystem instance, allows this task to interact with the file system in a testable way.</param>
+ public FileTaskResult(FileInfo file, bool deleteAfterMerge, IFileSystem fileSystem)
+ {
+ this.deleteAfterMerge = deleteAfterMerge;
+ this.dataSource = file;
+ this.fileSystem = fileSystem;
+
+ if (!fileSystem.FileExists(file.FullName))
{
throw new CruiseControlException("File not found: " + file.FullName);
}
-
- this.deleteAfterMerge = deleteAfterMerge;
- this.dataSource = file;
}
#endregion

Modified: trunk/project/core/tasks/MergeFilesTask.cs
===================================================================
--- trunk/project/core/tasks/MergeFilesTask.cs 2010-02-02 22:25:43 UTC (rev 6829)
+++ trunk/project/core/tasks/MergeFilesTask.cs 2010-02-02 23:11:24 UTC (rev 6830)
@@ -172,8 +172,8 @@
// Add the file to the merge list
actualLogger.Info("Merging file '{0}'", fileInfo);
result.BuildProgressInformation.AddTaskInformation(string.Format("Merging file '{0}'", fileInfo));
- var useCData = (mergeFile.MergeAction == MergeFileInfo.MergeActionType.CData);
- result.AddTaskResultFromFile(fileInfo.FullName, useCData);
+ result.AddTaskResult(new FileTaskResult(fileInfo, mergeFile.DeleteAfterMerge, actualFileSystem)
+ {WrapInCData = (mergeFile.MergeAction == MergeFileInfo.MergeActionType.CData)});
break;
case MergeFileInfo.MergeActionType.Copy:
// Copy the file to the target folder


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.

Reply all
Reply to author
Forward
0 new messages