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);
        }
Example #2
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);
        }
        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 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);
        }
Example #5
0
        /// <summary>
        /// Send a build request for a project with 1 target and validate the results. The results validated are the events
        /// raised by the build request engine, the results that was generated by the mock request builder and the cache contents
        /// </summary>
        public void BuildOneProject()
        {
            RequestDefinition p1 = CreateNewRequest("1.proj");

            p1.SubmitBuildRequest();
            p1.ValidateBuildResult();
        }
Example #6
0
        public void Build1ProjectWith1Target()
        {
            RequestDefinition p1 = CreateRequestDefinition("1.proj", null, null, 0);

            p1.SubmitBuildRequest();
            p1.ValidateBuildResult();
        }
Example #7
0
        public void CircularDependencyChain4()
        {
            string projectFileContents = String.Format(ObjectModelHelpers.CleanupFileContents(
                                                           @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
                            <UsingTask TaskName='QAMockTaskForIntegrationTests' AssemblyFile='{0}' />

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

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

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

                        </Project>"),
                                                       _assemblyPath);

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

            r1.SubmitBuildRequest();

            r1.WaitForResultsThrowException();
        }
        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);
        }
Example #9
0
        public void OnErrorTargetInvolvingDefaultTarget()
        {
            string projectFileContents = String.Format(ObjectModelHelpers.CleanupFileContents(
                                                           @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace' DefaultTargets='t1'>
                            <UsingTask TaskName='QAMockTaskForIntegrationTests' AssemblyFile='{0}' />

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

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

                        </Project>"),
                                                       _assemblyPath);

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

            r1.SubmitBuildRequest();

            r1.WaitForResults();

            r1.ValidateTargetEndResult("t1", TargetResultCode.Failure, null);
            r1.ValidateNonPrimaryTargetEndResult("t2", TargetResultCode.Success, null);
        }
Example #10
0
        [Ignore] // "Cannot use a project instance if the project is created from a file."
        public void OutputFromTaskUpdatesProperty()
        {
            string projectFileContents = String.Format(ObjectModelHelpers.CleanupFileContents(
                                                           @"<Project ToolsVersion='msbuilddefaulttoolsversion' xmlns='msbuildnamespace'>
                            <UsingTask TaskName='QAMockTaskForIntegrationTests' AssemblyFile='{0}' />

                            <PropertyGroup>
                                <SomeProperty>oldvalue</SomeProperty>
                            </PropertyGroup>

                            <Target Name='t'>
                                <QAMockTaskForIntegrationTests ExpectedOutput='Foo' TaskShouldThrowException='false'>
                                    <Output TaskParameter='TaskOutput' PropertyName='SomeProperty'/>
                                </QAMockTaskForIntegrationTests>
                            </Target>
                        </Project>"),
                                                       _assemblyPath);

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

            r1.SubmitBuildRequest();

            r1.WaitForResults();
            ProjectPropertyInstance property = projectInstance.GetProperty("SomeProperty");

            Assert.IsTrue(property.EvaluatedValue == "Foo", "SomeProperty=Foo");
        }
Example #11
0
        public void Build4ProjectWith4Targets()
        {
            RequestDefinition p1 = CreateRequestDefinition("1.proj", new string[4] {
                "target1", "target2", "target3", "target4"
            }, null, 0);
            RequestDefinition p2 = CreateRequestDefinition("2.proj", new string[4] {
                "target1", "target2", "target3", "target4"
            }, null, 0);
            RequestDefinition p3 = CreateRequestDefinition("3.proj", new string[4] {
                "target1", "target2", "target3", "target4"
            }, null, 0);
            RequestDefinition p4 = CreateRequestDefinition("4.proj", new string[4] {
                "target1", "target2", "target3", "target4"
            }, null, 0);

            p1.SubmitBuildRequest();
            p1.ValidateBuildResult();

            p2.SubmitBuildRequest();
            p2.ValidateBuildResult();

            p3.SubmitBuildRequest();
            p3.ValidateBuildResult();

            p4.SubmitBuildRequest();
            p4.ValidateBuildResult();
        }
Example #12
0
        /// <summary>
        /// Submit 3 build request where first one has multiple references and last has multiple references. Some of the references are built with different global properties
        /// </summary>
        public void BuildMultipleProjectsWithReferencesAndDifferentGlobalProperties()
        {
            ProjectPropertyInstance prop1 = ProjectPropertyInstance.Create("prop1", "Value1");
            ProjectPropertyInstance prop2 = ProjectPropertyInstance.Create("prop2", "Value2");
            PropertyDictionary <ProjectPropertyInstance> group1 = new PropertyDictionary <ProjectPropertyInstance>();

            group1.Set(prop1);
            PropertyDictionary <ProjectPropertyInstance> group2 = new PropertyDictionary <ProjectPropertyInstance>();

            group2.Set(prop2);

            RequestDefinition p1 = CreateNewRequest("1.proj");
            RequestDefinition p2 = CreateNewRequest("2.proj");
            RequestDefinition p3 = CreateNewRequest("3.proj");
            RequestDefinition p4 = CreateNewRequest("4.proj");
            RequestDefinition p5 = CreateNewRequest("2.proj", group1);
            RequestDefinition p6 = CreateNewRequest("6.proj");
            RequestDefinition p7 = CreateNewRequest("2.proj", group2);

            p1.AddChildDefinition(p4);
            p1.AddChildDefinition(p5);
            p3.AddChildDefinition(p6);
            p3.AddChildDefinition(p7);

            p1.SubmitBuildRequest();
            p1.ValidateBuildResult();

            p2.SubmitBuildRequest();
            p2.ValidateBuildResult();

            p3.SubmitBuildRequest();
            p3.ValidateBuildResult();
        }
Example #13
0
        /// <summary>
        /// A new build request from the node for a project which was already previously built in that node but for a different global properties
        /// </summary>
        public void ReferenceAProjectAlreadyBuiltInTheNodeButWithDifferentGlobalProperties()
        {
            ProjectPropertyInstance prop1 = ProjectPropertyInstance.Create("prop1", "Value1");
            ProjectPropertyInstance prop2 = ProjectPropertyInstance.Create("prop2", "Value2");
            PropertyDictionary <ProjectPropertyInstance> group1 = new PropertyDictionary <ProjectPropertyInstance>();

            group1.Set(prop1);
            PropertyDictionary <ProjectPropertyInstance> group2 = new PropertyDictionary <ProjectPropertyInstance>();

            group2.Set(prop2);

            RequestDefinition p1 = CreateNewRequest("1.proj", "2.0", new string[1] {
                "t1"
            }, group1);
            RequestDefinition p2 = CreateNewRequest("2.proj");
            RequestDefinition p3 = CreateNewRequest("1.proj", "2.0", new string[1] {
                "t1"
            }, group2);

            p2.AddChildDefinition(p3);

            p1.SubmitBuildRequest();
            p1.ValidateBuildResult();

            p2.SubmitBuildRequest();
            p2.ValidateBuildResult();
        }
Example #14
0
 /// <summary>
 /// Shuts down the component.
 /// </summary>
 public void ShutdownComponent()
 {
     this.host                  = null;
     this.testDataProvider      = null;
     this.testDefinition        = null;
     this.requestCallBack       = null;
     this.requestEntry          = null;
     this.projectLoggingContext = null;
 }
Example #15
0
        public void Build1ProjectWith4Targets()
        {
            RequestDefinition p1 = CreateRequestDefinition("1.proj", new string[4] {
                "target1", "target2", "target3", "target4"
            }, null, 0);

            p1.SubmitBuildRequest();
            p1.ValidateBuildResult();
        }
Example #16
0
 public QAMockTargetBuilder()
 {
     _host = null;
     _testDataProvider = null;
     _testDefinition = null;
     _requestCallBack = null;
     _requestEntry = null;
     _projectLoggingContext = null;
     _buildDone = new AutoResetEvent(false);
 }
Example #17
0
        /// <summary>
        /// Submit 1 build request which has a single reference
        /// </summary>
        public void BuildOneProjectWith1Reference()
        {
            RequestDefinition p1 = CreateNewRequest("1.proj");
            RequestDefinition p2 = CreateNewRequest("2.proj");

            p1.AddChildDefinition(p2);

            p1.SubmitBuildRequest();
            p1.ValidateBuildResult();
        }
Example #18
0
 public QAMockTargetBuilder()
 {
     this.host                  = null;
     this.testDataProvider      = null;
     this.testDefinition        = null;
     this.requestCallBack       = null;
     this.requestEntry          = null;
     this.projectLoggingContext = null;
     this.buildDone             = new AutoResetEvent(false);
 }
Example #19
0
        /// <summary>
        /// Builds the specified targets of an entry. The cancel event should only be set to true if we are planning
        /// on simulating execution time when a target is built
        /// </summary>
        public Task <BuildResult> BuildTargets(ProjectLoggingContext loggingContext, BuildRequestEntry entry, IRequestBuilderCallback callback, string[] targetNames, Lookup baseLookup, CancellationToken cancellationToken)
        {
            this.requestEntry          = entry;
            this.projectLoggingContext = loggingContext;
            this.requestCallBack       = callback;
            this.testDefinition        = this.testDataProvider[entry.Request.ConfigurationId];
            this.cancellationToken     = cancellationToken;
            BuildResult result = GenerateResults(targetNames);

            return(Task <BuildResult> .FromResult(result));
        }
Example #20
0
        public void TestCancellingRequest()
        {
            RequestDefinition p1 = CreateRequestDefinition("1.proj", null, null, 0);

            p1.WaitForCancel = true;
            p1.SubmitBuildRequest();

            this.commonTests.Host.AbortBuild();

            p1.ValidateBuildAbortedResult();
        }
Example #21
0
        /// <summary>
        /// Build the same project twice with different tools version
        /// </summary>
        public void BuildingTheSameProjectTwiceWithDifferentToolsVersion()
        {
            RequestDefinition p1 = CreateNewRequest("1.proj", "2.0");
            RequestDefinition p2 = CreateNewRequest("1.proj", "3.5");

            p1.SubmitBuildRequest();
            p1.ValidateBuildResult();

            p2.SubmitBuildRequest();
            p2.ValidateBuildResult();
        }
Example #22
0
 /// <summary>
 /// Constructor that takes in nothing.
 /// </summary>
 public QARequestBuilder()
 {
     this.host                     = null;
     this.configCache              = null;
     this.resultsCache             = null;
     this.builderThread            = null;
     this.requestedEntry           = null;
     this.cancelEvent              = new AutoResetEvent(false);
     this.continueEvent            = new AutoResetEvent(false);
     this.threadStarted            = new ManualResetEvent(false);
     this.currentProjectDefinition = null;
 }
Example #23
0
 /// <summary>
 /// Constructor that takes in nothing.
 /// </summary>
 public QARequestBuilder()
 {
     _host = null;
     _configCache = null;
     _resultsCache = null;
     _builderThread = null;
     _requestedEntry = null;
     _cancelEvent = new AutoResetEvent(false);
     _continueEvent = new AutoResetEvent(false);
     _threadStarted = new ManualResetEvent(false);
     _currentProjectDefinition = null;
 }
Example #24
0
        /// <summary>
        /// A new build request from the node of a project which was already previously built in that node
        /// </summary>
        public void ReferenceAProjectAlreadyBuiltInTheNode()
        {
            RequestDefinition p1 = CreateNewRequest("1.proj");
            RequestDefinition p2 = CreateNewRequest("2.proj");

            p2.AddChildDefinition(p1);

            p1.SubmitBuildRequest();
            p1.ValidateBuildResult();

            p2.SubmitBuildRequest();
            p2.ValidateBuildResult();
        }
Example #25
0
        /// <summary>
        /// Submit 1 build request which has 3 reference where 2 are the same
        /// UNDONE: This test will fail due to a bug where 3.proj is added 2 times in the unresolvedConfigurations list thus causing a hang
        /// </summary>
        public void BuildOneProjectWith3ReferenceWhere2AreTheSame()
        {
            RequestDefinition p1 = CreateNewRequest("1.proj");
            RequestDefinition p2 = CreateNewRequest("2.proj");
            RequestDefinition p3 = CreateNewRequest("3.proj");
            RequestDefinition p4 = CreateNewRequest("3.proj");

            p1.AddChildDefinition(p2);
            p1.AddChildDefinition(p3);
            p1.AddChildDefinition(p4);

            p1.SubmitBuildRequest();
            p1.ValidateBuildResult();
        }
Example #26
0
        /// <summary>
        /// Adds a new configuration to the configuration cache if one is not already there.
        /// Some times this method can be called twice specially when 2 request contains the same project
        /// where one is a request from the engine (building a reference) and 1 is a request from the test.
        /// If the configuration already exists in the cache then we will just use that.
        /// </summary>
        public BuildRequestConfiguration CreateConfiguration(RequestDefinition definition)
        {
            BuildRequestConfiguration unresolvedConfig = definition.UnresolvedConfiguration;
            BuildRequestConfiguration newConfig        = this.configurationCache.GetMatchingConfiguration(unresolvedConfig);

            if (newConfig == null)
            {
                int newId = GetIdForUnresolvedConfiguration(unresolvedConfig);
                newConfig = new BuildRequestConfiguration(newId, new BuildRequestData(definition.FileName, definition.GlobalProperties.ToDictionary(), definition.ToolsVersion, new string[0], null), "2.0");
                this.configurationCache.AddConfiguration(newConfig);
                newConfig.Project = definition.ProjectDefinition.GetMSBuildProjectInstance();
            }

            return(newConfig);
        }
        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 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 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();
        }
        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);
        }
        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();
        }
