Exemplo n.º 1
0
        protected override bool Execute(IIntegrationResult result)
        {
            ProcessInfo processInfo = CreateProcessInfo(result);
            result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : string.Format("Executing Rake: {0}", processInfo.PublicArguments));
            ProcessResult processResult = TryToRun(processInfo, result);

            if (!StringUtil.IsWhitespace(processResult.StandardOutput) || !StringUtil.IsWhitespace(processResult.StandardError))
            {
                // The executable produced some output.  We need to transform it into an XML build report
                // fragment so the rest of CC.Net can process it.
                ProcessResult newResult = new ProcessResult(
                    StringUtil.MakeBuildResult(processResult.StandardOutput,string.Empty),
                    StringUtil.MakeBuildResult(processResult.StandardError, "Error"),
                    processResult.ExitCode,
                    processResult.TimedOut,
                    processResult.Failed);

                processResult = newResult;
            }

            result.AddTaskResult(new ProcessTaskResult(processResult));

            if (processResult.TimedOut)
                throw new BuilderException(this, "Command Line Build timed out (after " + BuildTimeoutSeconds + " seconds)");

            return (!processResult.Failed);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="DevenvTaskResult" /> class.	
        /// </summary>
        /// <param name="result">The result.</param>
        /// <remarks></remarks>
		public DevenvTaskResult(ProcessResult result,TaskBase task) :
            base(result) { _task = task; }
