Skip to content
Browse files

Merge pull request #61 from obones/Issue50

retry merge
  • Loading branch information...
2 parents 5bd0fa6 + 06b4b65 commit 1cb60c8021413a08c53d027e3867691d64f5d9cc @RubenWillems RubenWillems committed
View
47 project/UnitTests/Core/IntegrationResultManagerTest.cs
@@ -123,7 +123,52 @@ public void SuccessfulIntegrationShouldClearFailedUsersOnNextIntegration()
Assert.AreEqual(0, result3.FailureUsers.Count);
}
- private void ExpectToLoadState(IIntegrationResult result)
+ [Test]
+ public void FailedIntegrationShouldResetFailedTasksOnNextIntegration()
+ {
+ IIntegrationResult lastResult = IntegrationResultMother.CreateFailed();
+ lastResult.FailureTasks.Add("task1");
+ ExpectToLoadState(lastResult);
+
+ IIntegrationResult newResult = manager.StartNewIntegration(ModificationExistRequest());
+ Assert.AreEqual(0, newResult.FailureTasks.Count, "Mismatched count of inherited FailureTasks");
+
+ Modification modification = new Modification();
+ modification.UserName = "user";
+ newResult.Modifications = new Modification[] { modification };
+ newResult.Status = IntegrationStatus.Failure;
+ newResult.FailureTasks.Add("task2");
+ mockStateManager.Expect("SaveState", newResult);
+ manager.FinishIntegration();
+
+ Assert.AreEqual(1, newResult.FailureTasks.Count, "Mismatched count of resulting FailureTasks");
+ }
+
+ [Test]
+ public void SuccessfulIntegrationShouldResetFailedTasksOnNextIntegration()
+ {
+ IIntegrationResult result1 = IntegrationResultMother.CreateFailed();
+ result1.FailureTasks.Add("task1");
+ ExpectToLoadState(result1);
+
+ IIntegrationResult result2 = manager.StartNewIntegration(ModificationExistRequest());
+ Assert.AreEqual(0, result2.FailureTasks.Count);
+
+ Modification modification = new Modification();
+ modification.UserName = "user";
+ result2.Modifications = new Modification[] { modification };
+ result2.Status = IntegrationStatus.Success;
+ result2.FailureTasks.Add("task2");
+ mockStateManager.Expect("SaveState", result2);
+ manager.FinishIntegration();
+ Assert.AreEqual(1, result2.FailureTasks.Count);
+ Assert.AreEqual("task2", result2.FailureTasks[0]);
+
+ IIntegrationResult result3 = manager.StartNewIntegration(ModificationExistRequest());
+ Assert.AreEqual(0, result3.FailureTasks.Count);
+ }
+
+ private void ExpectToLoadState(IIntegrationResult result)
{
mockStateManager.ExpectAndReturn("HasPreviousState", true, "project");
mockStateManager.ExpectAndReturn("LoadState", result, "project");
View
7 project/UnitTests/Core/IntegrationResultTest.cs
@@ -192,13 +192,14 @@ public void MapIntegrationProperties()
result.StartTime = new DateTime(2005,06,06,08,45,00);
result.ProjectUrl = "http://localhost/ccnet2";
result.FailureUsers.Add("user");
+ result.FailureTasks.Add("task");
Modification mods = new Modification();
mods.UserName = "John";
result.Modifications = new Modification[] { mods };
- Assert.AreEqual(16, result.IntegrationProperties.Count);
+ Assert.AreEqual(17, result.IntegrationProperties.Count);
Assert.AreEqual("project", result.IntegrationProperties[IntegrationPropertyNames.CCNetProject]);
Assert.AreEqual("http://localhost/ccnet2", result.IntegrationProperties[IntegrationPropertyNames.CCNetProjectUrl]);
Assert.AreEqual("label23", result.IntegrationProperties[IntegrationPropertyNames.CCNetLabel]);
@@ -218,6 +219,10 @@ public void MapIntegrationProperties()
Assert.IsNotNull(failureUsers);
Assert.AreEqual(1, failureUsers.Count);
Assert.AreEqual("user", failureUsers[0]);
+ ArrayList failureTasks = result.IntegrationProperties[IntegrationPropertyNames.CCNetFailureTasks] as ArrayList;
+ Assert.IsNotNull(failureTasks);
+ Assert.AreEqual(1, failureTasks.Count);
+ Assert.AreEqual("task", failureTasks[0]);
ArrayList Modifiers = result.IntegrationProperties[IntegrationPropertyNames.CCNetModifyingUsers] as ArrayList;
Assert.IsNotNull(Modifiers);
Assert.AreEqual(1, Modifiers.Count);
View
2 project/UnitTests/Core/ProjectTest.cs
@@ -691,6 +691,7 @@ public void PublishResultsShouldCleanTemporaryResultsOnFailure()
SetupResult.For(result.Succeeded).Return(false);
SetupResult.For(result.Modifications).Return(new Modification[0]);
SetupResult.For(result.FailureUsers).Return(new ArrayList());
+ SetupResult.For(result.FailureTasks).Return(new ArrayList());
var results = new List<ITaskResult>();
SetupResult.For(result.TaskResults).Return(results);
var project = new Project();
@@ -721,6 +722,7 @@ public void PublishResultsShouldNotCleanTemporaryResultsOnMergeFailure()
SetupResult.For(result.Succeeded).Return(false);
SetupResult.For(result.Modifications).Return(new Modification[0]);
SetupResult.For(result.FailureUsers).Return(new ArrayList());
+ SetupResult.For(result.FailureTasks).Return(new ArrayList());
var results = new List<ITaskResult>();
SetupResult.For(result.TaskResults).Return(results);
var project = new Project();
View
12 project/UnitTests/Core/Publishers/XmlIntegrationResultWriterTest.cs
@@ -1,5 +1,7 @@
using System;
+using System.Collections;
using System.IO;
+using System.Reflection;
using System.Xml.XPath;
using NUnit.Framework;
using ThoughtWorks.CruiseControl.Core;
@@ -55,7 +57,15 @@ public void WriteRequest()
AssertXPathExists(xml, "cruisecontrol/integrationProperties");
-
+ // Go through the list of integration property names constants and check they are here
+ FieldInfo[] fieldInfos = typeof(IntegrationPropertyNames).GetFields(BindingFlags.Public | BindingFlags.Static);
+ foreach (FieldInfo fi in fieldInfos)
+ if (fi.IsLiteral && !fi.IsInitOnly)
+ {
+ string integrationPropertyName = (string)fi.GetValue(null);
+ if (result.IntegrationProperties[integrationPropertyName] != null)
+ AssertXPathExists(xml, "cruisecontrol/integrationProperties/" + integrationPropertyName);
+ }
}
[Test]
View
1 project/UnitTests/Core/State/FileStateManagerTest.cs
@@ -124,6 +124,7 @@ public void LoadStateFileWithValid144Data()
<LastIntegrationStatus>Success</LastIntegrationStatus>
<LastSuccessfulIntegrationLabel>7</LastSuccessfulIntegrationLabel>
<FailureUsers />
+ <FailureTasks />
</IntegrationResult>";
Expect.Call(executionEnvironment.GetDefaultProgramDataFolder(ApplicationType.Server)).IgnoreArguments().Constraints(Rhino.Mocks.Constraints.Is.NotNull()).Return(applicationDataPath);
View
4 project/UnitTests/Core/Tasks/MsBuildTaskTest.cs
@@ -94,7 +94,7 @@ public void AddQuotesAroundPropertiesWithSpaces()
// NOTE: Property names are sorted alphabetically when passed as process arguments
// Tests that look for the correct arguments will fail if the following properties
// are not sorted alphabetically.
- string expectedProperties = string.Format(@"/p:CCNetArtifactDirectory={2};CCNetBuildCondition=IfModificationExists;CCNetBuildDate={0};CCNetBuildTime={1};CCNetFailureUsers=;CCNetIntegrationStatus=Success;CCNetLabel=""My Label"";CCNetLastIntegrationStatus=Success;CCNetListenerFile={3};CCNetModifyingUsers=;CCNetNumericLabel=0;CCNetProject=test;CCNetRequestSource=foo;CCNetUser=;CCNetWorkingDirectory={4}", testDateString, testTimeString, StringUtil.AutoDoubleQuoteString(result.ArtifactDirectory), StringUtil.AutoDoubleQuoteString(Path.GetTempPath() + "test_ListenFile.xml"), StringUtil.AutoDoubleQuoteString(DefaultWorkingDirectoryWithSpaces));
+ string expectedProperties = string.Format(@"/p:CCNetArtifactDirectory={2};CCNetBuildCondition=IfModificationExists;CCNetBuildDate={0};CCNetBuildTime={1};CCNetFailureTasks=;CCNetFailureUsers=;CCNetIntegrationStatus=Success;CCNetLabel=""My Label"";CCNetLastIntegrationStatus=Success;CCNetListenerFile={3};CCNetModifyingUsers=;CCNetNumericLabel=0;CCNetProject=test;CCNetRequestSource=foo;CCNetUser=;CCNetWorkingDirectory={4}", testDateString, testTimeString, StringUtil.AutoDoubleQuoteString(result.ArtifactDirectory), StringUtil.AutoDoubleQuoteString(Path.GetTempPath() + "test_ListenFile.xml"), StringUtil.AutoDoubleQuoteString(DefaultWorkingDirectoryWithSpaces));
ExpectToExecuteArguments(@"/nologo " + expectedProperties + GetLoggerArgument(), DefaultWorkingDirectoryWithSpaces);
result.Label = @"My Label";
result.WorkingDirectory = DefaultWorkingDirectoryWithSpaces;
@@ -200,7 +200,7 @@ private string IntegrationProperties()
// NOTE: Property names are sorted alphabetically when passed as process arguments
// Tests that look for the correct arguments will fail if the following properties
// are not sorted alphabetically.
- return string.Format(@"/p:CCNetArtifactDirectory={3};CCNetBuildCondition=IfModificationExists;CCNetBuildDate={1};CCNetBuildTime={2};CCNetFailureUsers=;CCNetIntegrationStatus=Success;CCNetLabel=1.0;CCNetLastIntegrationStatus=Success;CCNetListenerFile={4};CCNetModifyingUsers=;CCNetNumericLabel=0;CCNetProject=test;CCNetRequestSource=foo;CCNetUser=;CCNetWorkingDirectory={0}", StringUtil.AutoDoubleQuoteString(DefaultWorkingDirectory), testDateString, testTimeString, StringUtil.AutoDoubleQuoteString(result.ArtifactDirectory), StringUtil.AutoDoubleQuoteString(Path.GetTempPath() + "test_ListenFile.xml"));
+ return string.Format(@"/p:CCNetArtifactDirectory={3};CCNetBuildCondition=IfModificationExists;CCNetBuildDate={1};CCNetBuildTime={2};CCNetFailureTasks=;CCNetFailureUsers=;CCNetIntegrationStatus=Success;CCNetLabel=1.0;CCNetLastIntegrationStatus=Success;CCNetListenerFile={4};CCNetModifyingUsers=;CCNetNumericLabel=0;CCNetProject=test;CCNetRequestSource=foo;CCNetUser=;CCNetWorkingDirectory={0}", StringUtil.AutoDoubleQuoteString(DefaultWorkingDirectory), testDateString, testTimeString, StringUtil.AutoDoubleQuoteString(result.ArtifactDirectory), StringUtil.AutoDoubleQuoteString(Path.GetTempPath() + "test_ListenFile.xml"));
}
}
}
View
2 project/UnitTests/Core/Tasks/NAntTaskTest.cs
@@ -258,7 +258,7 @@ private string IntegrationProperties(string workingDirectory, string artifactDir
// NOTE: Property names are sorted alphabetically when passed as process arguments
// Tests that look for the correct arguments will fail if the following properties
// are not sorted alphabetically.
- return string.Format(@"-D:CCNetArtifactDirectory={1} -D:CCNetBuildCondition=IfModificationExists -D:CCNetBuildDate={2} -D:CCNetBuildTime={3} -D:CCNetFailureUsers= -D:CCNetIntegrationStatus=Success -D:CCNetLabel=1.0 -D:CCNetLastIntegrationStatus=Success -D:CCNetListenerFile={4} -D:CCNetModifyingUsers= -D:CCNetNumericLabel=0 -D:CCNetProject=test -D:CCNetRequestSource=foo -D:CCNetWorkingDirectory={0}", StringUtil.AutoDoubleQuoteString(workingDirectory), StringUtil.AutoDoubleQuoteString(artifactDirectory), testDateString, testTimeString, StringUtil.AutoDoubleQuoteString(Path.GetTempPath() + "test_ListenFile.xml"));
+ return string.Format(@"-D:CCNetArtifactDirectory={1} -D:CCNetBuildCondition=IfModificationExists -D:CCNetBuildDate={2} -D:CCNetBuildTime={3} -D:CCNetFailureTasks= -D:CCNetFailureUsers= -D:CCNetIntegrationStatus=Success -D:CCNetLabel=1.0 -D:CCNetLastIntegrationStatus=Success -D:CCNetListenerFile={4} -D:CCNetModifyingUsers= -D:CCNetNumericLabel=0 -D:CCNetProject=test -D:CCNetRequestSource=foo -D:CCNetWorkingDirectory={0}", StringUtil.AutoDoubleQuoteString(workingDirectory), StringUtil.AutoDoubleQuoteString(artifactDirectory), testDateString, testTimeString, StringUtil.AutoDoubleQuoteString(Path.GetTempPath() + "test_ListenFile.xml"));
}
}
}
View
3 project/UnitTests/resources/UnitTestResults2.xml
@@ -12,6 +12,8 @@
value="21:00:00" />
<parameter name="$CCNetFailureUsers"
value="System.Collections.ArrayList" />
+ <parameter name="$CCNetFailureTasks"
+ value="System.Collections.ArrayList" />
<parameter name="$CCNetIntegrationStatus"
value="Unknown" />
<parameter name="$CCNetLabel"
@@ -45,6 +47,7 @@
<CCNetBuildDate>2011-09-01</CCNetBuildDate>
<CCNetBuildTime>21:00:00</CCNetBuildTime>
<CCNetFailureUsers />
+ <CCNetFailureTasks />
<CCNetIntegrationStatus>Success</CCNetIntegrationStatus>
<CCNetLabel>1.0.0.1429</CCNetLabel>
<CCNetLastIntegrationStatus>Success</CCNetLastIntegrationStatus>
View
7 project/core/IIntegrationResult.cs
@@ -153,6 +153,13 @@ public interface IIntegrationResult
/// <value></value>
/// <remarks></remarks>
ArrayList FailureUsers { get; } // This should really be a Set but sets are not available in .NET 1.1
+ // Name of the tasks which contributed to the current build failure:
+ /// <summary>
+ /// Gets the failure tasks.
+ /// </summary>
+ /// <value></value>
+ /// <remarks></remarks>
+ ArrayList FailureTasks { get; } // This should really be a Set but sets are not available in .NET 1.1
/// <summary>
/// Gets the last modification date.
/// </summary>
View
4 project/core/IntegrationPropertyNames.cs
@@ -64,6 +64,10 @@ public class IntegrationPropertyNames
/// </summary>
public const string CCNetFailureUsers = "CCNetFailureUsers";
/// <summary>
+ /// The list of name of tasks which have contributed to the current build failure.
+ /// </summary>
+ public const string CCNetFailureTasks = "CCNetFailureTasks";
+ /// <summary>
/// The list of users who have contributed to the current build only
/// </summary>
public const string CCNetModifyingUsers = "CCNetModifyingUsers";
View
11 project/core/IntegrationResult.cs
@@ -40,6 +40,7 @@ public class IntegrationResult : IIntegrationResult
// mutable properties
private IntegrationStatus status = IntegrationStatus.Unknown;
private ArrayList failureUsers = new ArrayList();
+ private ArrayList failureTasks = new ArrayList();
private string label = InitialLabel;
private DateTime startTime;
private DateTime endTime;
@@ -550,6 +551,15 @@ public ArrayList FailureUsers
}
/// <summary>
+ /// The list of names of tasks which contributed to the current build failure.
+ /// </summary>
+ public ArrayList FailureTasks
+ {
+ get { return failureTasks; }
+ set { failureTasks = value; }
+ }
+
+ /// <summary>
/// Gets the integration request.
/// </summary>
/// <value></value>
@@ -584,6 +594,7 @@ public IDictionary IntegrationProperties
fullProps[IntegrationPropertyNames.CCNetLastIntegrationStatus] = LastIntegrationStatus;
fullProps[IntegrationPropertyNames.CCNetListenerFile] = BuildProgressInformation.ListenerFile;
fullProps[IntegrationPropertyNames.CCNetFailureUsers] = FailureUsers;
+ fullProps[IntegrationPropertyNames.CCNetFailureTasks] = FailureTasks;
fullProps[IntegrationPropertyNames.CCNetModifyingUsers] = GetModifiers();
fullProps[IntegrationPropertyNames.CCNetUser] = request.UserName;
if (IntegrationRequest != null) fullProps[IntegrationPropertyNames.CCNetRequestSource] = IntegrationRequest.Source;
View
1 project/core/IntegrationResultManager.cs
@@ -131,6 +131,7 @@ private static IntegrationSummary ConvertResultIntoSummary(IIntegrationResult in
string lastSuccessfulIntegrationLabel = (integration.Succeeded) ? integration.Label : integration.LastSuccessfulIntegrationLabel;
IntegrationSummary newSummary = new IntegrationSummary(integration.Status, integration.Label, lastSuccessfulIntegrationLabel, integration.StartTime);
newSummary.FailureUsers = integration.FailureUsers;
+ newSummary.FailureTasks = integration.FailureTasks;
return newSummary;
}
}
View
14 project/core/IntegrationSummary.cs
@@ -20,6 +20,7 @@ public class IntegrationSummary
private string lastSuccessfulIntegrationLabel;
private DateTime startTime;
private ArrayList failureUsers = new ArrayList();
+ private ArrayList failureTasks = new ArrayList();
/// <summary>
/// Initializes a new instance of the <see cref="IntegrationSummary" /> class.
@@ -133,5 +134,16 @@ public ArrayList FailureUsers
get { return failureUsers; }
set { failureUsers = value; }
}
- }
+
+ /// <summary>
+ /// Gets or sets the failure tasks.
+ /// </summary>
+ /// <value>The failure tasks.</value>
+ /// <remarks></remarks>
+ public ArrayList FailureTasks
+ {
+ get { return failureTasks; }
+ set { failureTasks = value; }
+ }
+ }
}
View
7 project/core/Project.cs
@@ -957,11 +957,18 @@ public void PublishResults(IIntegrationResult result, Dictionary<string, string>
if (result.Succeeded)
{
messages.Clear();
+ //result.FailureTasks.Clear();
}
else
{
AddBreakersToMessages(result);
AddFailedTaskToMessages();
+
+ var failedTasks = new List<string>();
+ FindFailedTasks(currentProjectStatus, failedTasks);
+
+ //result.FailureTasks.Clear();
+ result.FailureTasks.AddRange(failedTasks);
}
this.ClearMessages(Message.MessageKind.BuildStatus);
View
2 project/core/publishers/XmlIntegrationResultWriter.cs
@@ -162,6 +162,8 @@ private void WriteIntegrationProperties(IIntegrationResult result)
IntegrationPropertyNames.CCNetBuildTime);
WriteIntegrationProperty(result.IntegrationProperties[IntegrationPropertyNames.CCNetFailureUsers],
IntegrationPropertyNames.CCNetFailureUsers);
+ WriteIntegrationProperty(result.IntegrationProperties[IntegrationPropertyNames.CCNetFailureTasks],
+ IntegrationPropertyNames.CCNetFailureTasks);
WriteIntegrationProperty(result.IntegrationProperties[IntegrationPropertyNames.CCNetIntegrationStatus],
IntegrationPropertyNames.CCNetIntegrationStatus);
WriteIntegrationProperty(result.IntegrationProperties[IntegrationPropertyNames.CCNetLabel],

0 comments on commit 1cb60c8

Please sign in to comment.
Something went wrong with that request. Please try again.