Example #32
0
        /// <summary>
        /// Submit 3 build request where project 3 has a reference to Project 1
        /// </summary>
        public void Build3ProjectsWhere3HasAReferenceTo1()
        {
            RequestDefinition p1 = CreateNewRequest("1.proj", "2.0");
            RequestDefinition p2 = CreateNewRequest("2.proj", "2.0");
            RequestDefinition p3 = CreateNewRequest("3.proj", "2.0");

            p3.AddChildDefinition(p1);

            p1.SubmitBuildRequest();
            p1.ValidateBuildResult();

            p2.SubmitBuildRequest();
            p2.ValidateBuildResult();

            p3.SubmitBuildRequest();
            p3.ValidateBuildResult();
        }
Example #33
0
 /// <summary>
 /// Adds a reference project to the listw
 /// </summary>
 public void AddChildDefinition(RequestDefinition project)
 {
     _childDefinitions.Add(project);
 }
Example #34
0
        /// <summary>
        /// Constructor allows you to set the filname, toolsversion, targets to build, build properties and execution time.
        /// Following are the defaults:
        /// ToolsVersion = "ToolsVersion"
        /// GlobalProperties = new BuildPropertyGroup()
        /// ExecutionTime = 0;
        /// Targets to build = "target1"
        /// </summary>
        public RequestDefinition(string fileName, string toolsVersion, string[] targets, PropertyDictionary<ProjectPropertyInstance> properties, int executionTime, RequestDefinition[] childDefinitions, IBuildComponentHost host, bool noTargetsToBuild)
        {
            if (noTargetsToBuild || targets == null)
            {
                _targetsToBuild = new string[] { };
            }
            else
            {
                _targetsToBuild = targets;
            }

            _globalProperties = ((properties == null) ? new PropertyDictionary<ProjectPropertyInstance>() : properties);
            _toolsVersion = ((toolsVersion == null) ? RequestDefinition.defaultToolsVersion : toolsVersion);
            _fileName = fileName;
            if (childDefinitions != null)
            {
                _childDefinitions = new List<RequestDefinition>(childDefinitions);
                foreach (RequestDefinition bd in childDefinitions)
                {
                    _childDefinitions.Add(bd);
                }
            }
            else
            {
                _childDefinitions = new List<RequestDefinition>();
            }

            _testProjectCompletedEvent = new AutoResetEvent(false);
            _executionTime = executionTime;
            _requestEngine = (IBuildRequestEngine)host.GetComponent(BuildComponentType.RequestEngine);
            _testDataProvider = (ITestDataProvider)host.GetComponent(BuildComponentType.TestDataProvider);
            _resultsCache = (IResultsCache)host.GetComponent(BuildComponentType.ResultsCache);
            _testDataProvider.AddDefinition(this);
            _projectDefinition = new ProjectDefinition(_fileName);
            _waitForCancel = false;
        }
Example #35
0
 /// <summary>
 /// Constructor which sets most of the data members except for the noTargetsToBuild bool parameter
 /// </summary>
 public RequestDefinition(string fileName, string toolsVersion, string[] targets, PropertyDictionary<ProjectPropertyInstance> properties, int executionTime, RequestDefinition[] childDefinitions, IBuildComponentHost host)
     : this(fileName, toolsVersion, targets, properties, executionTime, childDefinitions, host, false)
 {
 }
Example #36
0
 /// <summary>
 /// Constructor takes in the filename and an array of child definitions.
 /// </summary>
 public RequestDefinition(string fileName, RequestDefinition[] childDefinitions, IBuildComponentHost host)
     : this(fileName, null, null, null, 0, childDefinitions, host)
 {
 }
Example #37
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);
        }
Example #38
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);
        }
Example #39
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();
        }
Example #40
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);
        }
Example #41
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);
        }
Example #42
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" });
        }
Example #43
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);
        }
Example #44
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);
        }
Example #45
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);
        }
Example #46
0
        /// <summary>
        /// Adds a new definition to the cache. Returns the key associated with this definition so that it can be
        /// used as the configuration id also.
        /// </summary>
        public int AddDefinition(RequestDefinition definition)
        {
            int newKey;

            if (this.configurationCache.GetMatchingConfiguration(definition.UnresolvedConfiguration) != null)
            {
                throw new InvalidOperationException("Multiple request definition with the same configuration cannot be added");
            }
            else
            {
                lock (this.definitions)
                {
                    newKey = key++;
                    this.definitions.Add(newKey, definition);
                }
            }

            return newKey;
        }