Exemplo n.º 3
0
        /// <summary>
        /// Run the task.
        /// </summary>
        /// <param name="result"></param>
        protected override bool Execute(IIntegrationResult result)
        {
            result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : "Running CodeItRight analysis");

            // Run the executable
            var processResult = TryToRun(CreateProcessInfo(result), result);

            // Need to start a new result as CodeItRight returns the number of violation
            processResult = new ProcessResult(
                processResult.StandardOutput,
                processResult.StandardError,
                processResult.ExitCode,
                processResult.TimedOut,
                processResult.ExitCode < 0);
            result.AddTaskResult(new ProcessTaskResult(processResult));

            if (!processResult.Failed)
            {
                var xmlFile = result.BaseFromWorkingDirectory("codeitright.xml");
                result.AddTaskResult(
                    new FileTaskResult(xmlFile, true));
            }

            // Check the failure threshold
            var failed = processResult.Failed;
            if (!failed && (this.FailureThreshold != Severity.None))
            {
                var xmlFile = result.BaseFromWorkingDirectory("codeitright.xml");
                var document = new XmlDocument();
                if (File.Exists(xmlFile))
                {
                    document.Load(xmlFile);
                    for (var level = (int)Severity.CriticalError; level >= (int)this.FailureThreshold; level--)
                    {
                        failed = CodeItRightTask.CheckReportForSeverity(document, (Severity)level);
                        if (failed)
                        {
                            break;
                        }
                    }
                }
            }

            return !failed;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Executes the specified result.	
        /// </summary>
        /// <param name="result">The result.</param>
        /// <returns></returns>
        /// <remarks></remarks>
				protected override bool Execute(IIntegrationResult result)
				{
					ProcessInfo processInfo = CreateProcessInfo(result);
					result.BuildProgressInformation.SignalStartRunTask(!string.IsNullOrEmpty(Description) ? Description : string.Format(System.Globalization.CultureInfo.CurrentCulture, "Executing Rake: {0}", processInfo.PublicArguments));
					ProcessResult processResult = TryToRun(processInfo, result);

					if (!StringUtil.IsWhitespace(processResult.StandardOutput) || !StringUtil.IsWhitespace(processResult.StandardError))
					{
						// The executable produced some output.  We need to transform it into an XML build report 
						// fragment so the rest of CC.Net can process it.
						ProcessResult newResult = new ProcessResult(
							StringUtil.MakeBuildResult(processResult.StandardOutput, string.Empty),
							StringUtil.MakeBuildResult(processResult.StandardError, "Error"),
							processResult.ExitCode,
							processResult.TimedOut,
							processResult.Failed);

						processResult = newResult;
					}

					result.AddTaskResult(new ProcessTaskResult(processResult));

					if (processResult.TimedOut)
						result.AddTaskResult(MakeTimeoutBuildResult(processInfo));

					return processResult.Succeeded;
				}
        /// <summary>
        /// Initializes a new instance of the <see cref="DevenvTaskResult" /> class.	
        /// </summary>
        /// <param name="result">The result.</param>
        /// <remarks></remarks>
		public DevenvTaskResult(ProcessResult result) : 
			base(result){}
        public void ShouldSetOutputAndIntegrationStatusToSuccessOnSuccessfulBuild()
        {
            ProcessResult processResult = new ProcessResult(" ", string.Empty, ProcessResult.SUCCESSFUL_EXIT_CODE, false);
            mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] { new IsAnything() });
            mytask.Executable = POWERSHELL_PATH;
            mytask.Script = "MyScript.ps1";
            mytask.BuildArgs = "an arg";
            mytask.EnvironmentVariables = new EnvironmentVariable[]
            {
                new EnvironmentVariable
                {
                    name = "test",
                    value = "value"
                }
            };

            IntegrationResult result = (IntegrationResult)IntegrationResult();
            mytask.Run(result);

            Assert.AreEqual(IntegrationStatus.Success, result.Status);
            CustomAssertion.AssertMatches(" ", result.TaskOutput);
        }
        public void ShouldSetOutputAndIntegrationStatusToFailedOnFailedBuild()
        {
            ProcessResult processResult = new ProcessResult(@"Documents\WindowsPowerShell\MyScript.ps1' is not recognized as a cmdlet", string.Empty, 1, false);
            CollectingConstraint constraint = new CollectingConstraint();
            mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] { constraint });

            mytask.Executable = POWERSHELL_PATH;
            mytask.Script = "MyScript.ps1";
            mytask.ConfiguredScriptsDirectory = @"D:\CruiseControl";

            IIntegrationResult result = Integration("myProject", @"D:\CruiseControl", "myArtifactDirectory");
            mytask.Run(result);

            ProcessInfo info = (ProcessInfo)constraint.Parameter;
            Assert.AreEqual(@"D:\CruiseControl", info.WorkingDirectory);

            Assert.AreEqual(IntegrationStatus.Failure, result.Status);
            CustomAssertion.AssertMatches(@"(\.|\n)*is not recognized as a cmdlet", result.TaskOutput);
        }
        public void VerifyPowerShellProcessInfoBasic()
        {
            CollectingConstraint constraint = new CollectingConstraint();
            ProcessResult processResult = new ProcessResult("output", "error", 0, false);
            mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] { constraint });
            mytask.Executable = POWERSHELL_PATH;
            mytask.Script = "MyScipt.ps1";
           
            mytask.Run(IntegrationResult());

            ProcessInfo info = (ProcessInfo)constraint.Parameter;
            Assert.AreEqual(POWERSHELL_PATH, info.FileName);
            Assert.AreEqual(PowerShellTask.DefaultBuildTimeOut * 1000, info.TimeOut);
            CustomAssertion.AssertContains(mytask.Script, info.Arguments);
        }
        public void VerifyPowerShellProcessInfoWithScriptsDirectoryConfigured()
        {
            CollectingConstraint constraint = new CollectingConstraint();
            ProcessResult processResult = new ProcessResult("output", "error", 0, false);
            mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] { constraint });
            mytask.Executable = POWERSHELL_PATH;
            mytask.Script = "MyScript.ps1";
            mytask.ConfiguredScriptsDirectory = @"D:\CruiseControl";

            mytask.Run(IntegrationResult());

            ProcessInfo info = (ProcessInfo)constraint.Parameter;
            Assert.AreEqual(POWERSHELL_PATH, info.FileName);
            Assert.AreEqual(PowerShellTask.DefaultBuildTimeOut * 1000, info.TimeOut);
            CustomAssertion.AssertStartsWith(@"-nologo -NoProfile -NonInteractive -file ""D:\CruiseControl\MyScript.ps1""", info.Arguments);
        }
