From: <dpi...@us...> - 2006-09-02 15:55:47
|
Revision: 2528 http://svn.sourceforge.net/ccnet/?rev=2528&view=rev Author: dpiessens Date: 2006-09-02 08:55:26 -0700 (Sat, 02 Sep 2006) Log Message: ----------- ccnet-738 Modified ccnet infrastructure to support an optional category attribute including tests Modified Paths: -------------- trunk/project/CCTrayLib/Monitoring/DashboardXmlParser.cs trunk/project/Remote/ProjectStatus.cs trunk/project/UnitTests/CCTrayLib/Presentation/DetailStringProviderTest.cs trunk/project/UnitTests/Core/ProjectStatusFixture.cs trunk/project/UnitTests/Core/ProjectTest.cs trunk/project/UnitTests/UnitTests.csproj trunk/project/UnitTests/WebDashboard/Dashboard/ProjectGridTest.cs trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionSchema.xsd trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionTest.cs trunk/project/WebDashboard/Dashboard/ProjectGridRow.cs trunk/project/WebDashboard/Plugins/FarmReport/XmlReportAction.cs trunk/project/core/IProject.cs trunk/project/core/Project.cs trunk/project/core/ProjectBase.cs Added Paths: ----------- trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionSchema.xsx Modified: trunk/project/CCTrayLib/Monitoring/DashboardXmlParser.cs =================================================================== --- trunk/project/CCTrayLib/Monitoring/DashboardXmlParser.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/CCTrayLib/Monitoring/DashboardXmlParser.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -34,6 +34,9 @@ [XmlAttribute()] public string webUrl; + + [XmlAttribute()] + public string category; } public class DashboardXmlParser : IDashboardXmlParser @@ -52,6 +55,7 @@ { return new ProjectStatus( project.name, + project.category, new ProjectActivity(project.activity), (IntegrationStatus) Enum.Parse(typeof (IntegrationStatus), project.lastBuildStatus), ProjectIntegratorState.Running, Modified: trunk/project/Remote/ProjectStatus.cs =================================================================== --- trunk/project/Remote/ProjectStatus.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/Remote/ProjectStatus.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -17,6 +17,7 @@ private IntegrationStatus buildStatus; private ProjectActivity activity = ProjectActivity.Sleeping; private string name; + private string category; private string webURL; private SerializableDateTime lastBuildDate = SerializableDateTime.Default; private string lastBuildLabel; @@ -33,12 +34,13 @@ this.lastBuildDate = new SerializableDateTime(lastBuildDate); } - public ProjectStatus(string name, ProjectActivity activity, IntegrationStatus buildStatus, ProjectIntegratorState status, string webURL, DateTime lastBuildDate, string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime) + public ProjectStatus(string name, string category, ProjectActivity activity, IntegrationStatus buildStatus, ProjectIntegratorState status, string webURL, DateTime lastBuildDate, string lastBuildLabel, string lastSuccessfulBuildLabel, DateTime nextBuildTime) { this.status = status; this.buildStatus = buildStatus; this.activity = activity; this.name = name; + this.category = category; this.webURL = webURL; this.lastBuildDate = new SerializableDateTime(lastBuildDate); this.lastBuildLabel = lastBuildLabel; @@ -66,6 +68,11 @@ get { return name; } } + public string Category + { + get { return category; } + } + public string WebURL { get { return webURL; } Modified: trunk/project/UnitTests/CCTrayLib/Presentation/DetailStringProviderTest.cs =================================================================== --- trunk/project/UnitTests/CCTrayLib/Presentation/DetailStringProviderTest.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/UnitTests/CCTrayLib/Presentation/DetailStringProviderTest.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -30,7 +30,7 @@ DateTime nextBuildTime = new DateTime(2005, 7, 20, 15, 12, 30); monitor.ProjectStatus = new ProjectStatus( - "NAME", + "NAME", "category", ProjectActivity.Sleeping, IntegrationStatus.Unknown, ProjectIntegratorState.Running, "url", DateTime.MinValue, "lastLabel", null, nextBuildTime); @@ -50,7 +50,7 @@ DateTime nextBuildTime = DateTime.MaxValue; monitor.ProjectStatus = new ProjectStatus( - "NAME", + "NAME", "category", ProjectActivity.Sleeping, IntegrationStatus.Unknown, ProjectIntegratorState.Running, "url", DateTime.MinValue, "lastLabel", null, nextBuildTime); Modified: trunk/project/UnitTests/Core/ProjectStatusFixture.cs =================================================================== --- trunk/project/UnitTests/Core/ProjectStatusFixture.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/UnitTests/Core/ProjectStatusFixture.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -6,6 +6,7 @@ public class ProjectStatusFixture { public const string DefaultProject = "project"; + public const string DefaultCategory = "category"; public static readonly ProjectActivity DefaultActivity = ProjectActivity.CheckingModifications; public static readonly DateTime DefaultLastBuildDate = DateTime.Now; public const ProjectIntegratorState DefaultIntegratorState = ProjectIntegratorState.Running; @@ -51,7 +52,12 @@ public static ProjectStatus New(string project, ProjectActivity activity, IntegrationStatus integrationStatus, ProjectIntegratorState integratorState, string label, DateTime lastBuildDate) { - return new ProjectStatus(project, activity, integrationStatus, integratorState, DefaultUrl, lastBuildDate, label, label, DefaultLastBuildDate); + return new ProjectStatus(project, DefaultCategory, activity, integrationStatus, integratorState, DefaultUrl, lastBuildDate, label, label, DefaultLastBuildDate); } + + public static ProjectStatus New(string project, string category, ProjectActivity activity, IntegrationStatus integrationStatus, ProjectIntegratorState integratorState, string label, DateTime lastBuildDate) + { + return new ProjectStatus(project, category, activity, integrationStatus, integratorState, DefaultUrl, lastBuildDate, label, label, DefaultLastBuildDate); + } } } \ No newline at end of file Modified: trunk/project/UnitTests/Core/ProjectTest.cs =================================================================== --- trunk/project/UnitTests/Core/ProjectTest.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/UnitTests/Core/ProjectTest.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -89,7 +89,7 @@ public void LoadFullySpecifiedProjectFromConfiguration() { string xml = @" -<project name=""foo"" webURL=""http://localhost/ccnet"" modificationDelaySeconds=""60"" publishExceptions=""true""> +<project name=""foo"" webURL=""http://localhost/ccnet"" modificationDelaySeconds=""60"" publishExceptions=""true"" category=""category1""> <workingDirectory>c:\my\working\directory</workingDirectory> <build type=""nant"" /> <sourcecontrol type=""filesystem""> @@ -119,6 +119,7 @@ project = (Project) NetReflector.Read(xml); Assert.AreEqual("foo", project.Name); Assert.AreEqual("http://localhost/ccnet", project.WebURL); + Assert.AreEqual("category1", project.Category); Assert.AreEqual(60, project.ModificationDelaySeconds); Assert.AreEqual(true, project.PublishExceptions); Assert.IsTrue(project.Builder is NAntTask); Modified: trunk/project/UnitTests/UnitTests.csproj =================================================================== --- trunk/project/UnitTests/UnitTests.csproj 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/UnitTests/UnitTests.csproj 2006-09-02 15:55:26 UTC (rev 2528) @@ -1466,6 +1466,11 @@ BuildAction = "EmbeddedResource" /> <File + RelPath = "WebDashboard\Plugins\BuildReport\XmlReportActionSchema.xsx" + DependentUpon = "XmlReportActionSchema.xsd" + BuildAction = "None" + /> + <File RelPath = "WebDashboard\Plugins\BuildReport\XmlReportActionTest.cs" SubType = "Code" BuildAction = "Compile" Modified: trunk/project/UnitTests/WebDashboard/Dashboard/ProjectGridTest.cs =================================================================== --- trunk/project/UnitTests/WebDashboard/Dashboard/ProjectGridTest.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/UnitTests/WebDashboard/Dashboard/ProjectGridTest.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -186,7 +186,7 @@ public void ShouldCopyProjectStatusToProjectRow() { // Setup - ProjectStatus projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, + ProjectStatus projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", DateTime.Today, "my label", null, DateTime.Today); ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[] { @@ -202,7 +202,7 @@ VerifyAll(); // Setup - projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, + projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Stopped, "url", DateTime.Today, "my label", null, DateTime.Today); statusses = new ProjectStatusOnServer[] { @@ -222,7 +222,7 @@ public void ShouldCopyProjectActivityToProjectRow() { // Setup - ProjectStatus projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, + ProjectStatus projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", DateTime.Today, "my label", null, DateTime.Today); ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[] { @@ -238,7 +238,7 @@ VerifyAll(); // Setup - projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, + projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, "category", ProjectActivity.CheckingModifications, IntegrationStatus.Success, ProjectIntegratorState.Stopped, "url", DateTime.Today, "my label", null, DateTime.Today); statusses = new ProjectStatusOnServer[] { @@ -259,7 +259,7 @@ { // Setup DateTime date = DateTime.Today; - ProjectStatus projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, + ProjectStatus projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", date, "my label", null, DateTime.Today); ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[] { @@ -279,7 +279,7 @@ public void ShouldCreateLinkToProjectReport() { // Setup - ProjectStatus projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, + ProjectStatus projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", DateTime.Today, "1", null, DateTime.Today); ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[] @@ -300,7 +300,7 @@ public void ShouldCopyProjectMessagesToProjectRow() { // Setup - ProjectStatus projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, + ProjectStatus projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", DateTime.Today, "my label", null, DateTime.Today); projectStatus1.Messages = new Message[1] {new Message("Test Message")}; @@ -320,7 +320,7 @@ VerifyAll(); // Setup - projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, + projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Stopped, "url", DateTime.Today, "my label", null, DateTime.Today); projectStatus1.Messages = new Message[2] {new Message(string.Empty), new Message("Second Message")}; @@ -343,15 +343,55 @@ } [Test] + public void ShouldCopyProjectCategoryToProjectRow() + { + // Setup + ProjectStatus projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, "category", + ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", DateTime.Today, "my label", null, DateTime.Today); + + + ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[] + { + new ProjectStatusOnServer(projectStatus1, serverSpecifier) + }; + SetupProjectLinkExpectation(); + + // Execute + ProjectGridRow[] rows = projectGrid.GenerateProjectGridRows(statusses, "myAction", ProjectGridSortColumn.Name, true); + + // Verify + Assert.AreEqual("category", rows[0].Category); + VerifyAll(); + + // Setup + projectStatus1 = new ProjectStatus(projectSpecifier.ProjectName, "category1", + ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Stopped, "url", DateTime.Today, "my label", null, DateTime.Today); + + + statusses = new ProjectStatusOnServer[] + { + new ProjectStatusOnServer(projectStatus1, serverSpecifier) + }; + SetupProjectLinkExpectation(); + + // Execute + rows = projectGrid.GenerateProjectGridRows(statusses, "myAction", ProjectGridSortColumn.Name, true); + + // Verify + Assert.AreEqual("category1", rows[0].Category); + VerifyAll(); + } + + [Test] public void ShouldReturnProjectsSortedByNameIfNameColumnSpecifiedAsSortSeed() { // Setup IProjectSpecifier projectA = new DefaultProjectSpecifier(serverSpecifier, "a"); IProjectSpecifier projectB = new DefaultProjectSpecifier(serverSpecifier, "b"); - ProjectStatus projectStatus1 = new ProjectStatus("a", + ProjectStatus projectStatus1 = new ProjectStatus("a", "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", DateTime.Today, "1", null, DateTime.Today); - ProjectStatus projectStatus2 = new ProjectStatus("b", + ProjectStatus projectStatus2 = new ProjectStatus("b", "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", DateTime.Today, "1", null, DateTime.Today); ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[] { @@ -391,9 +431,9 @@ IProjectSpecifier projectA = new DefaultProjectSpecifier(serverSpecifier, "a"); IProjectSpecifier projectB = new DefaultProjectSpecifier(serverSpecifier, "b"); - ProjectStatus projectStatus1 = new ProjectStatus("b", + ProjectStatus projectStatus1 = new ProjectStatus("b", "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", DateTime.Today, "1", null, DateTime.Today); - ProjectStatus projectStatus2 = new ProjectStatus("a", + ProjectStatus projectStatus2 = new ProjectStatus("a", "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", DateTime.Today.AddHours(1), "1", null, DateTime.Today); ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[] { @@ -432,9 +472,9 @@ // Setup IProjectSpecifier projectA = new DefaultProjectSpecifier(serverSpecifier, "a"); IProjectSpecifier projectB = new DefaultProjectSpecifier(serverSpecifier, "b"); - ProjectStatus projectStatus1 = new ProjectStatus("a", + ProjectStatus projectStatus1 = new ProjectStatus("a", "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", DateTime.Today, "1", null, DateTime.Today); - ProjectStatus projectStatus2 = new ProjectStatus("b", + ProjectStatus projectStatus2 = new ProjectStatus("b", "category", ProjectActivity.Sleeping, IntegrationStatus.Failure, ProjectIntegratorState.Running, "url", DateTime.Today.AddHours(1), "1", null, DateTime.Today); ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[] { @@ -476,9 +516,9 @@ IProjectSpecifier projectA = new DefaultProjectSpecifier(serverSpecifierA, "a"); IProjectSpecifier projectB = new DefaultProjectSpecifier(serverSpecifierB, "b"); - ProjectStatus projectStatus1 = new ProjectStatus("a", + ProjectStatus projectStatus1 = new ProjectStatus("a", "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "url", DateTime.Today, "1", null, DateTime.Today); - ProjectStatus projectStatus2 = new ProjectStatus("b", + ProjectStatus projectStatus2 = new ProjectStatus("b", "category", ProjectActivity.Sleeping, IntegrationStatus.Failure, ProjectIntegratorState.Running, "url", DateTime.Today.AddHours(1), "1", null, DateTime.Today); ProjectStatusOnServer[] statusses = new ProjectStatusOnServer[] { Modified: trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionSchema.xsd =================================================================== --- trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionSchema.xsd 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionSchema.xsd 2006-09-02 15:55:26 UTC (rev 2528) @@ -30,6 +30,7 @@ <xs:attribute name="lastBuildTime" type="xs:dateTime" use="required"/> <xs:attribute name="nextBuildTime" type="xs:dateTime" use="required"/> <xs:attribute name="webUrl" type="xs:string" use="required"/> + <xs:attribute name="category" type="xs:string" use="required"/> </xs:complexType> </xs:element> </xs:sequence> Added: trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionSchema.xsx =================================================================== --- trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionSchema.xsx (rev 0) +++ trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionSchema.xsx 2006-09-02 15:55:26 UTC (rev 2528) @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<!--This file is auto-generated by the XML Schema Designer. It holds layout information for components on the designer surface.--> +<XSDDesignerLayout layoutVersion="2" viewPortLeft="-3646" viewPortTop="0" zoom="100"> + <Projects_XmlElement left="317" top="254" width="5292" height="2963" selected="0" zOrder="1" index="0" expanded="1"> + <Project_XmlElement left="317" top="3725" width="5292" height="2963" selected="0" zOrder="2" index="0" expanded="1"> + <activity_XmlAttribute left="-2646" top="7196" width="5292" height="847" selected="0" zOrder="5" index="1" expanded="1"> + <_x0028_activity_x0029__XmlSimpleType left="-2646" top="8551" width="5292" height="2963" selected="0" zOrder="8" index="0" expanded="1" /> + </activity_XmlAttribute> + <lastBuildStatus_XmlAttribute left="3280" top="7196" width="5292" height="847" selected="0" zOrder="11" index="2" expanded="1"> + <_x0028_lastBuildStatus_x0029__XmlSimpleType left="3280" top="8551" width="5292" height="2963" selected="0" zOrder="14" index="0" expanded="1" /> + </lastBuildStatus_XmlAttribute> + </Project_XmlElement> + </Projects_XmlElement> +</XSDDesignerLayout> \ No newline at end of file Modified: trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionTest.cs =================================================================== --- trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionTest.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/UnitTests/WebDashboard/Plugins/BuildReport/XmlReportActionTest.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -80,6 +80,7 @@ AssertXPathMatches(doc, "/Projects/Project/@lastBuildTime", XmlConvert.ToString(LastBuildTime)); AssertXPathMatches(doc, "/Projects/Project/@nextBuildTime", XmlConvert.ToString(NextBuildTime)); AssertXPathMatches(doc, "/Projects/Project/@webUrl", "http://blah"); + AssertXPathMatches(doc, "/Projects/Project/@category", "category"); mockFarmService.Verify(); @@ -125,7 +126,7 @@ private ProjectStatus CreateProjectStatus() { return - new ProjectStatus("HelloWorld", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, + new ProjectStatus("HelloWorld", "category", ProjectActivity.Sleeping, IntegrationStatus.Success, ProjectIntegratorState.Running, "http://blah", LastBuildTime, "build_8", "build_7", NextBuildTime); } Modified: trunk/project/WebDashboard/Dashboard/ProjectGridRow.cs =================================================================== --- trunk/project/WebDashboard/Dashboard/ProjectGridRow.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/WebDashboard/Dashboard/ProjectGridRow.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -28,6 +28,11 @@ get { return serverSpecifier.ServerName; } } + public string Category + { + get { return status.Category; } + } + public string BuildStatus { get { return status.BuildStatus.ToString(); } Modified: trunk/project/WebDashboard/Plugins/FarmReport/XmlReportAction.cs =================================================================== --- trunk/project/WebDashboard/Plugins/FarmReport/XmlReportAction.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/WebDashboard/Plugins/FarmReport/XmlReportAction.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -41,6 +41,7 @@ xmlWriter.WriteStartElement("Project"); xmlWriter.WriteAttributeString("name", status.Name); + xmlWriter.WriteAttributeString("category", status.Category); xmlWriter.WriteAttributeString("activity", status.Activity.ToString()); xmlWriter.WriteAttributeString("lastBuildStatus", status.BuildStatus.ToString()); xmlWriter.WriteAttributeString("lastBuildLabel", status.LastSuccessfulBuildLabel); Modified: trunk/project/core/IProject.cs =================================================================== --- trunk/project/core/IProject.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/core/IProject.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -18,6 +18,14 @@ } /// <summary> + /// An optional category that groups the project + /// </summary> + string Category + { + get; + } + + /// <summary> /// A component to trigger integrations for this project. /// TODO: remove /// </summary> Modified: trunk/project/core/Project.cs =================================================================== --- trunk/project/core/Project.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/core/Project.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -249,7 +249,7 @@ public ProjectStatus CreateProjectStatus(IProjectIntegrator integrator) { - ProjectStatus status = new ProjectStatus(Name, CurrentActivity, LatestBuildStatus, integrator.State, WebURL, + ProjectStatus status = new ProjectStatus(Name, Category, CurrentActivity, LatestBuildStatus, integrator.State, WebURL, LastIntegrationResult.StartTime, LastIntegrationResult.Label, LastIntegrationResult.LastSuccessfulIntegrationLabel, Triggers.NextBuild); status.Messages = (Message[])messages.ToArray(typeof(Message)); Modified: trunk/project/core/ProjectBase.cs =================================================================== --- trunk/project/core/ProjectBase.cs 2006-09-01 05:51:18 UTC (rev 2527) +++ trunk/project/core/ProjectBase.cs 2006-09-02 15:55:26 UTC (rev 2528) @@ -12,6 +12,7 @@ public static readonly string DefaultArtifactSubDirectory = "Artifacts"; private string name; + private string category = ""; private string configuredWorkingDirectory = ""; private string configuredArtifactDirectory = ""; private ITrigger triggers = new MultipleTrigger(new ITrigger[] {new IntervalTrigger() } ); @@ -24,6 +25,13 @@ set { name = value; } } + [ReflectorProperty("category", Required=false)] + public virtual string Category + { + get { return category; } + set { category = value; } + } + [ReflectorProperty("triggers", InstanceType=typeof(MultipleTrigger), Required=false)] public ITrigger Triggers { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <exo...@us...> - 2006-09-07 04:30:17
|
Revision: 2533 http://svn.sourceforge.net/ccnet/?rev=2533&view=rev Author: exortech Date: 2006-09-06 21:30:05 -0700 (Wed, 06 Sep 2006) Log Message: ----------- - reducing number of tests creating temporary directories -- causing sporadic test failures on machines with faster hardware. - introducing SystemPath class to support creating unique temp directories and building paths. Modified Paths: -------------- trunk/project/UnitTests/Core/ConsoleRunnerTest.cs trunk/project/UnitTests/Core/LogFileTest.cs trunk/project/UnitTests/Core/Publishers/BuildPublisherTest.cs trunk/project/UnitTests/Core/SourceControl/FileSourceControlTest.cs trunk/project/UnitTests/Core/SourceControl/MksTest.cs trunk/project/UnitTests/Core/Util/SystemIoFileSystemTest.cs trunk/project/core/core.csproj trunk/project/core/util/TempFileUtil.cs Added Paths: ----------- trunk/project/core/util/SystemPath.cs Modified: trunk/project/UnitTests/Core/ConsoleRunnerTest.cs =================================================================== --- trunk/project/UnitTests/Core/ConsoleRunnerTest.cs 2006-09-06 07:49:54 UTC (rev 2532) +++ trunk/project/UnitTests/Core/ConsoleRunnerTest.cs 2006-09-07 04:30:05 UTC (rev 2533) @@ -17,14 +17,12 @@ { backup = new TraceListenerBackup(); listener = backup.AddTestTraceListener(); - TempFileUtil.CreateTempDir("ConsoleRunnerTest"); } [TearDown] public void TearDown() { backup.Reset(); - TempFileUtil.DeleteTempDir("ConsoleRunnerTest"); } [Test, Ignore("This test has initimate knowledge of the logging implementation; it should not")] Modified: trunk/project/UnitTests/Core/LogFileTest.cs =================================================================== --- trunk/project/UnitTests/Core/LogFileTest.cs 2006-09-06 07:49:54 UTC (rev 2532) +++ trunk/project/UnitTests/Core/LogFileTest.cs 2006-09-07 04:30:05 UTC (rev 2533) @@ -9,21 +9,6 @@ [TestFixture] public class LogFileTest : CustomAssertion { - private static readonly string TestFolder = "logfilelist"; - private string _tempFolder; - - [SetUp] - public void Setup() - { - _tempFolder = TempFileUtil.CreateTempDir(TestFolder); - } - - [TearDown] - public void Teardown() - { - TempFileUtil.DeleteTempDir(TestFolder); - } - [Test] public void ParseDateFromFilename() { @@ -79,12 +64,15 @@ // testFilenames array must be in sorted order -- otherwise links iteration will fail string[] testFilenames = {"log123.xml", "log200.xml", "logfile.txt", "log20020830164057Lbuild.6.xml", "badfile.xml" }; - TempFileUtil.CreateTempFiles(TestFolder, testFilenames); - - string[] fileNames = LogFileUtil.GetLogFileNames(_tempFolder); - Assert.AreEqual(3,fileNames.Length); - Assert.AreEqual(testFilenames[0],fileNames[0]); - Assert.AreEqual(testFilenames[1],fileNames[1]); + + using (TempDirectory tempPath = new TempDirectory()) + { + CreateTempFiles(tempPath, testFilenames); + string[] fileNames = LogFileUtil.GetLogFileNames(tempPath.ToString()); + Assert.AreEqual(3,fileNames.Length); + Assert.AreEqual(testFilenames[0],fileNames[0]); + Assert.AreEqual(testFilenames[1],fileNames[1]); + } } [Test] @@ -95,11 +83,12 @@ "log20011230164057Lbuild.8.xml", "log20010430164057Lbuild.7.xml", "badfile.xml" }; - TempFileUtil.CreateTempFiles(TestFolder, testFilenames); - string path = TempFileUtil.GetTempPath(TestFolder); - - string logfile = LogFileUtil.GetLatestLogFileName(path); - Assert.AreEqual("log20011230164057Lbuild.8.xml", logfile); + using (TempDirectory tempPath = new TempDirectory()) + { + CreateTempFiles(tempPath, testFilenames); + string logfile = LogFileUtil.GetLatestLogFileName(tempPath.ToString()); + Assert.AreEqual("log20011230164057Lbuild.8.xml", logfile); + } } [Test] @@ -112,8 +101,10 @@ [Test] public void GetLastLogFileName_EmptyFolder() { - string folder = TempFileUtil.CreateTempDir(TestFolder); - Assert.IsNull(LogFileUtil.GetLatestLogFileName(folder)); + using (TempDirectory tempDir = new TempDirectory()) + { + Assert.IsNull(LogFileUtil.GetLatestLogFileName(tempDir.ToString())); + } } [Test] @@ -124,13 +115,23 @@ "log20011230164057Lbuild.6.xml", "log20010430164057Lbuild.6.xml", "badfile.xml" }; - TempFileUtil.CreateTempFiles(TestFolder, testFilenames); - DateTime expected = new DateTime(2001,12,30,16,40,57); - string path = TempFileUtil.GetTempPath(TestFolder); - DateTime actual = LogFileUtil.GetLastBuildDate(path, new DateTime()); - Assert.AreEqual(expected, actual); + using (TempDirectory tempPath = new TempDirectory()) + { + CreateTempFiles(tempPath, testFilenames); + DateTime expected = new DateTime(2001,12,30,16,40,57); + DateTime actual = LogFileUtil.GetLastBuildDate(tempPath.ToString(), new DateTime()); + Assert.AreEqual(expected, actual); + } } - + + private void CreateTempFiles(SystemPath path, string[] filenames) + { + foreach (string filename in filenames) + { + path.CreateEmptyFile(filename); + } + } + [Test] public void GetLastBuildDate_NoDirectory() { @@ -140,8 +141,10 @@ [Test] public void GetLastBuildDate_NoFiles() { - string path = TempFileUtil.CreateTempDir("lastbuilddate_nofiles"); - Assert.AreEqual(new DateTime(), LogFileUtil.GetLastBuildDate(path, new DateTime())); + using (TempDirectory tempDir = new TempDirectory()) + { + Assert.AreEqual(new DateTime(), LogFileUtil.GetLastBuildDate(tempDir.ToString(), new DateTime())); + } } [Test] Modified: trunk/project/UnitTests/Core/Publishers/BuildPublisherTest.cs =================================================================== --- trunk/project/UnitTests/Core/Publishers/BuildPublisherTest.cs 2006-09-06 07:49:54 UTC (rev 2532) +++ trunk/project/UnitTests/Core/Publishers/BuildPublisherTest.cs 2006-09-07 04:30:05 UTC (rev 2533) @@ -1,7 +1,7 @@ -using System.IO; using NUnit.Framework; using ThoughtWorks.CruiseControl.Core; using ThoughtWorks.CruiseControl.Core.Publishers; +using ThoughtWorks.CruiseControl.Core.Util; using ThoughtWorks.CruiseControl.Remote; namespace ThoughtWorks.CruiseControl.UnitTests.Core.Publishers @@ -9,76 +9,49 @@ [TestFixture] public class BuildPublisherTest : CustomAssertion { - private string pubDir = "BuildPublisherTest.PubDir"; - private string srcDir = "BuildPublisherTest.SrcDir"; - private string subDir = "SubDir"; - private string subSubDir = "SubSubDir"; + private SystemPath srcRoot; + private SystemPath pubRoot; + private SystemPath subRoot; + private SystemPath subSubRoot; private const string fileName = "foo.txt"; private const string fileContents = "I'm the contents of foo.txt"; [SetUp] - public void SetUp() + public void SetUp() { - DirectoryInfo src = new DirectoryInfo(srcDir); - if (!src.Exists) - src.Create(); - - DirectoryInfo sub = new DirectoryInfo(string.Format("{0}\\{1}", srcDir, subDir)); - if (!sub.Exists) - sub.Create(); - DirectoryInfo subSub = new DirectoryInfo(string.Format("{0}\\{1}", sub.FullName, subSubDir)); - if (!subSub.Exists) - subSub.Create(); - - FileInfo srcFile = new FileInfo(srcDir + @"\" + fileName); - StreamWriter writer = srcFile.CreateText(); - writer.WriteLine(fileContents); - writer.Close(); - - - FileInfo subFile = new FileInfo(sub.FullName + @"\" + fileName); - writer = subFile.CreateText(); - writer.WriteLine(fileContents); - writer.Close(); - - FileInfo subSubFile = new FileInfo(subSub.FullName + @"\" + fileName); - writer = subSubFile.CreateText(); - writer.WriteLine(fileContents); - writer.Close(); + srcRoot = SystemPath.UniqueTempPath(); + pubRoot = SystemPath.UniqueTempPath(); + subRoot = srcRoot.CreateSubDirectory("SubDir"); + subSubRoot = subRoot.CreateSubDirectory("SubSubDir"); + srcRoot.CreateTextFile(fileName, fileContents); + subRoot.CreateTextFile(fileName, fileContents); + subSubRoot.CreateTextFile(fileName, fileContents); } [Test] - public void TestCopyFiles() + public void TestCopyFiles() { BuildPublisher publisher = new BuildPublisher(); - publisher.PublishDir = pubDir; - publisher.SourceDir = srcDir; + publisher.PublishDir = pubRoot.ToString(); + publisher.SourceDir = srcRoot.ToString(); IntegrationResult result = new IntegrationResult(); result.Status = IntegrationStatus.Success; result.Label = "99"; publisher.Run(result); - FileInfo resultFile = new FileInfo(pubDir + @"\99\" + fileName); - Assert.IsTrue(resultFile.Exists, "File not found in build number directory"); - - resultFile = new FileInfo(pubDir + @"\99\" + subDir + "\\" + fileName); - Assert.IsTrue(resultFile.Exists, "File not found in sub directory"); - - resultFile = new FileInfo(pubDir + @"\99\" + subDir + "\\" + subSubDir + "\\" + fileName); - Assert.IsTrue(resultFile.Exists, "File not found in sub sub directory"); + SystemPath labelPubDir = pubRoot.Combine("99"); + Assert.IsTrue(labelPubDir.Combine(fileName).Exists(), "File not found in build number directory"); + SystemPath subPubDir = labelPubDir.Combine("SubDir"); + Assert.IsTrue(subPubDir.Combine(fileName).Exists(), "File not found in sub directory"); + Assert.IsTrue(subPubDir.Combine("SubSubDir").Combine(fileName).Exists(), "File not found in sub sub directory"); } [TearDown] - public void TearDown() + public void TearDown() { - DirectoryInfo pub = new DirectoryInfo(pubDir); - if (pub.Exists) - pub.Delete(true); - - DirectoryInfo src = new DirectoryInfo(srcDir); - if (src.Exists) - src.Delete(true); + srcRoot.DeleteDirectory(); + pubRoot.DeleteDirectory(); } } -} +} \ No newline at end of file Modified: trunk/project/UnitTests/Core/SourceControl/FileSourceControlTest.cs =================================================================== --- trunk/project/UnitTests/Core/SourceControl/FileSourceControlTest.cs 2006-09-06 07:49:54 UTC (rev 2532) +++ trunk/project/UnitTests/Core/SourceControl/FileSourceControlTest.cs 2006-09-07 04:30:05 UTC (rev 2533) @@ -11,45 +11,40 @@ [TestFixture] public class FileSourceControlTest : CustomAssertion { - private string tempDir; - private string tempSubDir; private FileSourceControl sc; private DynamicMock fileSystemMock; + private SystemPath tempRoot; + private SystemPath tempSubRoot; [SetUp] public void SetUp() { fileSystemMock = new DynamicMock(typeof (IFileSystem)); - tempDir = TempFileUtil.CreateTempDir("repo"); - tempSubDir = TempFileUtil.CreateTempDir("repo\\subrepo"); + tempRoot = SystemPath.UniqueTempPath(); + tempSubRoot = tempRoot.Combine("subrepo"); sc = new FileSourceControl((IFileSystem) fileSystemMock.MockInstance); - sc.RepositoryRoot = tempDir; + sc.RepositoryRoot = tempRoot.ToString(); } [TearDown] public void TearDown() { - TempFileUtil.DeleteTempDir(tempSubDir); - TempFileUtil.DeleteTempDir(tempDir); + tempRoot.DeleteDirectory(); } [Test, ExpectedException(typeof (DirectoryNotFoundException))] public void MissingDirectoryThrowsException() { - TempFileUtil.DeleteTempDir(tempSubDir); - TempFileUtil.DeleteTempDir(tempDir); - + Assert.IsFalse(tempRoot.Exists(), "Temporary directory should not exist: " + tempRoot.ToString()); sc.GetModifications(IntegrationResult(DateTime.MinValue), IntegrationResult(DateTime.MaxValue)); } [Test] public void IgnoreMissingDirectoryReturnsZeroMods() { - TempFileUtil.DeleteTempDir(tempSubDir); - TempFileUtil.DeleteTempDir(tempSubDir); - + Assert.IsFalse(tempRoot.Exists(), "Temporary directory should not exist: " + tempRoot.ToString()); sc.IgnoreMissingRoot = true; try { @@ -65,9 +60,11 @@ [Test] public void GetModifications_EmptyLocal() { - string file1 = TempFileUtil.CreateTempFile("repo", "file1.txt", "foo"); - string file2 = TempFileUtil.CreateTempFile("repo", "file2.txt", "bar"); - string file3 = TempFileUtil.CreateTempFile("repo\\subrepo", "file3.txt", "bat"); + tempRoot.CreateDirectory(); + tempSubRoot.CreateDirectory(); + string file1 = tempRoot.CreateTextFile("file1.txt", "foo").ToString(); + string file2 = tempRoot.CreateTextFile("file2.txt", "bar").ToString(); + string file3 = tempSubRoot.CreateTextFile("file3.txt", "bat").ToString(); Modification[] mods = sc.GetModifications(IntegrationResult(DateTime.MinValue), IntegrationResult(DateTime.MaxValue)); @@ -90,6 +87,7 @@ [Test] public void GetModificationsWhenRepositoryFolderIsEmpty() { + tempRoot.CreateDirectory(); Modification[] mods = sc.GetModifications(IntegrationResult(DateTime.MinValue), IntegrationResult(DateTime.MaxValue)); Assert.IsNotNull(mods); Assert.AreEqual(0, mods.Length); @@ -98,8 +96,9 @@ [Test] public void GetModificationsWhenRepositoryRootContainsOneUnmodifiedFile() { - TempFileUtil.CreateTempFile("repo", "file1.txt", "foo"); - string file2 = TempFileUtil.CreateTempFile("repo", "file2.txt", "bar"); + tempRoot.CreateDirectory(); + tempRoot.CreateTextFile("file1.txt", "foo"); + string file2 = tempRoot.CreateTextFile("file2.txt", "bar").ToString(); new FileInfo(file2).LastWriteTime = DateTime.Now.AddHours(2); Modification[] mods = sc.GetModifications(IntegrationResult(DateTime.Now.AddHours(1)), IntegrationResult(DateTime.MaxValue)); @@ -112,7 +111,7 @@ { IntegrationResult result = new IntegrationResult("foo", "myWorkingDirectory"); sc.AutoGetSource = true; - fileSystemMock.Expect("Copy", tempDir, "myWorkingDirectory"); + fileSystemMock.Expect("Copy", tempRoot.ToString(), "myWorkingDirectory"); sc.GetSource(result); Modified: trunk/project/UnitTests/Core/SourceControl/MksTest.cs =================================================================== --- trunk/project/UnitTests/Core/SourceControl/MksTest.cs 2006-09-06 07:49:54 UTC (rev 2532) +++ trunk/project/UnitTests/Core/SourceControl/MksTest.cs 2006-09-07 04:30:05 UTC (rev 2533) @@ -31,7 +31,7 @@ [SetUp] public void SetUp() { - sandboxRoot = TempFileUtil.CreateTempDir("MksSandBox"); + sandboxRoot = TempFileUtil.GetTempPath("MksSandBox"); mockHistoryParserWrapper = new DynamicMock(typeof (IHistoryParser)); mockHistoryParser = (IHistoryParser) mockHistoryParserWrapper.MockInstance; @@ -53,8 +53,6 @@ mockHistoryParserWrapper.Verify(); mksHistoryParserWrapper.Verify(); mockIntegrationResult.Verify(); - - TempFileUtil.DeleteTempDir("MksSandBox"); } private string CreateSourceControlXml() Modified: trunk/project/UnitTests/Core/Util/SystemIoFileSystemTest.cs =================================================================== --- trunk/project/UnitTests/Core/Util/SystemIoFileSystemTest.cs 2006-09-06 07:49:54 UTC (rev 2532) +++ trunk/project/UnitTests/Core/Util/SystemIoFileSystemTest.cs 2006-09-07 04:30:05 UTC (rev 2533) @@ -7,81 +7,81 @@ [TestFixture] public class SystemIoFileSystemTest { - private string tempDir; - private string tempSubDir; - private string tempOtherDir; + private SystemPath tempRoot; + private SystemPath tempSubRoot; + private SystemPath tempOtherRoot; [SetUp] public void Setup() { - tempDir = TempFileUtil.CreateTempDir("repo"); - tempSubDir = TempFileUtil.CreateTempDir("repo\\subrepo"); - tempOtherDir = TempFileUtil.CreateTempDir("other"); + tempRoot = SystemPath.UniqueTempPath().CreateDirectory(); + tempSubRoot = tempRoot.CreateSubDirectory("subrepo"); + tempOtherRoot = SystemPath.UniqueTempPath().CreateDirectory(); } [TearDown] public void TearDown() { - TempFileUtil.DeleteTempDir(tempOtherDir); - TempFileUtil.DeleteTempDir(tempSubDir); - TempFileUtil.DeleteTempDir(tempDir); + tempRoot.DeleteDirectory(); + tempOtherRoot.DeleteDirectory(); } [Test] public void ShouldCopyFileToDirectory() { - TempFileUtil.CreateTempFile(tempDir, "File1"); - new SystemIoFileSystem().Copy(Path.Combine(tempDir, "File1"), tempSubDir); - Assert.IsTrue(File.Exists(Path.Combine(tempSubDir, "File1"))); + SystemPath file1 = tempRoot.CreateEmptyFile("File1"); + new SystemIoFileSystem().Copy(file1.ToString(), tempSubRoot.ToString()); + Assert.IsTrue(tempSubRoot.Combine("File1").Exists()); } [Test] public void ShouldCopyFileToFile() { - TempFileUtil.CreateTempFile(tempDir, "File1"); - new SystemIoFileSystem().Copy(Path.Combine(tempDir, "File1"), Path.Combine(tempDir, "File2")); - Assert.IsTrue(File.Exists(Path.Combine(tempDir, "File2"))); + SystemPath sourceFile = tempRoot.CreateEmptyFile("File1"); + SystemPath targetFile = tempSubRoot.Combine("File2"); + new SystemIoFileSystem().Copy(sourceFile.ToString(), targetFile.ToString()); + Assert.IsTrue(targetFile.Exists()); } [Test] public void ShouldAllowOverwrites() - { - TempFileUtil.CreateTempFile(tempDir, "File1"); - TempFileUtil.CreateTempFile(tempDir, "File2"); - new SystemIoFileSystem().Copy(Path.Combine(tempDir, "File1"), Path.Combine(tempDir, "File2")); - Assert.IsTrue(File.Exists(Path.Combine(tempDir, "File2"))); + { + SystemPath sourceFile = tempRoot.CreateEmptyFile("File1"); + SystemPath targetFile = tempSubRoot.CreateEmptyFile("File2"); + new SystemIoFileSystem().Copy(sourceFile.ToString(), targetFile.ToString()); + Assert.IsTrue(targetFile.Exists()); } [Test] public void ShouldAllowOverwritesEvenWhenDestinationHasReadOnlyAttributeSet() { - string file1 = TempFileUtil.CreateTempFile(tempDir, "File1"); - string file2 = TempFileUtil.CreateTempFile(tempDir, "File2"); - File.SetAttributes(file2, FileAttributes.ReadOnly); - new SystemIoFileSystem().Copy(file1, file2); + SystemPath sourceFile = tempRoot.CreateEmptyFile("File1"); + SystemPath targetFile = tempSubRoot.CreateEmptyFile("File2"); + File.SetAttributes(targetFile.ToString(), FileAttributes.ReadOnly); + new SystemIoFileSystem().Copy(sourceFile.ToString(), targetFile.ToString()); - Assert.IsTrue(File.Exists(Path.Combine(tempDir, "File2"))); + Assert.IsTrue(targetFile.Exists()); } [Test] public void ShouldCopyDirectoryToDirectoryRecursively() { - TempFileUtil.CreateTempFile(tempDir, "File1"); - TempFileUtil.CreateTempFile(tempSubDir, "File2"); - new SystemIoFileSystem().Copy(tempDir, tempOtherDir); + tempRoot.CreateEmptyFile("File1"); + tempSubRoot.CreateEmptyFile("File2"); + new SystemIoFileSystem().Copy(tempRoot.ToString(), tempOtherRoot.ToString()); - Assert.IsTrue(File.Exists(Path.Combine(tempOtherDir, "File1"))); - Assert.IsTrue(File.Exists(Path.Combine(Path.Combine(tempOtherDir, "subrepo"), "File2"))); + Assert.IsTrue(tempOtherRoot.Combine("File1").Exists()); + Assert.IsTrue(tempOtherRoot.Combine("subrepo").Combine("File2").Exists()); } [Test] public void ShouldSaveToFile() { - string tempFile = Path.Combine(tempDir, "foo.txt"); - Assert.IsFalse(File.Exists(tempFile)); - new SystemIoFileSystem().Save(tempFile, "bar"); - Assert.IsTrue(File.Exists(tempFile)); - using (StreamReader reader = File.OpenText(tempFile)) + SystemPath tempFile = tempRoot.Combine("foo.txt"); + Assert.IsFalse(tempFile.Exists()); + new SystemIoFileSystem().Save(tempFile.ToString(), "bar"); + Assert.IsTrue(tempFile.Exists()); + using (StreamReader reader = File.OpenText(tempFile.ToString())) { Assert.AreEqual("bar", reader.ReadToEnd()); } @@ -90,11 +90,11 @@ [Test] public void ShouldSaveUnicodeToFile() { - string tempFile = Path.Combine(tempDir, "foo.txt"); - Assert.IsFalse(File.Exists(tempFile)); - new SystemIoFileSystem().Save(tempFile, "hi there? h\xE5kan! \u307b"); - Assert.IsTrue(File.Exists(tempFile)); - using (StreamReader reader = File.OpenText(tempFile)) + SystemPath tempFile = tempRoot.Combine("foo.txt"); + Assert.IsFalse(tempFile.Exists()); + new SystemIoFileSystem().Save(tempFile.ToString(), "hi there? h\xE5kan! \u307b"); + Assert.IsTrue(tempFile.Exists()); + using (StreamReader reader = File.OpenText(tempFile.ToString())) { Assert.AreEqual("hi there? h\xE5kan! \u307b", reader.ReadToEnd()); } @@ -103,8 +103,8 @@ [Test] public void LoadReadsFileContentCorrectly() { - TempFileUtil.CreateTempFile(tempDir, "foo.txt", "bar"); - Assert.AreEqual("bar", new SystemIoFileSystem().Load(Path.Combine(tempDir, "foo.txt")).ReadToEnd()); + SystemPath tempFile = tempRoot.CreateTextFile("foo.txt", "bar"); + Assert.AreEqual("bar", new SystemIoFileSystem().Load(tempFile.ToString()).ReadToEnd()); } } } \ No newline at end of file Modified: trunk/project/core/core.csproj =================================================================== --- trunk/project/core/core.csproj 2006-09-06 07:49:54 UTC (rev 2532) +++ trunk/project/core/core.csproj 2006-09-07 04:30:05 UTC (rev 2533) @@ -1264,6 +1264,11 @@ BuildAction = "Compile" /> <File + RelPath = "util\SystemPath.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "util\TempFileUtil.cs" SubType = "Code" BuildAction = "Compile" Added: trunk/project/core/util/SystemPath.cs =================================================================== --- trunk/project/core/util/SystemPath.cs (rev 0) +++ trunk/project/core/util/SystemPath.cs 2006-09-07 04:30:05 UTC (rev 2533) @@ -0,0 +1,99 @@ +using System; +using System.IO; + +namespace ThoughtWorks.CruiseControl.Core.Util +{ + public class SystemPath + { + public static readonly SystemPath Temp = new SystemPath(Path.GetTempPath()); + + private readonly string path; + + public SystemPath(string path) + { + if (PathIsInvalid(path)) throw new ArgumentException("Path contains invalid characters: " + path, "path"); + this.path = path; + } + + public SystemPath Combine(string subpath) + { + return new SystemPath(Path.Combine(path, subpath)); + } + + public bool Exists() + { + return File.Exists(path); + } + + public override string ToString() + { + return path; + } + + public SystemPath CreateDirectory() + { + Directory.CreateDirectory(path); + return this; + } + + public void DeleteDirectory() + { + if (! Directory.Exists(path)) return; + try { Directory.Delete(path, true); } + catch (Exception e) { throw new IOException("Unable to delete directory: " + path, e); } + } + + public static SystemPath UniqueTempPath() + { + return Temp.Combine(Guid.NewGuid().ToString()); + } + + public static bool PathIsInvalid(string path) + { + return (-1 != path.IndexOfAny(Path.InvalidPathChars)); + } + + public SystemPath CreateSubDirectory(string dir) + { + return Combine(dir).CreateDirectory(); + } + + public SystemPath CreateEmptyFile(string file) + { + return Combine(file).CreateEmptyFile(); + } + + public SystemPath CreateEmptyFile() + { + return CreateTextFile(string.Empty); + } + + private SystemPath CreateTextFile(string content) + { + using (StreamWriter stream = File.CreateText(path)) + { + stream.Write(content); + } + return this; + } + + public SystemPath CreateTextFile(string filename, string content) + { + return Combine(filename).CreateTextFile(content); + } + + } + + public class TempDirectory : SystemPath, IDisposable + { + public TempDirectory() : base(UniqueTempPath().ToString()) + { + CreateDirectory(); + } + + void IDisposable.Dispose() + { + DeleteDirectory(); + } + } +} \ No newline at end of file Modified: trunk/project/core/util/TempFileUtil.cs =================================================================== --- trunk/project/core/util/TempFileUtil.cs 2006-09-06 07:49:54 UTC (rev 2532) +++ trunk/project/core/util/TempFileUtil.cs 2006-09-07 04:30:05 UTC (rev 2533) @@ -1,3 +1,4 @@ +using System; using System.IO; using System.Text; using System.Xml; @@ -6,7 +7,7 @@ { /// <summary> /// Utility class for managing temp files and folders. - /// Uses your systems temp folder. + /// Uses your system's temp folder. /// </summary> public class TempFileUtil { @@ -41,7 +42,7 @@ public static string GetTempFilePath(string dirname, string filename) { - return Path.Combine(GetTempPath(dirname),filename); + return Path.Combine(GetTempPath(dirname), filename); } public static bool DeleteTempDir(string dirname) @@ -49,13 +50,14 @@ string tempDir = GetTempPath(dirname); if (Directory.Exists(tempDir)) { - Directory.Delete(tempDir, true); + try { Directory.Delete(tempDir, true); } + catch (Exception e) { throw new IOException("Unable to delete directory: " + tempDir, e); } return true; } else return false; } - + public static bool DeleteTempDir(object obj) { return DeleteTempDir(obj.GetType().FullName); @@ -63,12 +65,12 @@ public static bool TempFileExists(string dirname, string filename) { - return File.Exists(TempFileUtil.GetTempFilePath(dirname, filename)); + return File.Exists(GetTempFilePath(dirname, filename)); } public static string CreateTempXmlFile(string dirname, string filename, string contents) { - string path = Path.Combine(GetTempPath(dirname),filename); + string path = Path.Combine(GetTempPath(dirname), filename); CreateTempXmlFile(path, contents); return path; } @@ -81,19 +83,14 @@ } public static string CreateTempFile(string tempDir, string filename) - { - string path = CreateTempDir(tempDir, false); - path = Path.Combine(path, filename); - using (File.CreateText(path)) - { - return path; - } + { + return CreateTempFile(tempDir, filename, string.Empty); } public static string CreateTempFile(string tempDir, string filename, string content) - { - string path = CreateTempDir(tempDir, false); - path = Path.Combine(path, filename); + { + string path = CreateTempDir(tempDir, false); + path = Path.Combine(path, filename); using (StreamWriter stream = File.CreateText(path)) { stream.Write(content); @@ -105,13 +102,13 @@ { for (int i = 0; i < filenames.Length; i++) { - CreateTempFile(tempDir,filenames[i]); + CreateTempFile(tempDir, filenames[i]); } } public static void UpdateTempFile(string filename, string text) { - using (StreamWriter writer = File.AppendText(filename)) + using (StreamWriter writer = File.AppendText(filename)) { writer.Write(text); } @@ -125,4 +122,4 @@ } } } -} +} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <exo...@us...> - 2006-09-07 05:53:19
|
Revision: 2539 http://svn.sourceforge.net/ccnet/?rev=2539&view=rev Author: exortech Date: 2006-09-06 22:53:08 -0700 (Wed, 06 Sep 2006) Log Message: ----------- CCNET-724: fixed bug where ccnet fails if the initial label is not incremented because the build fails when trying to detect modifications. this issue is described here: http://thread.gmane.org/gmane.comp.windows.dotnet.ccnet.user/5923/focus=5945 Modified Paths: -------------- trunk/project/UnitTests/Core/IntegrationResultMother.cs trunk/project/UnitTests/Core/ProjectTest.cs trunk/project/UnitTests/UnitTests.csproj trunk/project/core/IntegrationResult.cs trunk/project/core/IntegrationResultManager.cs trunk/project/core/Project.cs trunk/project/core/publishers/Statistics/StatisticsPublisher.cs Added Paths: ----------- trunk/project/UnitTests/Core/ProjectExceptionHandlingTest.cs Modified: trunk/project/UnitTests/Core/IntegrationResultMother.cs =================================================================== --- trunk/project/UnitTests/Core/IntegrationResultMother.cs 2006-09-07 05:46:44 UTC (rev 2538) +++ trunk/project/UnitTests/Core/IntegrationResultMother.cs 2006-09-07 05:53:08 UTC (rev 2539) @@ -31,6 +31,7 @@ result.Status = status; result.StartTime = date; result.EndTime = date; + result.Label = "2.0"; return result; } Added: trunk/project/UnitTests/Core/ProjectExceptionHandlingTest.cs =================================================================== --- trunk/project/UnitTests/Core/ProjectExceptionHandlingTest.cs (rev 0) +++ trunk/project/UnitTests/Core/ProjectExceptionHandlingTest.cs 2006-09-07 05:53:08 UTC (rev 2539) @@ -0,0 +1,49 @@ +using System; +using NMock; +using NMock.Constraints; +using NUnit.Framework; +using ThoughtWorks.CruiseControl.Core; +using ThoughtWorks.CruiseControl.Core.State; +using ThoughtWorks.CruiseControl.Remote; + +namespace ThoughtWorks.CruiseControl.UnitTests.Core +{ + [TestFixture] + public class ProjectExceptionHandlingTest + { + [Test] + public void ShouldHandleIncrementingLabelAfterInitialBuildFailsWithException() + { + IMock mockSourceControl = new DynamicMock(typeof (ISourceControl)); + mockSourceControl.ExpectAndThrow("GetModifications", new Exception("doh!"), new IsAnything(), new IsAnything()); + mockSourceControl.ExpectAndReturn("GetModifications", new Modification[] {new Modification()}, new IsAnything(), new IsAnything()); + + Project project = new Project(); + project.Name = "test"; + project.SourceControl = (ISourceControl) mockSourceControl.MockInstance; + project.StateManager = new StateManagerStub(); + project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test")); + Assert.AreEqual(IntegrationStatus.Exception, project.LatestBuildStatus); + Assert.AreEqual(IntegrationResult.InitialLabel, project.LastIntegrationResult.Label); + + project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test")); + Assert.AreEqual(IntegrationStatus.Success, project.LatestBuildStatus); + Assert.AreEqual("1", project.LastIntegrationResult.Label); + } + } + + internal class StateManagerStub : IStateManager + { + private IIntegrationResult savedResult = IntegrationResult.CreateInitialIntegrationResult("test", @"c:\temp"); + + public IIntegrationResult LoadState(string project) + { + return savedResult; + } + + public void SaveState(IIntegrationResult result) + { + savedResult = result; + } + } +} \ No newline at end of file Modified: trunk/project/UnitTests/Core/ProjectTest.cs =================================================================== --- trunk/project/UnitTests/Core/ProjectTest.cs 2006-09-07 05:46:44 UTC (rev 2538) +++ trunk/project/UnitTests/Core/ProjectTest.cs 2006-09-07 05:53:08 UTC (rev 2539) @@ -23,7 +23,6 @@ public class ProjectTest : IntegrationFixture { private Project project; - private IMock mockBuilder; private IMock mockSourceControl; private IMock mockStateManager; private IMock mockTrigger; @@ -44,7 +43,6 @@ Assert.IsTrue(Directory.Exists(artifactDirPath)); mockery = new Mockery(); - mockBuilder = mockery.NewStrictMock(typeof (ITask)); mockSourceControl = mockery.NewStrictMock(typeof (ISourceControl)); mockStateManager = mockery.NewStrictMock(typeof (IStateManager)); mockTrigger = mockery.NewStrictMock(typeof (ITrigger)); @@ -59,7 +57,6 @@ private void SetupProject() { project.Name = ProjectName; - project.Builder = (ITask) mockBuilder.MockInstance; project.SourceControl = (ISourceControl) mockSourceControl.MockInstance; project.StateManager = (IStateManager) mockStateManager.MockInstance; project.Triggers = (ITrigger) mockTrigger.MockInstance; @@ -347,15 +344,15 @@ [Test] public void RunningFirstIntegrationShouldForceBuild() { - mockStateManager.ExpectAndReturn("LoadState", IntegrationResult.CreateInitialIntegrationResult(ProjectName, @"c:\temp"), ProjectName); // running the first integration (no state file) + IntegrationResult initialResult = IntegrationResult.CreateInitialIntegrationResult(ProjectName, @"c:\temp"); + mockStateManager.ExpectAndReturn("LoadState", initialResult, ProjectName); // running the first integration (no state file) mockStateManager.Expect("SaveState", new IsAnything()); - mockLabeller.ExpectAndReturn("Generate", "label", new IsAnything()); // generate new label - mockSourceControl.ExpectAndReturn("GetModifications", new Modification[0], new IsAnything(), new IsAnything()); // return no modifications found + mockLabeller.ExpectAndReturn("Generate", "label", initialResult); // generate new label + mockSourceControl.ExpectAndReturn("GetModifications", new Modification[0], initialResult, new IsAnything()); // return no modifications found mockSourceControl.Expect("GetSource", new IsAnything()); mockSourceControl.Expect("LabelSourceControl", new IsAnything()); mockPublisher.Expect("Run", new IsAnything()); mockTask.Expect("Run", new IsAnything()); - project.Builder = new MockBuilder(); // need to use mock builder in order to set properties on IntegrationResult project.ConfiguredWorkingDirectory = @"c:\temp"; IIntegrationResult result = project.Integrate(ModificationExistRequest()); @@ -371,7 +368,6 @@ Assert.AreEqual("label", result.Label); AssertFalse("unexpected modifications were returned", result.HasModifications()); AssertEqualArrays(new Modification[0], result.Modifications); - Assert.AreEqual(MockBuilder.BUILDER_OUTPUT, result.TaskOutput, "no output is expected as builder is not called"); Assert.IsTrue(result.EndTime >= result.StartTime); VerifyAll(); } @@ -382,7 +378,6 @@ { mockStateManager.ExpectAndReturn("LoadState", IntegrationResultMother.CreateSuccessful(), ProjectName); mockSourceControl.ExpectAndReturn("GetModifications", new Modification[0], new IsAnything(), new IsAnything()); // return no modifications found - mockBuilder.ExpectNoCall("Run", typeof (IntegrationResult)); mockPublisher.ExpectNoCall("Run", typeof (IntegrationResult)); IIntegrationResult result = project.Integrate(ModificationExistRequest()); Modified: trunk/project/UnitTests/UnitTests.csproj =================================================================== --- trunk/project/UnitTests/UnitTests.csproj 2006-09-07 05:46:44 UTC (rev 2538) +++ trunk/project/UnitTests/UnitTests.csproj 2006-09-07 05:53:08 UTC (rev 2539) @@ -462,6 +462,11 @@ BuildAction = "Compile" /> <File + RelPath = "Core\ProjectExceptionHandlingTest.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File RelPath = "Core\ProjectIntegratorListFactoryTest.cs" SubType = "Code" BuildAction = "Compile" Modified: trunk/project/core/IntegrationResult.cs =================================================================== --- trunk/project/core/IntegrationResult.cs 2006-09-07 05:46:44 UTC (rev 2538) +++ trunk/project/core/IntegrationResult.cs 2006-09-07 05:53:08 UTC (rev 2539) @@ -24,7 +24,6 @@ private Exception exception; private ArrayList taskResults = new ArrayList(); private IDictionary properties = new SortedList(); - private bool initial = false; private IntegrationRequest request; // Default constructor required for serialization @@ -238,7 +237,7 @@ public bool IsInitial() { - return initial; + return Label == InitialLabel; } /// <summary> @@ -341,9 +340,9 @@ public static IntegrationResult CreateInitialIntegrationResult(string project, string workingDirectory) { IntegrationResult result = new IntegrationResult(project, workingDirectory); - result.initial = true; result.StartTime = DateTime.Now.AddDays(-1); result.EndTime = DateTime.Now; + result.BuildCondition = Remote.BuildCondition.ForceBuild; return result; } @@ -431,14 +430,13 @@ public class IntegrationState { private readonly IntegrationStatus status; - private readonly DateTime date; + private readonly DateTime date = DateTime.Now; private readonly string label; private readonly string baseArtifactDirectory; public IntegrationState(IntegrationStatus status, string label, string baseArtifactDirectory) { this.status = status; - this.date = date; this.label = label; this.baseArtifactDirectory = baseArtifactDirectory; } Modified: trunk/project/core/IntegrationResultManager.cs =================================================================== --- trunk/project/core/IntegrationResultManager.cs 2006-09-07 05:46:44 UTC (rev 2538) +++ trunk/project/core/IntegrationResultManager.cs 2006-09-07 05:53:08 UTC (rev 2539) @@ -21,7 +21,7 @@ { if (lastResult == null) { - lastResult = LoadLastIntegration(); + lastResult = project.StateManager.LoadState(project.Name); } return lastResult; } @@ -30,7 +30,7 @@ public IIntegrationResult StartNewIntegration(IntegrationRequest request) { currentResult = new IntegrationResult(project.Name, project.WorkingDirectory, project.StatisticsFile, request); - + currentResult.LastIntegrationStatus = LastIntegrationResult.Status; currentResult.LastSuccessfulIntegrationLabel = LastIntegrationResult.LastSuccessfulIntegrationLabel; @@ -40,13 +40,6 @@ return currentResult; } - private IIntegrationResult LoadLastIntegration() - { - IIntegrationResult result = project.StateManager.LoadState(project.Name); - result.WorkingDirectory = project.WorkingDirectory; - return result; - } - private BuildCondition DetermineBuildCondition(BuildCondition buildCondition) { if (LastIntegrationResult.IsInitial()) @@ -70,5 +63,4 @@ lastResult = currentResult; } } - -} +} \ No newline at end of file Modified: trunk/project/core/Project.cs =================================================================== --- trunk/project/core/Project.cs 2006-09-07 05:46:44 UTC (rev 2538) +++ trunk/project/core/Project.cs 2006-09-07 05:53:08 UTC (rev 2539) @@ -48,7 +48,9 @@ private IIntegratable integratable; private QuietPeriod quietPeriod = new QuietPeriod(new DateTimeProvider()); private ArrayList messages = new ArrayList(); - [ReflectorProperty("prebuild", Required=false)] public ITask[] PrebuildTasks = new ITask[0]; + + [ReflectorProperty("prebuild", Required=false)] + public ITask[] PrebuildTasks = new ITask[0]; public Project() { Modified: trunk/project/core/publishers/Statistics/StatisticsPublisher.cs =================================================================== --- trunk/project/core/publishers/Statistics/StatisticsPublisher.cs 2006-09-07 05:46:44 UTC (rev 2538) +++ trunk/project/core/publishers/Statistics/StatisticsPublisher.cs 2006-09-07 05:53:08 UTC (rev 2539) @@ -94,15 +94,15 @@ return Path.Combine(integrationResult.ArtifactDirectory, integrationResult.StatisticsFile); } - private string CsvStatisticsFile(IntegrationState integrationState) - { - return Path.Combine(integrationState.ArtifactDirectory, csvFileName); - } - private void UpdateCsvFile(StatisticsBuilder builder, IntegrationState previousState) { string csvFile = CsvStatisticsFile(previousState); builder.AppendCsv(csvFile); } + + private string CsvStatisticsFile(IntegrationState integrationState) + { + return Path.Combine(integrationState.ArtifactDirectory, csvFileName); + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <exo...@us...> - 2006-09-07 06:40:25
|
Revision: 2541 http://svn.sourceforge.net/ccnet/?rev=2541&view=rev Author: exortech Date: 2006-09-06 23:40:20 -0700 (Wed, 06 Sep 2006) Log Message: ----------- CCNET-426: removing Builder node from Project class -- it was deprecated, but it has now been removed. Modified Paths: -------------- trunk/project/UnitTests/Core/Config/ConfigurationFileSaverTest.cs trunk/project/UnitTests/Core/ProjectTest.cs trunk/project/core/Project.cs Modified: trunk/project/UnitTests/Core/Config/ConfigurationFileSaverTest.cs =================================================================== --- trunk/project/UnitTests/Core/Config/ConfigurationFileSaverTest.cs 2006-09-07 06:01:53 UTC (rev 2540) +++ trunk/project/UnitTests/Core/Config/ConfigurationFileSaverTest.cs 2006-09-07 06:40:20 UTC (rev 2541) @@ -28,11 +28,9 @@ // Setup Project project1 = new Project(); project1.Name = "Project One"; - project1.Builder = builder; project1.SourceControl = sourceControl; Project project2 = new Project(); project2.Name = "Project Two"; - project2.Builder = builder; project2.SourceControl = sourceControl; ProjectList projectList = new ProjectList(); projectList.Add(project1); @@ -55,6 +53,5 @@ Assert.IsNotNull (configuration2.Projects["Project Two"]); mockConfiguration.Verify(); } - } } Modified: trunk/project/UnitTests/Core/ProjectTest.cs =================================================================== --- trunk/project/UnitTests/Core/ProjectTest.cs 2006-09-07 06:01:53 UTC (rev 2540) +++ trunk/project/UnitTests/Core/ProjectTest.cs 2006-09-07 06:40:20 UTC (rev 2541) @@ -88,7 +88,6 @@ string xml = @" <project name=""foo"" webURL=""http://localhost/ccnet"" modificationDelaySeconds=""60"" publishExceptions=""true"" category=""category1""> <workingDirectory>c:\my\working\directory</workingDirectory> - <build type=""nant"" /> <sourcecontrol type=""filesystem""> <repositoryRoot>C:\</repositoryRoot> </sourcecontrol> @@ -119,7 +118,6 @@ Assert.AreEqual("category1", project.Category); Assert.AreEqual(60, project.ModificationDelaySeconds); Assert.AreEqual(true, project.PublishExceptions); - Assert.IsTrue(project.Builder is NAntTask); Assert.IsTrue(project.SourceControl is FileSourceControl); Assert.IsTrue(project.Labeller is DefaultLabeller); Assert.IsTrue(project.StateManager is FileStateManager); @@ -145,14 +143,14 @@ Assert.AreEqual(Project.DefaultUrl(), project.WebURL); Assert.AreEqual(0, project.ModificationDelaySeconds); //TODO: is this the correct default? should quiet period be turned off by default? is this sourcecontrol specific? Assert.AreEqual(true, project.PublishExceptions); - Assert.IsTrue(project.Builder is NullTask); Assert.IsTrue(project.SourceControl is NullSourceControl); Assert.IsTrue(project.Labeller is DefaultLabeller); Assert.AreEqual(typeof(MultipleTrigger), project.Triggers.GetType()); Assert.AreEqual(typeof(IntervalTrigger), ((MultipleTrigger)project.Triggers).Triggers[0].GetType()); Assert.AreEqual(1, project.Publishers.Length); Assert.IsTrue(project.Publishers[0] is XmlLogPublisher); - Assert.AreEqual(0, project.Tasks.Length); + Assert.AreEqual(1, project.Tasks.Length); + Assert.AreEqual(typeof(NullTask), project.Tasks[0].GetType()); Assert.AreEqual(0, project.ExternalLinks.Length); VerifyAll(); } @@ -352,7 +350,7 @@ mockSourceControl.Expect("GetSource", new IsAnything()); mockSourceControl.Expect("LabelSourceControl", new IsAnything()); mockPublisher.Expect("Run", new IsAnything()); - mockTask.Expect("Run", new IsAnything()); + mockTask.Expect("Run", new AddTaskResultConstraint()); project.ConfiguredWorkingDirectory = @"c:\temp"; IIntegrationResult result = project.Integrate(ModificationExistRequest()); @@ -407,9 +405,8 @@ mockSourceControl.Expect("LabelSourceControl", new IsAnything()); mockSourceControl.Expect("GetSource", new IsAnything()); mockPublisher.Expect("Run", new IsAnything()); - mockTask.Expect("Run", new IsAnything()); + mockTask.Expect("Run", new AddTaskResultConstraint()); - project.Builder = new MockBuilder(); // need to use mock builder in order to set properties on IntegrationResult IIntegrationResult result = project.Integrate(ModificationExistRequest()); Assert.AreEqual(ProjectName, result.ProjectName); @@ -465,9 +462,7 @@ [Test] public void SourceControlLabelled() { - project.Builder = new MockBuilder(); mockLabeller.ExpectAndReturn("Generate", "1.2.1", new IsAnything()); - mockTask.Expect("Run", new IsAnything()); mockSourceControl.ExpectAndReturn("GetModifications", CreateModifications(), new IsAnything(), new IsAnything()); mockSourceControl.Expect("GetSource", new IsAnything()); mockSourceControl.Expect("LabelSourceControl", new IsAnything()); @@ -475,6 +470,7 @@ IMock stateMock = new DynamicMock(typeof (IStateManager)); stateMock.ExpectAndReturn("LoadState", IntegrationResult.CreateInitialIntegrationResult(ProjectName, @"c:\temp"), ProjectName); // running the first integration (no state file) project.StateManager = (IStateManager) stateMock.MockInstance; + mockTask.Expect("Run", new AddTaskResultConstraint()); IIntegrationResult results = project.Integrate(ModificationExistRequest()); @@ -488,29 +484,6 @@ // Run Tasks [Test] - public void ShouldRunBuilderFirst() - { - IntegrationResult result = new IntegrationResult(); - mockTask.Expect("Run", result); - MockBuilder builder = new MockBuilder(); - project.Builder = builder; - project.Run(result); - Assert.IsTrue(builder.HasRun); - AssertStartsWith(MockBuilder.BUILDER_OUTPUT, result.TaskOutput); - VerifyAll(); - } - - [Test] - public void ShouldNotRunBuilderIfItDoesNotExist() - { - IntegrationResult result = new IntegrationResult(); - mockTask.Expect("Run", result); - project.Builder = null; - project.Run(result); - VerifyAll(); - } - - [Test] public void ShouldStopBuildIfTaskFails() { IntegrationResult result = IntegrationResultMother.CreateFailed(); @@ -520,7 +493,6 @@ secondTask.ExpectNoCall("Run", typeof (IntegrationResult)); project.Tasks = new ITask[] {(ITask) mockTask.MockInstance, (ITask) secondTask.MockInstance}; - project.Builder = null; project.Run(result); VerifyAll(); secondTask.Verify(); @@ -546,10 +518,9 @@ mockSourceControl.ExpectAndReturn("GetModifications", CreateModifications(), new IsAnything(), new IsAnything()); mockSourceControl.Expect("GetSource", new IsAnything()); mockSourceControl.Expect("LabelSourceControl", new IsAnything()); - mockTask.Expect("Run", new IsAnything()); Exception expectedException = new CruiseControlException("expected exception"); mockPublisher.ExpectAndThrow("Run", expectedException, new IsAnything()); - project.Builder = new MockBuilder(); + mockTask.Expect("Run", new AddTaskResultConstraint()); IIntegrationResult results = project.Integrate(ModificationExistRequest()); @@ -570,7 +541,6 @@ mockSourceControl.Expect("GetSource", new IsAnything()); mockPublisher.Expect("Run", new IsAnything()); - project.Builder = null; project.PublishExceptions = true; project.Integrate(ForceBuildRequest()); @@ -601,5 +571,21 @@ project.Prebuild(result); Assert.AreEqual("1.0", result.Label); } + + private class AddTaskResultConstraint : BaseConstraint + { + public override bool Eval(object val) + { + IntegrationResult result = val as IntegrationResult; + if (result == null) return false; + result.AddTaskResult("success"); + return true; + } + + public override string Message + { + get { return "failed AddTaskResultConstraint"; } + } + } } } \ No newline at end of file Modified: trunk/project/core/Project.cs =================================================================== --- trunk/project/core/Project.cs 2006-09-07 06:01:53 UTC (rev 2540) +++ trunk/project/core/Project.cs 2006-09-07 06:40:20 UTC (rev 2541) @@ -37,9 +37,8 @@ private string webUrl = DefaultUrl(); private string statisticsFile = "report.xml"; private ISourceControl sourceControl = new NullSourceControl(); - private ITask builder = new NullTask(); private ILabeller labeller = new DefaultLabeller(); - private ITask[] tasks = new ITask[0]; + private ITask[] tasks = new ITask[] {new NullTask()}; private ITask[] publishers = new ITask[] {new XmlLogPublisher()}; private ProjectActivity currentActivity = ProjectActivity.Sleeping; private IStateManager state = new FileStateManager(new SystemIoFileSystem()); @@ -48,8 +47,8 @@ private IIntegratable integratable; private QuietPeriod quietPeriod = new QuietPeriod(new DateTimeProvider()); private ArrayList messages = new ArrayList(); - - [ReflectorProperty("prebuild", Required=false)] + + [ReflectorProperty("prebuild", Required=false)] public ITask[] PrebuildTasks = new ITask[0]; public Project() @@ -77,13 +76,6 @@ set { webUrl = value; } } - [ReflectorProperty("build", InstanceTypeKey="type", Required=false)] - public ITask Builder - { - get { return builder; } - set { builder = value; } - } - [ReflectorProperty("statisticsFile", Required=false)] public string StatisticsFile { @@ -166,7 +158,7 @@ public IIntegrationResult Integrate(IntegrationRequest request) { - return integratable.Integrate(request); + return integratable.Integrate(request); } public void Prebuild(IIntegrationResult result) @@ -177,10 +169,7 @@ public void Run(IIntegrationResult result) { - IList tasksToRun = new ArrayList(tasks); - if (Builder != null) tasksToRun.Insert(0, builder); - - RunTasks(result, tasksToRun); + RunTasks(result, tasks); } private static void RunTasks(IIntegrationResult result, IList tasksToRun) @@ -236,7 +225,7 @@ { XmlDocument xmlDocument = new XmlDocument(); string documentLocation = Path.Combine(ArtifactDirectory, statisticsFile); - if(File.Exists(documentLocation)) + if (File.Exists(documentLocation)) { xmlDocument.Load(documentLocation); } @@ -251,10 +240,12 @@ public ProjectStatus CreateProjectStatus(IProjectIntegrator integrator) { - ProjectStatus status = new ProjectStatus(Name, Category, CurrentActivity, LatestBuildStatus, integrator.State, WebURL, - LastIntegrationResult.StartTime, LastIntegrationResult.Label, LastIntegrationResult.LastSuccessfulIntegrationLabel, - Triggers.NextBuild); - status.Messages = (Message[])messages.ToArray(typeof(Message)); + ProjectStatus status = + new ProjectStatus(Name, Category, CurrentActivity, LatestBuildStatus, integrator.State, WebURL, + LastIntegrationResult.StartTime, LastIntegrationResult.Label, + LastIntegrationResult.LastSuccessfulIntegrationLabel, + Triggers.NextBuild); + status.Messages = (Message[]) messages.ToArray(typeof (Message)); return status; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <exo...@us...> - 2006-10-04 00:48:21
|
Revision: 2565 http://svn.sourceforge.net/ccnet/?rev=2565&view=rev Author: exortech Date: 2006-10-01 22:01:57 -0700 (Sun, 01 Oct 2006) Log Message: ----------- support for rebasing svn working directory when tagging source Modified Paths: -------------- trunk/project/UnitTests/Core/SourceControl/SvnTest.cs trunk/project/core/sourcecontrol/Svn.cs Modified: trunk/project/UnitTests/Core/SourceControl/SvnTest.cs =================================================================== --- trunk/project/UnitTests/Core/SourceControl/SvnTest.cs 2006-10-02 04:22:57 UTC (rev 2564) +++ trunk/project/UnitTests/Core/SourceControl/SvnTest.cs 2006-10-02 05:01:57 UTC (rev 2565) @@ -124,6 +124,17 @@ } [Test] + public void ShouldApplyLabelUsingRebasedWorkingDirectory() + { + ExpectToExecuteArguments(@"copy -m ""CCNET build foo"" c:\source svn://someserver/tags/foo/foo --non-interactive"); + svn.TagOnSuccess = true; + svn.WorkingDirectory = null; + IIntegrationResult result = IntegrationResult(from); + result.Label = "foo"; + svn.LabelSourceControl(result); + } + + [Test] public void CreatingLabelProcessPerformsServerToServerCopyWithRevisionWhenKnown() { IntegrationResult result = IntegrationResultMother.CreateSuccessful("foo"); Modified: trunk/project/core/sourcecontrol/Svn.cs =================================================================== --- trunk/project/core/sourcecontrol/Svn.cs 2006-10-02 04:22:57 UTC (rev 2564) +++ trunk/project/core/sourcecontrol/Svn.cs 2006-10-02 05:01:57 UTC (rev 2565) @@ -120,7 +120,7 @@ { if (result.LastChangeNumber == 0) { - return WorkingDirectory.TrimEnd(Path.DirectorySeparatorChar); + return result.BaseFromWorkingDirectory(WorkingDirectory).TrimEnd(Path.DirectorySeparatorChar); } return TrunkUrl; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <exo...@us...> - 2006-10-04 00:49:02
|
Revision: 2567 http://svn.sourceforge.net/ccnet/?rev=2567&view=rev Author: exortech Date: 2006-10-01 22:45:21 -0700 (Sun, 01 Oct 2006) Log Message: ----------- CCNET-747: all exceptions during build break the build deprecating PublishExceptions attribute Modified Paths: -------------- trunk/project/UnitTests/Core/IntegrationRunnerTest.cs trunk/project/UnitTests/Core/ProjectExceptionHandlingTest.cs trunk/project/UnitTests/Core/ProjectTest.cs trunk/project/UnitTests/Core/Tasks/MergeFileTaskTest.cs trunk/project/core/IIntegrationRunnerTarget.cs trunk/project/core/IntegrationRunner.cs trunk/project/core/Project.cs trunk/project/core/ProjectIntegrator.cs trunk/project/examples/VSSAndDevenvAndNUnitCCNet.config Modified: trunk/project/UnitTests/Core/IntegrationRunnerTest.cs =================================================================== --- trunk/project/UnitTests/Core/IntegrationRunnerTest.cs 2006-10-02 05:05:23 UTC (rev 2566) +++ trunk/project/UnitTests/Core/IntegrationRunnerTest.cs 2006-10-02 05:45:21 UTC (rev 2567) @@ -69,10 +69,7 @@ { SetupPreambleExpections(); resultMock.ExpectAndReturn("ShouldRunBuild", false); - resultMock.Expect("MarkEndTime"); targetMock.Expect("Activity", ProjectActivity.Sleeping); - resultMock.ExpectAndReturn("Status", IntegrationStatus.Unknown); - resultMock.ExpectAndReturn("EndTime", endTime); IIntegrationResult returnedResult = runner.Integrate(request); @@ -94,23 +91,6 @@ Assert.AreEqual(result, returnedResult); mockery.Verify(); } - - [Test] - public void ShouldStillPublishResultsIfLabellingThrowsException() - { - SetupPreambleExpections(); - SetupShouldBuildExpectations(); - resultMock.ExpectAndReturn("Status", IntegrationStatus.Success); - resultMock.ExpectAndReturn("Status", IntegrationStatus.Success); - sourceControlMock.ExpectAndThrow("LabelSourceControl", new Exception(), result); - targetMock.Expect("PublishResults", result); - resultManagerMock.Expect("FinishIntegration"); - - IIntegrationResult returnedResult = runner.Integrate(request); - - Assert.AreEqual(result, returnedResult); - mockery.Verify(); - } [Test] public void ShouldStillPublishResultsIfPrebuildThrowsException() @@ -126,7 +106,8 @@ targetMock.Expect("Activity", ProjectActivity.Sleeping); resultMock.ExpectAndReturn("EndTime", endTime); resultMock.ExpectAndReturn("Status", IntegrationStatus.Exception); - targetMock.ExpectAndReturn("PublishExceptions", false); + targetMock.Expect("PublishResults", result); + resultManagerMock.Expect("FinishIntegration"); runner.Integrate(ModificationExistRequest()); mockery.Verify(); @@ -160,7 +141,6 @@ private void SetupBuildPassExpectations() { resultMock.ExpectAndReturn("Status", IntegrationStatus.Success); - resultMock.ExpectAndReturn("Status", IntegrationStatus.Success); sourceControlMock.Expect("LabelSourceControl", result); targetMock.Expect("PublishResults", result); resultManagerMock.Expect("FinishIntegration"); Modified: trunk/project/UnitTests/Core/ProjectExceptionHandlingTest.cs =================================================================== --- trunk/project/UnitTests/Core/ProjectExceptionHandlingTest.cs 2006-10-02 05:05:23 UTC (rev 2566) +++ trunk/project/UnitTests/Core/ProjectExceptionHandlingTest.cs 2006-10-02 05:45:21 UTC (rev 2567) @@ -22,14 +22,35 @@ project.Name = "test"; project.SourceControl = (ISourceControl) mockSourceControl.MockInstance; project.StateManager = new StateManagerStub(); - project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test")); - Assert.AreEqual(IntegrationStatus.Exception, project.LatestBuildStatus); - Assert.AreEqual(IntegrationResult.InitialLabel, project.LastIntegrationResult.Label); + try { project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test"));} + catch (Exception) { } project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test")); Assert.AreEqual(IntegrationStatus.Success, project.LatestBuildStatus); Assert.AreEqual("1", project.LastIntegrationResult.Label); } + + [Test] + public void ShouldNotResetLabelIfGetModificationsThrowsException() + { + IMock mockSourceControl = new DynamicMock(typeof (ISourceControl)); + mockSourceControl.ExpectAndThrow("GetModifications", new Exception("doh!"), new IsAnything(), new IsAnything()); + mockSourceControl.ExpectAndReturn("GetModifications", new Modification[] {new Modification()}, new IsAnything(), new IsAnything()); + + StateManagerStub stateManagerStub = new StateManagerStub(); + stateManagerStub.SaveState(IntegrationResultMother.CreateSuccessful("10")); + + Project project = new Project(); + project.Name = "test"; + project.SourceControl = (ISourceControl) mockSourceControl.MockInstance; + project.StateManager = stateManagerStub; + try { project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test"));} + catch (Exception) { } + + project.Integrate(new IntegrationRequest(BuildCondition.ForceBuild, "test")); + Assert.AreEqual(IntegrationStatus.Success, project.LatestBuildStatus); + Assert.AreEqual("11", project.LastIntegrationResult.Label); + } } internal class StateManagerStub : IStateManager Modified: trunk/project/UnitTests/Core/ProjectTest.cs =================================================================== --- trunk/project/UnitTests/Core/ProjectTest.cs 2006-10-02 05:05:23 UTC (rev 2566) +++ trunk/project/UnitTests/Core/ProjectTest.cs 2006-10-02 05:45:21 UTC (rev 2567) @@ -86,7 +86,7 @@ public void LoadFullySpecifiedProjectFromConfiguration() { string xml = @" -<project name=""foo"" webURL=""http://localhost/ccnet"" modificationDelaySeconds=""60"" publishExceptions=""true"" category=""category1""> +<project name=""foo"" webURL=""http://localhost/ccnet"" modificationDelaySeconds=""60"" category=""category1""> <workingDirectory>c:\my\working\directory</workingDirectory> <sourcecontrol type=""filesystem""> <repositoryRoot>C:\</repositoryRoot> @@ -117,7 +117,6 @@ Assert.AreEqual("http://localhost/ccnet", project.WebURL); Assert.AreEqual("category1", project.Category); Assert.AreEqual(60, project.ModificationDelaySeconds); - Assert.AreEqual(true, project.PublishExceptions); Assert.IsTrue(project.SourceControl is FileSourceControl); Assert.IsTrue(project.Labeller is DefaultLabeller); Assert.IsTrue(project.StateManager is FileStateManager); @@ -142,7 +141,6 @@ Assert.AreEqual("foo", project.Name); Assert.AreEqual(Project.DefaultUrl(), project.WebURL); Assert.AreEqual(0, project.ModificationDelaySeconds); //TODO: is this the correct default? should quiet period be turned off by default? is this sourcecontrol specific? - Assert.AreEqual(true, project.PublishExceptions); Assert.IsTrue(project.SourceControl is NullSourceControl); Assert.IsTrue(project.Labeller is DefaultLabeller); Assert.AreEqual(typeof(MultipleTrigger), project.Triggers.GetType()); @@ -389,7 +387,7 @@ AssertFalse("unexpected modifications were returned", result.HasModifications()); AssertEqualArrays(new Modification[0], result.Modifications); Assert.AreEqual(string.Empty, result.TaskOutput, "no output is expected as builder is not called"); - Assert.IsTrue(result.EndTime >= result.StartTime); +// Assert.IsTrue(result.EndTime >= result.StartTime); VerifyAll(); } @@ -420,36 +418,6 @@ VerifyAll(); } - [Test] - public void ShouldNotPublishIntegrationResultsIfPublishExceptionsIsFalseAndSourceControlThrowsAnException() - { - mockStateManager.ExpectAndReturn("LoadState", IntegrationResult.CreateInitialIntegrationResult(ProjectName, @"c:\temp"), ProjectName); // running the first integration (no state file) - CruiseControlException expectedException = new CruiseControlException(); - mockSourceControl.ExpectAndThrow("GetModifications", expectedException, new IsAnything(), new IsAnything()); - mockPublisher.ExpectNoCall("Run", typeof (IntegrationResult)); - mockStateManager.ExpectNoCall("SaveState", typeof (IntegrationResult)); - - project.PublishExceptions = false; - IIntegrationResult result = project.Integrate(ModificationExistRequest()); - Assert.AreEqual(expectedException, result.ExceptionResult); - VerifyAll(); - } - - [Test] - public void ShouldPublishIntegrationResultsIfPublishExceptionsIsTrueAndSourceControlThrowsAnException() - { - mockStateManager.ExpectAndReturn("LoadState", IntegrationResult.CreateInitialIntegrationResult(ProjectName, @"c:\temp"), ProjectName); // running the first integration (no state file) - CruiseControlException expectedException = new CruiseControlException(); - mockSourceControl.ExpectAndThrow("GetModifications", expectedException, new IsAnything(), new IsAnything()); - mockPublisher.Expect("Run", new IsAnything()); - mockStateManager.Expect("SaveState", new IsAnything()); - - project.PublishExceptions = true; - IIntegrationResult result = project.Integrate(ModificationExistRequest()); - Assert.AreEqual(expectedException, result.ExceptionResult); - VerifyAll(); - } - [Test, ExpectedException(typeof (CruiseControlException))] public void RethrowExceptionIfLoadingStateFileThrowsException() { @@ -541,7 +509,6 @@ mockSourceControl.Expect("GetSource", new IsAnything()); mockPublisher.Expect("Run", new IsAnything()); - project.PublishExceptions = true; project.Integrate(ForceBuildRequest()); VerifyAll(); Modified: trunk/project/UnitTests/Core/Tasks/MergeFileTaskTest.cs =================================================================== --- trunk/project/UnitTests/Core/Tasks/MergeFileTaskTest.cs 2006-10-02 05:05:23 UTC (rev 2566) +++ trunk/project/UnitTests/Core/Tasks/MergeFileTaskTest.cs 2006-10-02 05:45:21 UTC (rev 2567) @@ -103,7 +103,7 @@ public void LoadFromConfig() { string xml = @"<merge><files><file>foo.xml</file><file>bar.xml</file></files></merge>"; - MergeFilesTask task = NetReflector.Read(xml) as MergeFilesTask; + task = NetReflector.Read(xml) as MergeFilesTask; Assert.AreEqual(2, task.MergeFiles.Length); Assert.AreEqual("foo.xml", task.MergeFiles[0]); Assert.AreEqual("bar.xml", task.MergeFiles[1]); @@ -111,9 +111,9 @@ private void AssertDataContainedInList(IList list, string data) { - foreach (ITaskResult result in list) + foreach (ITaskResult taskResult in list) { - if (result.Data == data) + if (taskResult.Data == data) return; } Assert.Fail(data + " not found in the list"); Modified: trunk/project/core/IIntegrationRunnerTarget.cs =================================================================== --- trunk/project/core/IIntegrationRunnerTarget.cs 2006-10-02 05:05:23 UTC (rev 2566) +++ trunk/project/core/IIntegrationRunnerTarget.cs 2006-10-02 05:45:21 UTC (rev 2567) @@ -7,8 +7,6 @@ ISourceControl SourceControl { get; } void Prebuild(IIntegrationResult result); - bool PublishExceptions { get; } - void PublishResults(IIntegrationResult result); // Would like to have this somewhere else really Modified: trunk/project/core/IntegrationRunner.cs =================================================================== --- trunk/project/core/IntegrationRunner.cs 2006-10-02 05:05:23 UTC (rev 2566) +++ trunk/project/core/IntegrationRunner.cs 2006-10-02 05:45:21 UTC (rev 2567) @@ -28,27 +28,15 @@ CreateDirectoryIfItDoesntExist(result.WorkingDirectory); CreateDirectoryIfItDoesntExist(result.ArtifactDirectory); result.MarkStartTime(); - try + result.Modifications = GetModifications(lastResult, result); + if (result.ShouldRunBuild()) { - result.Modifications = GetModifications(lastResult, result); - if (result.ShouldRunBuild()) - { - Log.Info("Building: " + request.ToString()); - target.Activity = ProjectActivity.Building; - target.Prebuild(result); - target.SourceControl.GetSource(result); - target.Run(result); - Log.Info("Build complete: " + result.Status); - } + Log.Info("Building: " + request.ToString()); + Build(result); + PostBuild(result); + Log.Info(string.Format("Integration complete: {0} - {1}", result.Status, result.EndTime)); } - catch (Exception ex) - { - Log.Error(ex); - result.ExceptionResult = ex; - } - result.MarkEndTime(); - PostBuild(result); - + target.Activity = ProjectActivity.Sleeping; return result; } @@ -58,48 +46,33 @@ return quietPeriod.GetModifications(target.SourceControl, from, to); } - private void CreateDirectoryIfItDoesntExist(string directory) + private void Build(IIntegrationResult result) { - if (! Directory.Exists(directory)) - Directory.CreateDirectory(directory); - } - - private void PostBuild(IIntegrationResult result) - { - if (ShouldPublishResult(result)) - { - LabelSourceControl(result); - target.PublishResults(result); - resultManager.FinishIntegration(); - } - Log.Info("Integration complete: " + result.EndTime); - - target.Activity = ProjectActivity.Sleeping; - } - - private void LabelSourceControl(IIntegrationResult result) - { + target.Activity = ProjectActivity.Building; try { + target.Prebuild(result); + target.SourceControl.GetSource(result); + target.Run(result); target.SourceControl.LabelSourceControl(result); } - catch (Exception e) + catch (Exception ex) { - Log.Error(new CruiseControlException("Exception occurred while labelling source control provider.", e)); + result.ExceptionResult = ex; } + result.MarkEndTime(); } - private bool ShouldPublishResult(IIntegrationResult result) + private void PostBuild(IIntegrationResult result) { - IntegrationStatus integrationStatus = result.Status; - if (integrationStatus == IntegrationStatus.Exception) - { - return target.PublishExceptions; - } - else - { - return integrationStatus != IntegrationStatus.Unknown; - } + target.PublishResults(result); + resultManager.FinishIntegration(); } + + private void CreateDirectoryIfItDoesntExist(string directory) + { + if (! Directory.Exists(directory)) + Directory.CreateDirectory(directory); + } } } \ No newline at end of file Modified: trunk/project/core/Project.cs =================================================================== --- trunk/project/core/Project.cs 2006-10-02 05:05:23 UTC (rev 2566) +++ trunk/project/core/Project.cs 2006-10-02 05:45:21 UTC (rev 2567) @@ -128,13 +128,6 @@ set { tasks = value; } } - [ReflectorProperty("publishExceptions", Required=false)] - public bool PublishExceptions - { - get { return publishExceptions; } - set { publishExceptions = value; } - } - // Move this ideally public ProjectActivity Activity { Modified: trunk/project/core/ProjectIntegrator.cs =================================================================== --- trunk/project/core/ProjectIntegrator.cs 2006-10-02 05:05:23 UTC (rev 2566) +++ trunk/project/core/ProjectIntegrator.cs 2006-10-02 05:45:21 UTC (rev 2567) @@ -87,7 +87,7 @@ /// </summary> private void Run() { - Log.Info("Starting integration for project: " + project.Name); + Log.Info("Starting integrator for project: " + project.Name); try { // loop, until the integrator is stopped Modified: trunk/project/examples/VSSAndDevenvAndNUnitCCNet.config =================================================================== --- trunk/project/examples/VSSAndDevenvAndNUnitCCNet.config 2006-10-02 05:05:23 UTC (rev 2566) +++ trunk/project/examples/VSSAndDevenvAndNUnitCCNet.config 2006-10-02 05:45:21 UTC (rev 2567) @@ -1,5 +1,5 @@ <cruisecontrol> - <project name="Refactoring" webURL="http://localhost/ccnet" publishExceptions="true"> + <project name="Refactoring" webURL="http://localhost/ccnet"> <sourcecontrol type="vss" autoGetSource="true"> <project>$/Refactoring</project> <username>orogers</username> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |