Esempio n. 1
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);
        }
Esempio n. 2
0
        public void MultipleOnErrorTargetIsBuilt()
        {
            string projectFileContents = String.Format(ObjectModelHelpers.CleanupFileContents(
                                                           @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
                            <UsingTask TaskName='QAMockTaskForIntegrationTests' AssemblyFile='{0}' />

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

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

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

                        </Project>"),
                                                       _assemblyPath);

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

            r1.SubmitBuildRequest();

            r1.WaitForResults();

            r1.ValidateTargetEndResult("t1", TargetResultCode.Failure, null);
            r1.ValidateNonPrimaryTargetEndResult("t2", TargetResultCode.Success, null);
            r1.ValidateNonPrimaryTargetEndResult("t3", TargetResultCode.Success, null);
        }
Esempio n. 3
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);
        }
Esempio n. 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);
        }
Esempio n. 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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
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);
        }
Esempio n. 9
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);
        }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
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);
        }
Esempio n. 13
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);
        }