public void BuildProjectWith1TargetWhichDependsOn1TargetWhichErrors()
        {
            ProjectDefinition project1 = new ProjectDefinition(FullProjectPath("1.proj"));
            TargetDefinition  target1  = new TargetDefinition("Target1", null, "Target2", project1.ProjectXmlDocument);
            TargetDefinition  target2  = new TargetDefinition("Target2", null, project1.ProjectXmlDocument);
            TaskDefinition    task1    = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition    task2    = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetStopWithErrorResult());

            target1.AddTask(task1);
            target2.AddTask(task2);
            project1.AddTarget(target1);
            project1.AddTarget(target2);
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] {
                "Target1"
            }, null, 100, null, (IBuildComponentHost)_commonTests.Host);

            test1.ProjectDefinition = project1;

            test1.SubmitBuildRequest();

            task2.WaitForTaskToComplete();
            test1.WaitForResults();

            test1.ValidateNonPrimaryTargetEndResult("Target2", TargetResultCode.Failure, null);
            test1.ValidateTargetEndResult("Target1", TargetResultCode.Failure, null);
        }
        public void Build1ProjectWith2TargetAnd1TaskEach()
        {
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[2] {
                "Target1", "Target2"
            }, null, 100, null, (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition project1 = test1.ProjectDefinition;
            TargetDefinition  target1  = new TargetDefinition("Target1", project1.ProjectXmlDocument);
            TargetDefinition  target2  = new TargetDefinition("Target2", project1.ProjectXmlDocument);
            TaskDefinition    task1    = new TaskDefinition("Task1", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition    task2    = new TaskDefinition("Task2", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());

            target1.AddTask(task1);
            target1.AddTask(task2);
            project1.AddTarget(target1);
            project1.AddTarget(target2);

            test1.SubmitBuildRequest();

            task1.WaitForTaskToComplete();
            task2.WaitForTaskToComplete();
            test1.WaitForResults();
            test1.ValidateTargetBuilt("Target1");
            test1.ValidateTargetBuilt("Target2");
            test1.ValidateTargetEndResult("Target1", TargetResultCode.Success, null);
            test1.ValidateTargetEndResult("Target2", TargetResultCode.Success, null);
        }
        public void DependentTargetsDependOnTheSameTarget3()
        {
            string[] targetsToBuild = new string[1] {
                "target1"
            };

            RequestDefinition request = new RequestDefinition(FullProjectPath("1.proj"), "2.0", targetsToBuild, null, 0, null, (IBuildComponentHost)_commonTests.Host);

            TargetDefinition target1 = new TargetDefinition("target1", null, "target2;target3", request.ProjectDefinition.ProjectXmlDocument);
            TargetDefinition target2 = new TargetDefinition("target2", null, "target4", request.ProjectDefinition.ProjectXmlDocument);
            TargetDefinition target3 = new TargetDefinition("target3", null, "target2", request.ProjectDefinition.ProjectXmlDocument);
            TargetDefinition target4 = new TargetDefinition("target4", null, "target5", request.ProjectDefinition.ProjectXmlDocument);
            TargetDefinition target5 = new TargetDefinition("target5", request.ProjectDefinition.ProjectXmlDocument);

            request.ProjectDefinition.AddTarget(target1);
            request.ProjectDefinition.AddTarget(target2);
            request.ProjectDefinition.AddTarget(target3);
            request.ProjectDefinition.AddTarget(target4);
            request.ProjectDefinition.AddTarget(target5);

            request.SubmitBuildRequest();

            request.WaitForResults();

            request.ValidateTargetEndResult("target1", TargetResultCode.Success, null);
            request.ValidateNonPrimaryTargetEndResult("target2", TargetResultCode.Success, null);
            request.ValidateNonPrimaryTargetEndResult("target3", TargetResultCode.Success, null);
            request.ValidateNonPrimaryTargetEndResult("target4", TargetResultCode.Success, null);
            request.ValidateNonPrimaryTargetEndResult("target5", TargetResultCode.Success, null);
        }
        public void TasksContinueToExecuteAfterContinueOnError()
        {
            ProjectDefinition project1 = new ProjectDefinition(FullProjectPath("1.proj"));
            TargetDefinition  target1  = new TargetDefinition("Target1", null, "Target2", project1.ProjectXmlDocument);
            TargetDefinition  target2  = new TargetDefinition("Target2", null, project1.ProjectXmlDocument);
            TaskDefinition    task1    = new TaskDefinition("t1-1", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition    task2    = new TaskDefinition("t2-1", null, false, project1.ProjectXmlDocument, TestUtilities.GetContinueWithErrorResult());
            TaskDefinition    task3    = new TaskDefinition("t2-2", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());

            target1.AddTask(task1);
            target2.AddTask(task2);
            target2.AddTask(task3);

            project1.AddTarget(target1);
            project1.AddTarget(target2);
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] {
                "Target1"
            }, null, 100, null, (IBuildComponentHost)_commonTests.Host);

            test1.ProjectDefinition = project1;

            test1.SubmitBuildRequest();

            task2.WaitForTaskToComplete();
            task1.WaitForTaskToComplete();
            test1.WaitForResults();

            test1.ValidateNonPrimaryTargetEndResult("Target2", TargetResultCode.Success, null);
            test1.ValidateTargetEndResult("Target1", TargetResultCode.Success, null);
        }
示例#5
0
        public void BuildDependentTargetWithFalseCondition()
        {
            ProjectDefinition project1 = new ProjectDefinition(FullProjectPath("1.proj"));
            TargetDefinition  target1  = new TargetDefinition("Target1", null, "Target2", project1.ProjectXmlDocument);
            TargetDefinition  target2  = new TargetDefinition("Target2", @"'1' == '2'", project1.ProjectXmlDocument);
            TaskDefinition    task1    = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition    task2    = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());

            target1.AddTask(task1);
            target2.AddTask(task2);
            project1.AddTarget(target1);
            project1.AddTarget(target2);
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] {
                "Target1"
            }, null, 100, null, (IBuildComponentHost)this.commonTests.Host);

            test1.ProjectDefinition = project1;

            test1.SubmitBuildRequest();

            task1.WaitForTaskToComplete();
            test1.WaitForResults();
            test1.ValidateTargetBuilt("Target1");
            test1.ValidateNonPrimaryTargetEndResult("Target2", TargetResultCode.Skipped, null);
            test1.ValidateTargetEndResult("Target1", TargetResultCode.Success, null);
        }
