public void TestConstructorBad2() { Assert.Throws <ArgumentNullException>(() => { FullyQualifiedBuildRequest request = new FullyQualifiedBuildRequest(new BuildRequestConfiguration(new BuildRequestData("foo", new Dictionary <string, string>(), "tools", new string[0], null), "2.0"), null, true); } ); }
public void TestConstructorBad1() { Assert.Throws <ArgumentNullException>(() => { FullyQualifiedBuildRequest request = new FullyQualifiedBuildRequest(null, new string[1] { "foo" }, true); } ); }
public void TestProperties() { BuildRequestData data = new BuildRequestData("foo", new Dictionary <string, string>(), "tools", new string[0], null); BuildRequestConfiguration config = new BuildRequestConfiguration(data, "2.0"); FullyQualifiedBuildRequest request = new FullyQualifiedBuildRequest(config, new string[1] { "foo" }, true); Assert.Equal(request.Config, config); Assert.Single(request.Targets); Assert.Equal("foo", request.Targets[0]); Assert.True(request.ResultsNeeded); }
public void TestConstructorGood() { BuildRequestData data1 = new BuildRequestData("foo", new Dictionary <string, string>(), "tools", Array.Empty <string>(), null); FullyQualifiedBuildRequest request = new FullyQualifiedBuildRequest(new BuildRequestConfiguration(data1, "2.0"), new string[1] { "foo" }, true); request = new FullyQualifiedBuildRequest(new BuildRequestConfiguration(data1, "2.0"), Array.Empty <string>(), true); BuildRequestData data3 = new BuildRequestData("foo", new Dictionary <string, string>(), "tools", Array.Empty <string>(), null); request = new FullyQualifiedBuildRequest(new BuildRequestConfiguration(data1, "2.0"), Array.Empty <string>(), false); }
public void TestRequestWithReferenceCancelled() { BuildRequestConfiguration configuration = CreateTestProject(1); try { TestTargetBuilder targetBuilder = (TestTargetBuilder)_host.GetComponent(BuildComponentType.TargetBuilder); IConfigCache configCache = (IConfigCache)_host.GetComponent(BuildComponentType.ConfigCache); FullyQualifiedBuildRequest[] newRequest = new FullyQualifiedBuildRequest[1] { new FullyQualifiedBuildRequest(configuration, new string[1] { "testTarget2" }, true) }; targetBuilder.SetNewBuildRequests(newRequest); configCache.AddConfiguration(configuration); BuildRequest request = CreateNewBuildRequest(1, new string[1] { "target1" }); BuildRequestEntry entry = new BuildRequestEntry(request, configuration); BuildResult result = new BuildResult(request); result.AddResultsForTarget("target1", GetEmptySuccessfulTargetResult()); targetBuilder.SetResultsToReturn(result); _requestBuilder.BuildRequest(GetNodeLoggingContext(), entry); WaitForEvent(_newBuildRequestsEvent, "New Build Requests"); Assert.Equal(_newBuildRequests_Entry, entry); ObjectModelHelpers.AssertArrayContentsMatch(_newBuildRequests_FQRequests, newRequest); BuildResult newResult = new BuildResult(_newBuildRequests_BuildRequests[0]); newResult.AddResultsForTarget("testTarget2", GetEmptySuccessfulTargetResult()); entry.ReportResult(newResult); _requestBuilder.ContinueRequest(); Thread.Sleep(500); _requestBuilder.CancelRequest(); WaitForEvent(_buildRequestCompletedEvent, "Build Request Completed"); Assert.Equal(BuildRequestEntryState.Complete, entry.State); Assert.Equal(entry, _buildRequestCompleted_Entry); Assert.Equal(BuildResultCode.Failure, _buildRequestCompleted_Entry.Result.OverallResult); } finally { DeleteTestProject(configuration); } }
/// <summary> /// Thread to process the build request /// </summary> private void BuilderThreadProc() { bool completeSuccess = true; WaitHandle[] handles = new WaitHandle[2] { cancelEvent, continueEvent }; this.threadStarted.Set(); // Add a request for each of the referenced projects. All we need to do is to make sure that the new project definition for the referenced // project has been added to the host collection FullyQualifiedBuildRequest[] fq = new FullyQualifiedBuildRequest[this.currentProjectDefinition.ChildDefinitions.Count]; int fqCount = 0; foreach (RequestDefinition childDefinition in this.currentProjectDefinition.ChildDefinitions) { BuildRequestConfiguration unresolvedConfig = childDefinition.UnresolvedConfiguration; fq[fqCount++] = new FullyQualifiedBuildRequest(unresolvedConfig, childDefinition.TargetsToBuild, true); } try { // Check to see if there was a cancel before we do anything if (cancelEvent.WaitOne(1, false)) { HandleCancel(); return; } // Submit the build request for the references if we have any if (fqCount > 0) { OnNewBuildRequests(this.requestedEntry, fq); // Wait for all of them to complete till our entry is marked ready int evt = WaitHandle.WaitAny(handles); // If a cancel occurs then we are done. Set the result to an exception if (evt == 0) { HandleCancel(); return; } // If we get a continue then one of the reference has complete. Set the result in the cache only in case of success. // Even though there may have been error - we cannot abandone the loop as there are already // requests in progress which may call back to this thread else if (evt == 1) { IDictionary <int, BuildResult> results = requestedEntry.Continue(); foreach (BuildResult configResult in results.Values) { if (configResult.OverallResult == BuildResultCode.Failure) { completeSuccess = false; } else { this.resultsCache.AddResult(configResult); } } } } // Check to see if there was a cancel we process the final result if (cancelEvent.WaitOne(1, false)) { HandleCancel(); return; } // Simulate execution time for the actual entry if one was specified and if the entry built successfully if (this.currentProjectDefinition.ExecutionTime > 0 && completeSuccess == true) { Thread.Sleep(this.currentProjectDefinition.ExecutionTime); } // Create and send the result BuildResult result = new BuildResult(requestedEntry.Request); // No specific target was asked to build. Return the default result if (requestedEntry.Request.Targets.Count == 0) { result.AddResultsForTarget(RequestDefinition.defaultTargetName, new TargetResult(new TaskItem[1], completeSuccess ? TestUtilities.GetSuccessResult() : TestUtilities.GetStopWithErrorResult())); } else { foreach (string target in requestedEntry.Request.Targets) { result.AddResultsForTarget(target, new TargetResult(new TaskItem[1], completeSuccess ? TestUtilities.GetSuccessResult() : TestUtilities.GetStopWithErrorResult())); } } this.resultsCache.AddResult(result); this.requestedEntry.Complete(result); RaiseRequestComplete(this.requestedEntry); return; } catch (Exception e) { if (this.requestedEntry != null) { string message = String.Format("Test: Unhandeled exception occured: \nMessage: {0} \nStack:\n{1}", e.Message, e.StackTrace); BuildResult errorResult = new BuildResult(this.requestedEntry.Request, new InvalidOperationException(message)); this.requestedEntry.Complete(errorResult); RaiseRequestComplete(this.requestedEntry); } } }
public void TestConstructorBad2() { FullyQualifiedBuildRequest request = new FullyQualifiedBuildRequest(new BuildRequestConfiguration(new BuildRequestData("foo", new Dictionary <string, string>(), "tools", new string[0], null), "2.0"), null, true); }
public void TestConstructorBad1() { FullyQualifiedBuildRequest request = new FullyQualifiedBuildRequest(null, new string[1] { "foo" }, true); }