Пример #1
0
        public void OnErrorTargetIsATargetAlreadyBuilt()
        {
            string projectFileContents = String.Format(ObjectModelHelpers.CleanupFileContents(
                                                           @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
                            <UsingTask TaskName='QAMockTaskForIntegrationTests' AssemblyFile='{0}' />

                            <Target Name='t1'>
                                <QAMockTaskForIntegrationTests />
                            </Target>

                            <Target Name='t2' >
                                <QAMockTaskForIntegrationTests TaskShouldError='true' />
                                <OnError ExecuteTargets='t1' />
                            </Target>

                        </Project>"),
                                                       _assemblyPath);

            ProjectInstance   projectInstance = null;
            RequestDefinition r1 = GetRequestUsingProject(projectFileContents, "1.proj", "t1;t2", out projectInstance);

            r1.SubmitBuildRequest();

            r1.WaitForResults();

            r1.ValidateTargetEndResult("t1", TargetResultCode.Success, null);
            r1.ValidateTargetEndResult("t2", TargetResultCode.Failure, null);
        }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
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);
        }
Пример #5
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);
        }
Пример #6
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);
        }
Пример #7
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);
        }
Пример #8
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"
            });
        }
Пример #9
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);
        }
Пример #10
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);
        }
Пример #11
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);
        }
Пример #12
0
        public void OutputFromTarget()
        {
            string projectFileContents = String.Format(ObjectModelHelpers.CleanupFileContents(
                      @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
                            <UsingTask TaskName='QAMockTaskForIntegrationTests' AssemblyFile='{0}' />

                            <Target Name='t' Outputs='$(SomeProperty)'>
                                <QAMockTaskForIntegrationTests ExpectedOutput='Foo' TaskShouldThrowException='false'>
                                    <Output TaskParameter='TaskOutput' PropertyName='SomeProperty'/>
                                </QAMockTaskForIntegrationTests>
                            </Target>
                        </Project>"),
                        this.assemblyPath);

            ProjectInstance projectInstance = null;
            RequestDefinition r1 = GetRequestUsingProject(projectFileContents, "1.proj", "t", out projectInstance);

            r1.SubmitBuildRequest();

            r1.WaitForResults();
            r1.ValidateTargetEndResult("t", TargetResultCode.Success, new string[1] { "Foo" });
        }
Пример #13
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);
        }
Пример #14
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);
        }
Пример #15
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);
        }
Пример #16
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);
        }
Пример #17
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);
        }
Пример #18
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);
        }
Пример #19
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);
        }
Пример #20
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" });
        }
Пример #21
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);
        }
Пример #22
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);
        }
Пример #23
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);
        }
Пример #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 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);
        }
Пример #26
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);
        }