Example #47
0
        /// <summary>
        /// Given a string containing the project file content return a RequestBuilder with all the information of the project
        /// populated.
        /// </summary>
        private RequestDefinition GetRequestUsingProject(string projectFileContents, string projectName, string targetName, out ProjectInstance project)
        {
            ProjectDefinition p1 = new ProjectDefinition(projectName);
            project = p1.MSBuildProjectInstance = GenerateProjectInstanceFromXml(projectFileContents);
            string[] targetNames = null;
            if (targetName != null)
            {
                targetNames = targetName.Split(';');
            }

            projectName = System.IO.Path.Combine(_tempPath, projectName);
            RequestDefinition r1 = new RequestDefinition(projectName, "2.0", targetNames, null, 0, null, (IBuildComponentHost)_commonTests.Host);
            r1.ProjectDefinition = p1;

            return r1;
        }
Example #48
0
        /// <summary>
        /// Adds a new configuration to the configuration cache if one is not already there.
        /// Some times this method can be called twice specially when 2 request contains the same project
        /// where one is a request from the engine (building a reference) and 1 is a request from the test. 
        /// If the configuration already exists in the cache then we will just use that.
        /// </summary>
        public BuildRequestConfiguration CreateConfiguration(RequestDefinition definition)
        {
            BuildRequestConfiguration unresolvedConfig = definition.UnresolvedConfiguration;
            BuildRequestConfiguration newConfig = this.configurationCache.GetMatchingConfiguration(unresolvedConfig);
            if (newConfig == null)
            {
                int newId = GetIdForUnresolvedConfiguration(unresolvedConfig);
                newConfig = new BuildRequestConfiguration(newId, new BuildRequestData(definition.FileName, definition.GlobalProperties.ToDictionary(), definition.ToolsVersion, new string[0], null), "2.0");
                this.configurationCache.AddConfiguration(newConfig);
                newConfig.Project = definition.ProjectDefinition.GetMSBuildProjectInstance();
            }

            return newConfig;
        }