示例#6
0
        /// <summary>
        /// Create a default target in the project file if there are no existing targets in the project file
        /// </summary>
        private void CreateDefaultFirstTarget()
        {
            TargetDefinition target = new TargetDefinition(RequestDefinition.defaultTargetName, this.projectXmlDocument);

            this.AddTarget(target);
            this.projectRootElement.AppendChild(target.FinalTargetXmlElement);
        }
        public void Build1ProjectWith1TargetWhereConditionIsFasle()
        {
            RequestDefinition test1    = new RequestDefinition(FullProjectPath("1.proj"), (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition project1 = test1.ProjectDefinition;
            TargetDefinition  target1  = new TargetDefinition(RequestDefinition.defaultTargetName, @"'1' == '2'", project1.ProjectXmlDocument);
            TaskDefinition    task1    = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());

            target1.AddTask(task1);
            project1.AddTarget(target1);

            test1.SubmitBuildRequest();

            test1.WaitForResults();
            test1.ValidateTargetEndResult(RequestDefinition.defaultTargetName, TargetResultCode.Skipped, null);
        }
        public void ValidateTargetOutput()
        {
            RequestDefinition test1    = new RequestDefinition(FullProjectPath("1.proj"), (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition project1 = test1.ProjectDefinition;
            TargetDefinition  target1  = new TargetDefinition("Target1", null, "Foo", null, project1.ProjectXmlDocument);

            project1.AddTarget(target1);

            test1.SubmitBuildRequest();

            test1.WaitForResults();
            test1.ValidateTargetEndResult("Target1", TargetResultCode.Success, new string[1] {
                "Foo"
            });
        }
        public void Build1ProjectWith1TargetWhereTheTaskFail()
        {
            RequestDefinition test1    = new RequestDefinition(FullProjectPath("1.proj"), (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition project1 = test1.ProjectDefinition;
            TargetDefinition  target1  = new TargetDefinition(RequestDefinition.defaultTargetName, null, project1.ProjectXmlDocument);
            TaskDefinition    task1    = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetStopWithErrorResult());

            target1.AddTask(task1);
            project1.AddTarget(target1);

            test1.SubmitBuildRequest();

            test1.WaitForResults();
            test1.ValidateTargetBuilt(RequestDefinition.defaultTargetName);
            test1.ValidateTargetEndResult(RequestDefinition.defaultTargetName, TargetResultCode.Failure, null);
        }
示例#10
0
        public void TaskStatusOnCancellation()
        {
            RequestDefinition r1  = new RequestDefinition(FullProjectPath("1.proj"), "4.0", null, null, 5000, null, (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition p1  = r1.ProjectDefinition;
            TargetDefinition  t1  = new TargetDefinition(RequestDefinition.defaultTargetName, p1.ProjectXmlDocument);
            TaskDefinition    ta1 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, p1.ProjectXmlDocument, TestUtilities.GetSuccessResult());

            t1.AddTask(ta1);
            p1.AddTarget(t1);

            r1.SubmitBuildRequest();
            ta1.WaitForTaskToStart();
            _commonTests.Host.ShutDownRequestEngine();

            r1.WaitForResultsThrowException();
        }
示例#11
0
        public void CircularDependencyWithParentTarget()
        {
            ProjectDefinition project = new ProjectDefinition(FullProjectPath("1.proj"));
            TargetDefinition  target1 = new TargetDefinition("target1", null, "target2", project.ProjectXmlDocument);
            TargetDefinition  target2 = new TargetDefinition("target2", null, "target1", project.ProjectXmlDocument);
            RequestDefinition test    = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] {
                "target1"
            }, null, 0, null, (IBuildComponentHost)_commonTests.Host);

            project.AddTarget(target1);
            project.AddTarget(target2);
            test.ProjectDefinition = project;

            test.SubmitBuildRequest();

            test.WaitForResultsThrowException();
        }
示例#12
0
        public void Build1ProjectWith1TargetAnd2Task()
        {
            RequestDefinition test1    = new RequestDefinition(FullProjectPath("1.proj"), (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition project1 = test1.ProjectDefinition;
            TargetDefinition  target1  = new TargetDefinition(RequestDefinition.defaultTargetName, project1.ProjectXmlDocument);
            TaskDefinition    task1    = new TaskDefinition("task1", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition    task2    = new TaskDefinition("task2", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());

            target1.AddTask(task1);
            target1.AddTask(task2);
            project1.AddTarget(target1);

            test1.SubmitBuildRequest();

            task1.WaitForTaskToComplete();
            task2.WaitForTaskToComplete();
            test1.WaitForResults();
            test1.ValidateTargetBuilt(RequestDefinition.defaultTargetName);
            test1.ValidateTargetEndResult(RequestDefinition.defaultTargetName, TargetResultCode.Success, null);
        }
示例#13
0
        /// <summary>
        /// Simulates executing a task. Execution time simulation is rounded to the closes numeric value. If this value is less than 1000 than nothing happens.
        /// </summary>
        public Task <WorkUnitResult> ExecuteTask(TargetLoggingContext targetLoggingContext, BuildRequestEntry requestEntry, ITargetBuilderCallback targetBuilderCallback, ProjectTargetInstanceChild task, TaskExecutionMode mode, Lookup lookupForInference, Lookup lookupForExecution, CancellationToken cancellationToken)
        {
            bool cancelled = false;
            RequestDefinition   testDefinition   = _testDataProvider[requestEntry.Request.ConfigurationId];
            TargetDefinition    targetDefinition = testDefinition.ProjectDefinition.TargetsCollection[targetLoggingContext.Target.Name];
            ProjectTaskInstance taskInstance     = (ProjectTaskInstance)task as ProjectTaskInstance;
            TaskDefinition      taskDefinition   = targetDefinition.TasksCollection[taskInstance.Name];

            taskDefinition.SignalTaskStarted();

            if (testDefinition.ExecutionTime > 1000)
            {
                DateTime startTime = DateTime.Now;
                long     executionTimeInSeconds = testDefinition.ExecutionTime / 1000;

                while (executionTimeInSeconds > 0)
                {
                    if (cancellationToken.WaitHandle.WaitOne(1, false) == true)
                    {
                        cancelled = true;
                        break;
                    }

                    Thread.Sleep(1000);
                    executionTimeInSeconds -= 1;
                }
            }

            if (!cancelled)
            {
                _result = taskDefinition.ExpectedResult;
            }
            else
            {
                _result = new WorkUnitResult(WorkUnitResultCode.Canceled, WorkUnitActionCode.Stop, new MockTaskBuilderException());
            }

            taskDefinition.SignalTaskCompleted();
            _taskDone.Set();
            return(Task <BuildResult> .FromResult(_result));
        }
示例#14
0
        /// <summary>
        /// Helper method to create the request definition and setting the request definition will have an actual project instance or not
        /// </summary>
        private RequestDefinition InternalCreateNewRequest(string projectFile, string toolsversion, string[] targetsToBuild, PropertyDictionary <ProjectPropertyInstance> globalProperties)
        {
            // Make sure that the path is rooted. This is particularly important when testing implementation of RequestBuilder. The RequestBuild adds default path if the project file path
            // is not rooted. This will cause us to not be able to locate the approprate RequestDefinition as the file name is also used as a comparing mechinasim
            projectFile = System.IO.Path.Combine(this.tempPath, projectFile);
            RequestDefinition p1 = new RequestDefinition(projectFile, toolsversion, targetsToBuild, globalProperties, 0, null, (IBuildComponentHost)this.host);

            // If a project object is to be created then we will need to add all targets that we will be building to the project XML
            if (this.createMSBuildProject)
            {
                p1.CreateMSBuildProject = true;
                ProjectDefinition p = p1.ProjectDefinition;
                foreach (string target in targetsToBuild)
                {
                    TargetDefinition t = new TargetDefinition(target, p.ProjectXmlDocument);
                    p1.ProjectDefinition.AddTarget(t);
                }
            }

            return(p1);
        }
示例#15
0
        public void BuildRequestContainsTheSameTargetTwiceWHichPreviouslyPassed()
        {
            string[] targetsToBuild = new string[3] {
                "target1", "target2", "target1"
            };

            RequestDefinition request = new RequestDefinition(FullProjectPath("1.proj"), "2.0", targetsToBuild, null, 0, null, (IBuildComponentHost)_commonTests.Host);

            TargetDefinition target1 = new TargetDefinition("target1", request.ProjectDefinition.ProjectXmlDocument);
            TargetDefinition target2 = new TargetDefinition("target2", request.ProjectDefinition.ProjectXmlDocument);

            request.ProjectDefinition.AddTarget(target1);
            request.ProjectDefinition.AddTarget(target2);

            request.SubmitBuildRequest();

            request.WaitForResults();

            request.ValidateTargetEndResult("target1", TargetResultCode.Success, null);
            request.ValidateTargetEndResult("target2", TargetResultCode.Success, null);
        }
示例#16
0
        public void TargetDependencyChain2()
        {
            ProjectDefinition project1 = new ProjectDefinition(FullProjectPath("1.proj"));
            TargetDefinition  target1  = new TargetDefinition("Target1", null, "Target2;Target3", project1.ProjectXmlDocument);
            TargetDefinition  target2  = new TargetDefinition("Target2", null, null, project1.ProjectXmlDocument);
            TargetDefinition  target3  = new TargetDefinition("Target3", null, "Target4", project1.ProjectXmlDocument);
            TargetDefinition  target4  = new TargetDefinition("Target4", null, null, project1.ProjectXmlDocument);
            TaskDefinition    task1    = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition    task2    = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition    task3    = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition    task4    = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            RequestDefinition test1    = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] {
                "Target1"
            }, null, 100, null, (IBuildComponentHost)_commonTests.Host);

            target1.AddTask(task1);
            target2.AddTask(task2);
            target3.AddTask(task3);
            target4.AddTask(task4);
            project1.AddTarget(target1);
            project1.AddTarget(target2);
            project1.AddTarget(target3);
            project1.AddTarget(target4);
            test1.ProjectDefinition = project1;

            test1.SubmitBuildRequest();

            task2.WaitForTaskToComplete();
            task4.WaitForTaskToComplete();
            task3.WaitForTaskToComplete();
            task1.WaitForTaskToComplete();
            test1.WaitForResults();

            test1.ValidateTargetEndResult("Target1", TargetResultCode.Success, null);
            test1.ValidateNonPrimaryTargetEndResult("Target2", TargetResultCode.Success, null);
            test1.ValidateNonPrimaryTargetEndResult("Target3", TargetResultCode.Success, null);
            test1.ValidateNonPrimaryTargetEndResult("Target4", TargetResultCode.Success, null);
        }
示例#17
0
        public void OnErrorTargetIsBuilt()
        {
            RequestDefinition r1 = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] {
                "tar1"
            }, null, 0, null, (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition p1 = r1.ProjectDefinition;

            TargetDefinition tar1       = new TargetDefinition("tar1", p1.ProjectXmlDocument);
            TargetDefinition tarOnError = new TargetDefinition("error", p1.ProjectXmlDocument);
            TaskDefinition   tas1       = new TaskDefinition("tas1", p1.ProjectXmlDocument, TestUtilities.GetStopWithErrorResult());

            tar1.AddTask(tas1);
            tar1.AddOnError("error", null);
            p1.AddTarget(tar1);
            p1.AddTarget(tarOnError);

            r1.SubmitBuildRequest();

            r1.WaitForResults();

            r1.ValidateTargetEndResult("tar1", TargetResultCode.Failure, null);
            r1.ValidateNonPrimaryTargetEndResult("error", TargetResultCode.Success, null);
        }
示例#18
0
 /// <summary>
 /// Create a default target in the project file if there are no existing targets in the project file
 /// </summary>
 private void CreateDefaultFirstTarget()
 {
     TargetDefinition target = new TargetDefinition(RequestDefinition.defaultTargetName, this.projectXmlDocument);
     this.AddTarget(target);
     this.projectRootElement.AppendChild(target.FinalTargetXmlElement);
 }
示例#19
0
        public void TasksContinueToExecuteAfterContinueOnError()
        {
            ProjectDefinition project1 = new ProjectDefinition(FullProjectPath("1.proj"));
            TargetDefinition target1 = new TargetDefinition("Target1", null, "Target2", project1.ProjectXmlDocument);
            TargetDefinition target2 = new TargetDefinition("Target2", null, project1.ProjectXmlDocument);
            TaskDefinition task1 = new TaskDefinition("t1-1", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition task2 = new TaskDefinition("t2-1", null, false, project1.ProjectXmlDocument, TestUtilities.GetContinueWithErrorResult());
            TaskDefinition task3 = new TaskDefinition("t2-2", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            target1.AddTask(task1);
            target2.AddTask(task2);
            target2.AddTask(task3);

            project1.AddTarget(target1);
            project1.AddTarget(target2);
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] { "Target1" }, null, 100, null, (IBuildComponentHost)_commonTests.Host);
            test1.ProjectDefinition = project1;

            test1.SubmitBuildRequest();

            task2.WaitForTaskToComplete();
            task1.WaitForTaskToComplete();
            test1.WaitForResults();

            test1.ValidateNonPrimaryTargetEndResult("Target2", TargetResultCode.Success, null);
            test1.ValidateTargetEndResult("Target1", TargetResultCode.Success, null);
        }
示例#20
0
        /// <summary>
        /// Helper method to create the request definition and setting the request definition will have an actual project instance or not
        /// </summary>
        private RequestDefinition InternalCreateNewRequest(string projectFile, string toolsversion, string[] targetsToBuild, PropertyDictionary<ProjectPropertyInstance> globalProperties)
        {
            // Make sure that the path is rooted. This is particularly important when testing implementation of RequestBuilder. The RequestBuild adds default path if the project file path 
            // is not rooted. This will cause us to not be able to locate the approprate RequestDefinition as the file name is also used as a comparing mechinasim
            projectFile = System.IO.Path.Combine(_tempPath, projectFile);
            RequestDefinition p1 = new RequestDefinition(projectFile, toolsversion, targetsToBuild, globalProperties, 0, null, (IBuildComponentHost)_host);

            // If a project object is to be created then we will need to add all targets that we will be building to the project XML
            if (_createMSBuildProject)
            {
                p1.CreateMSBuildProject = true;
                ProjectDefinition p = p1.ProjectDefinition;
                foreach (string target in targetsToBuild)
                {
                    TargetDefinition t = new TargetDefinition(target, p.ProjectXmlDocument);
                    p1.ProjectDefinition.AddTarget(t);
                }
            }

            return p1;
        }
示例#21
0
        public void Build1ProjectWith2TargetAnd1TaskEach()
        {
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[2] { "Target1", "Target2" }, null, 100, null, (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition project1 = test1.ProjectDefinition;
            TargetDefinition target1 = new TargetDefinition("Target1", project1.ProjectXmlDocument);
            TargetDefinition target2 = new TargetDefinition("Target2", project1.ProjectXmlDocument);
            TaskDefinition task1 = new TaskDefinition("Task1", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition task2 = new TaskDefinition("Task2", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            target1.AddTask(task1);
            target1.AddTask(task2);
            project1.AddTarget(target1);
            project1.AddTarget(target2);

            test1.SubmitBuildRequest();

            task1.WaitForTaskToComplete();
            task2.WaitForTaskToComplete();
            test1.WaitForResults();
            test1.ValidateTargetBuilt("Target1");
            test1.ValidateTargetBuilt("Target2");
            test1.ValidateTargetEndResult("Target1", TargetResultCode.Success, null);
            test1.ValidateTargetEndResult("Target2", TargetResultCode.Success, null);
        }
示例#22
0
        public void Build1ProjectWith1TargetAnd2Task()
        {
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition project1 = test1.ProjectDefinition;
            TargetDefinition target1 = new TargetDefinition(RequestDefinition.defaultTargetName, project1.ProjectXmlDocument);
            TaskDefinition task1 = new TaskDefinition("task1", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition task2 = new TaskDefinition("task2", null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            target1.AddTask(task1);
            target1.AddTask(task2);
            project1.AddTarget(target1);

            test1.SubmitBuildRequest();

            task1.WaitForTaskToComplete();
            task2.WaitForTaskToComplete();
            test1.WaitForResults();
            test1.ValidateTargetBuilt(RequestDefinition.defaultTargetName);
            test1.ValidateTargetEndResult(RequestDefinition.defaultTargetName, TargetResultCode.Success, null);
        }
示例#23
0
 /// <summary>
 /// Add a new target to the project
 /// </summary>
 public void AddTarget(TargetDefinition target)
 {
     this.projectRootElement.AppendChild(target.FinalTargetXmlElement);
     this.targets.Add(target.Name, target);
 }
示例#24
0
        public void OnErrorTargetIsBuilt()
        {
            RequestDefinition r1 = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] { "tar1" }, null, 0, null, (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition p1 = r1.ProjectDefinition;

            TargetDefinition tar1 = new TargetDefinition("tar1", p1.ProjectXmlDocument);
            TargetDefinition tarOnError = new TargetDefinition("error", p1.ProjectXmlDocument);
            TaskDefinition tas1 = new TaskDefinition("tas1", p1.ProjectXmlDocument, TestUtilities.GetStopWithErrorResult());

            tar1.AddTask(tas1);
            tar1.AddOnError("error", null);
            p1.AddTarget(tar1);
            p1.AddTarget(tarOnError);

            r1.SubmitBuildRequest();

            r1.WaitForResults();

            r1.ValidateTargetEndResult("tar1", TargetResultCode.Failure, null);
            r1.ValidateNonPrimaryTargetEndResult("error", TargetResultCode.Success, null);
        }
示例#25
0
        public void CircularDependencyInvolvingTargetsWithinDefaultTargets()
        {
            ProjectDefinition project = new ProjectDefinition(FullProjectPath("1.proj"), null, "target1", "2.0", true);
            TargetDefinition target1 = new TargetDefinition("target1", null, "target2", project.ProjectXmlDocument);
            TargetDefinition target2 = new TargetDefinition("target2", null, "target1", project.ProjectXmlDocument);

            project.AddTarget(target1);
            project.AddTarget(target2);

            RequestDefinition request = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] { "target1" }, null, 0, null, (IBuildComponentHost)_commonTests.Host);
            request.ProjectDefinition = project;

            request.SubmitBuildRequest();

            request.WaitForResultsThrowException();
        }
示例#26
0
 /// <summary>
 /// Add a new target to the project
 /// </summary>
 public void AddTarget(TargetDefinition target)
 {
     this.projectRootElement.AppendChild(target.FinalTargetXmlElement);
     this.targets.Add(target.Name, target);
 }
示例#27
0
        public void BuildRequestContainsTheSameTargetTwiceWHichPreviouslyPassed()
        {
            string[] targetsToBuild = new string[3] { "target1", "target2", "target1" };

            RequestDefinition request = new RequestDefinition(FullProjectPath("1.proj"), "2.0", targetsToBuild, null, 0, null, (IBuildComponentHost)_commonTests.Host);

            TargetDefinition target1 = new TargetDefinition("target1", request.ProjectDefinition.ProjectXmlDocument);
            TargetDefinition target2 = new TargetDefinition("target2", request.ProjectDefinition.ProjectXmlDocument);

            request.ProjectDefinition.AddTarget(target1);
            request.ProjectDefinition.AddTarget(target2);

            request.SubmitBuildRequest();

            request.WaitForResults();

            request.ValidateTargetEndResult("target1", TargetResultCode.Success, null);
            request.ValidateTargetEndResult("target2", TargetResultCode.Success, null);
        }
示例#28
0
        public void TaskStatusOnCancellation()
        {
            RequestDefinition r1 = new RequestDefinition(FullProjectPath("1.proj"), "4.0", null, null, 5000, null, (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition p1 = r1.ProjectDefinition;
            TargetDefinition t1 = new TargetDefinition(RequestDefinition.defaultTargetName, p1.ProjectXmlDocument);
            TaskDefinition ta1 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, p1.ProjectXmlDocument, TestUtilities.GetSuccessResult());

            t1.AddTask(ta1);
            p1.AddTarget(t1);

            r1.SubmitBuildRequest();
            ta1.WaitForTaskToStart();
            _commonTests.Host.ShutDownRequestEngine();

            r1.WaitForResultsThrowException();
        }
示例#29
0
        public void ValidateTargetOutput()
        {
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition project1 = test1.ProjectDefinition;
            TargetDefinition target1 = new TargetDefinition("Target1", null, "Foo", null, project1.ProjectXmlDocument);

            project1.AddTarget(target1);

            test1.SubmitBuildRequest();

            test1.WaitForResults();
            test1.ValidateTargetEndResult("Target1", TargetResultCode.Success, new string[1] { "Foo" });
        }
示例#30
0
        public void DependentTargetsDependOnTheSameTarget3()
        {
            string[] targetsToBuild = new string[1] { "target1" };

            RequestDefinition request = new RequestDefinition(FullProjectPath("1.proj"), "2.0", targetsToBuild, null, 0, null, (IBuildComponentHost)_commonTests.Host);

            TargetDefinition target1 = new TargetDefinition("target1", null, "target2;target3", request.ProjectDefinition.ProjectXmlDocument);
            TargetDefinition target2 = new TargetDefinition("target2", null, "target4", request.ProjectDefinition.ProjectXmlDocument);
            TargetDefinition target3 = new TargetDefinition("target3", null, "target2", request.ProjectDefinition.ProjectXmlDocument);
            TargetDefinition target4 = new TargetDefinition("target4", null, "target5", request.ProjectDefinition.ProjectXmlDocument);
            TargetDefinition target5 = new TargetDefinition("target5", request.ProjectDefinition.ProjectXmlDocument);

            request.ProjectDefinition.AddTarget(target1);
            request.ProjectDefinition.AddTarget(target2);
            request.ProjectDefinition.AddTarget(target3);
            request.ProjectDefinition.AddTarget(target4);
            request.ProjectDefinition.AddTarget(target5);

            request.SubmitBuildRequest();

            request.WaitForResults();

            request.ValidateTargetEndResult("target1", TargetResultCode.Success, null);
            request.ValidateNonPrimaryTargetEndResult("target2", TargetResultCode.Success, null);
            request.ValidateNonPrimaryTargetEndResult("target3", TargetResultCode.Success, null);
            request.ValidateNonPrimaryTargetEndResult("target4", TargetResultCode.Success, null);
            request.ValidateNonPrimaryTargetEndResult("target5", TargetResultCode.Success, null);
        }
示例#31
0
        public void BuildProjectWith1TargetWhichDependsOn1TargetWhichErrors()
        {
            ProjectDefinition project1 = new ProjectDefinition(FullProjectPath("1.proj"));
            TargetDefinition target1 = new TargetDefinition("Target1", null, "Target2", project1.ProjectXmlDocument);
            TargetDefinition target2 = new TargetDefinition("Target2", null, project1.ProjectXmlDocument);
            TaskDefinition task1 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition task2 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetStopWithErrorResult());
            target1.AddTask(task1);
            target2.AddTask(task2);
            project1.AddTarget(target1);
            project1.AddTarget(target2);
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] { "Target1" }, null, 100, null, (IBuildComponentHost)_commonTests.Host);
            test1.ProjectDefinition = project1;

            test1.SubmitBuildRequest();

            task2.WaitForTaskToComplete();
            test1.WaitForResults();

            test1.ValidateNonPrimaryTargetEndResult("Target2", TargetResultCode.Failure, null);
            test1.ValidateTargetEndResult("Target1", TargetResultCode.Failure, null);
        }
示例#32
0
        public void BuildDependentTargetWithFalseCondition()
        {
            ProjectDefinition project1 = new ProjectDefinition(FullProjectPath("1.proj"));
            TargetDefinition target1 = new TargetDefinition("Target1", null, "Target2", project1.ProjectXmlDocument);
            TargetDefinition target2 = new TargetDefinition("Target2", @"'1' == '2'", project1.ProjectXmlDocument);
            TaskDefinition task1 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition task2 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            target1.AddTask(task1);
            target2.AddTask(task2);
            project1.AddTarget(target1);
            project1.AddTarget(target2);
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] { "Target1" }, null, 100, null, (IBuildComponentHost)this.commonTests.Host);
            test1.ProjectDefinition = project1;

            test1.SubmitBuildRequest();

            task1.WaitForTaskToComplete();
            test1.WaitForResults();
            test1.ValidateTargetBuilt("Target1");
            test1.ValidateNonPrimaryTargetEndResult("Target2", TargetResultCode.Skipped, null);
            test1.ValidateTargetEndResult("Target1", TargetResultCode.Success, null);
        }
示例#33
0
        public void TargetDependencyChain2()
        {
            ProjectDefinition project1 = new ProjectDefinition(FullProjectPath("1.proj"));
            TargetDefinition target1 = new TargetDefinition("Target1", null, "Target2;Target3", project1.ProjectXmlDocument);
            TargetDefinition target2 = new TargetDefinition("Target2", null, null, project1.ProjectXmlDocument);
            TargetDefinition target3 = new TargetDefinition("Target3", null, "Target4", project1.ProjectXmlDocument);
            TargetDefinition target4 = new TargetDefinition("Target4", null, null, project1.ProjectXmlDocument);
            TaskDefinition task1 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition task2 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition task3 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            TaskDefinition task4 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), "2.0", new string[1] { "Target1" }, null, 100, null, (IBuildComponentHost)_commonTests.Host);
            target1.AddTask(task1);
            target2.AddTask(task2);
            target3.AddTask(task3);
            target4.AddTask(task4);
            project1.AddTarget(target1);
            project1.AddTarget(target2);
            project1.AddTarget(target3);
            project1.AddTarget(target4);
            test1.ProjectDefinition = project1;

            test1.SubmitBuildRequest();

            task2.WaitForTaskToComplete();
            task4.WaitForTaskToComplete();
            task3.WaitForTaskToComplete();
            task1.WaitForTaskToComplete();
            test1.WaitForResults();

            test1.ValidateTargetEndResult("Target1", TargetResultCode.Success, null);
            test1.ValidateNonPrimaryTargetEndResult("Target2", TargetResultCode.Success, null);
            test1.ValidateNonPrimaryTargetEndResult("Target3", TargetResultCode.Success, null);
            test1.ValidateNonPrimaryTargetEndResult("Target4", TargetResultCode.Success, null);
        }
示例#34
0
        public void Build1ProjectWith1TargetWhereTheTaskFail()
        {
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition project1 = test1.ProjectDefinition;
            TargetDefinition target1 = new TargetDefinition(RequestDefinition.defaultTargetName, null, project1.ProjectXmlDocument);
            TaskDefinition task1 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetStopWithErrorResult());
            target1.AddTask(task1);
            project1.AddTarget(target1);

            test1.SubmitBuildRequest();

            test1.WaitForResults();
            test1.ValidateTargetBuilt(RequestDefinition.defaultTargetName);
            test1.ValidateTargetEndResult(RequestDefinition.defaultTargetName, TargetResultCode.Failure, null);
        }
示例#35
0
        public void Build1ProjectWith1TargetWhereConditionIsFasle()
        {
            RequestDefinition test1 = new RequestDefinition(FullProjectPath("1.proj"), (IBuildComponentHost)_commonTests.Host);
            ProjectDefinition project1 = test1.ProjectDefinition;
            TargetDefinition target1 = new TargetDefinition(RequestDefinition.defaultTargetName, @"'1' == '2'", project1.ProjectXmlDocument);
            TaskDefinition task1 = new TaskDefinition(RequestDefinition.defaultTaskName, null, false, project1.ProjectXmlDocument, TestUtilities.GetSuccessResult());
            target1.AddTask(task1);
            project1.AddTarget(target1);

            test1.SubmitBuildRequest();

            test1.WaitForResults();
            test1.ValidateTargetEndResult(RequestDefinition.defaultTargetName, TargetResultCode.Skipped, null);
        }