Exemplo n.º 10
0
        public void ShouldThrowBuilderExceptionIfProcessTimesOut()
        {
            ProcessResult processResult = new ProcessResult(string.Empty, string.Empty, ProcessResult.TIMED_OUT_EXIT_CODE, true);
            mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] { new IsAnything() });
            mytask.BuildTimeoutSeconds = 2;
            mytask.Executable = POWERSHELL_PATH;
            mytask.Script = "MyScript.ps1";

            Assert.That(delegate { mytask.Run(IntegrationResult()); },
                        Throws.TypeOf<BuilderException>());
        }
Exemplo n.º 11
0
		public void ShouldThrowBuilderExceptionIfProcessTimesOut()
		{
			ProcessResult processResult = new ProcessResult(string.Empty, string.Empty, ProcessResult.TIMED_OUT_EXIT_CODE, true);
			mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] {new IsAnything()});
			task.BuildTimeoutSeconds = 2;
			task.Executable = DEVENV_PATH;
			task.SolutionFile = SOLUTION_FILE;
			task.Configuration = CONFIGURATION;

            Assert.That(delegate { task.Run(IntegrationResult()); },
                        Throws.TypeOf<BuilderException>());
		}
Exemplo n.º 12
0
		public void ShouldSetOutputAndIntegrationStatusToFailedOnFailedBuild()
		{
			ProcessResult processResult = new ProcessResult(@"D:\dev\ccnet\ccnet\project\nosolution.sln could not be found and will not be loaded", string.Empty, 1, false);
			CollectingConstraint constraint = new CollectingConstraint();
			mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] {constraint});

			task.Executable = DEVENV_PATH;
			task.SolutionFile = @"D:\dev\ccnet\ccnet\project\nosolution.sln";
			task.Configuration = CONFIGURATION;

			IIntegrationResult result = Integration("myProject", "myWorkingDirectory", "myArtifactDirectory");
			task.Run(result);

			ProcessInfo info = (ProcessInfo) constraint.Parameter;
			Assert.AreEqual("myWorkingDirectory", info.WorkingDirectory);

			Assert.AreEqual(IntegrationStatus.Failure, result.Status);
			AssertMatches(@"(\.|\n)*could not be found and will not be loaded", result.TaskOutput);
		}
Exemplo n.º 13
0
		public void ShouldSetOutputAndIntegrationStatusToSuccessOnSuccessfulBuild()
		{
			ProcessResult processResult = new ProcessResult(@"Rebuild All: 10 succeeded, 0 failed, 0 skipped", string.Empty, ProcessResult.SUCCESSFUL_EXIT_CODE, false);
			mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] { new IsAnything() });
			task.Executable = DEVENV_PATH;
			task.SolutionFile = SOLUTION_FILE;
			task.Configuration = CONFIGURATION;

			IntegrationResult result = (IntegrationResult)IntegrationResult();
			task.Run(result);

			Assert.AreEqual(IntegrationStatus.Success, result.Status);
			AssertMatches(@"Rebuild All: \d+ succeeded, \d+ failed, \d+ skipped", result.TaskOutput);
		}
Exemplo n.º 14
0
		public void VerifyDevenvProcessInfoWithProjectDefined()
		{
			CollectingConstraint constraint = new CollectingConstraint();
			ProcessResult processResult = new ProcessResult("output", "error", 0, false);
			mockProcessExecutor.ExpectAndReturn("Execute", processResult, new object[] {constraint});
			task.Executable = DEVENV_PATH;
			task.SolutionFile = "mySolution.sln";
			task.Configuration = "\"Debug\"";
			task.Project = "myProject";

			task.Run(IntegrationResult());

			ProcessInfo info = (ProcessInfo) constraint.Parameter;
			Assert.AreEqual(DEVENV_PATH, info.FileName);
			Assert.AreEqual(DevenvTask.DEFAULT_BUILD_TIMEOUT*1000, info.TimeOut);
            AssertStartsWith("\"mySolution.sln\" /rebuild \"Debug\" /project \"myProject\"", info.Arguments);
		}