Example #49
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);
        }
        /// <summary>
        /// Returns a new Request definition object created using the parameters passed in
        /// </summary>
        /// <param name="filename">Name of the project file in the request. This needs to be a rooted path</param>
        /// <param name="targets">Targets to build in that project file</param>
        /// <param name="toolsVersion">Tools version for that project file</param>
        /// <param name="executionTime">Simulated time the request should take to complete</param>
        private RequestDefinition CreateRequestDefinition(string filename, string[] targets, string toolsVersion, int executionTime)
        {
            if (targets == null)
            {
                targets = new string[1] { RequestDefinition.defaultTargetName };
            }

            if (toolsVersion == null)
            {
                toolsVersion = "2.0";
            }

            filename = System.IO.Path.Combine(_tempPath, filename);
            RequestDefinition request = new RequestDefinition(filename, toolsVersion, targets, null, executionTime, null, (IBuildComponentHost)_commonTests.Host);
            request.CreateMSBuildProject = true;

            return request;
        }
Example #51
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);
        }
Example #52
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;
        }
Example #53
0
 /// <summary>
 /// The component is shutting down
 /// </summary>
 public void ShutdownComponent()
 {
     _requestedEntry = null;
     _currentProjectDefinition = null;
 }
Example #54
0
        /// <summary>
        /// Builds the specified targets of an entry. The cancel event should only be set to true if we are planning
        /// on simulating execution time when a target is built
        /// </summary>
        public Task<BuildResult> BuildTargets(ProjectLoggingContext loggingContext, BuildRequestEntry entry, IRequestBuilderCallback callback, string[] targetNames, Lookup baseLookup, CancellationToken cancellationToken)
        {
            _requestEntry = entry;
            _projectLoggingContext = loggingContext;
            _requestCallBack = callback;
            _testDefinition = _testDataProvider[entry.Request.ConfigurationId];
            _cancellationToken = cancellationToken;
            BuildResult result = GenerateResults(targetNames);

            return Task<BuildResult>.FromResult(result);
        }
Example #55
0
        /// <summary>
        /// Build a request entry
        /// </summary>
        /// <param name="entry"></param>
        public void BuildRequest(NodeLoggingContext nodeLoggingContext, BuildRequestEntry entry)
        {
            _requestedEntry = entry;
            if (null == _requestedEntry.RequestConfiguration.Project)
            {
                Project mockProject = new Project(XmlReader.Create(new System.IO.StringReader(
@"<Project ToolsVersion='4.0' xmlns='http://schemas.microsoft.com/developer/msbuild/2003'>
            <Target Name='t'>
            </Target>
            </Project>")));
                _requestedEntry.RequestConfiguration.Project = mockProject.CreateProjectInstance();
            }

            _currentProjectDefinition = _testDataProvider[_requestedEntry.Request.ConfigurationId];
            _requestedEntry.Continue();
            _builderThread = new Thread(BuilderThreadProc);
            _builderThread.Name = "Builder Thread for Request: " + entry.Request.ConfigurationId.ToString();
            _builderThread.Start();
        }
Example #56
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);
        }
Example #57
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);
        }
Example #58
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();
        }
Example #59
0
 /// <summary>
 /// Shuts down the component.
 /// </summary>
 public void ShutdownComponent()
 {
     _host = null;
     _testDataProvider = null;
     _testDefinition = null;
     _requestCallBack = null;
     _requestEntry = null;
     _projectLoggingContext = null;
 }