/// <summary> /// Checks if the target results are as expected. This method can only be called for targets may be built as a result of building /// the requested / default / initial targets /// </summary> public void ValidateNonPrimaryTargetEndResult(string targetName, TargetResultCode expectedResultCode, string[] items) { BuildResult result = this.resultsCache.GetResultForRequest(this.buildRequest); TargetResult targetResult = (TargetResult)result[targetName]; InternalValidateTargetEndResult(targetResult, expectedResultCode, items); }
/// <summary> /// Checks if the target results are as expected. /// </summary> private void InternalValidateTargetEndResult(TargetResult targetResult, TargetResultCode expectedResultCode, string[] items) { int foundCount = 0; Assert.AreEqual(expectedResultCode, targetResult.ResultCode, "Expected result is not the same as the received result"); if (items != null) { foreach (string item in items) { bool foundItemValue = false; foreach (ITaskItem i in targetResult.Items) { if (item == i.ItemSpec) { foundItemValue = true; foundCount++; break; } } Assert.IsTrue(foundItemValue, "Item not found in result"); } Assert.IsTrue(foundCount == items.Length, "Total items expected was not the same as what was received."); } }
/// <summary> /// Generate results for the targets requested to be built. Using the TestDataProvider also simulate any /// P2P callbacks on the first target. In order to test the cancels there is also functionality to allow the /// target execution to wait on a cancel event before exiting /// </summary> private BuildResult GenerateResults(string[] targetNames) { bool simulatedResults = false; BuildResult result = new BuildResult(this.requestEntry.Request); foreach (string target in targetNames) { if (!simulatedResults) { SimulateCallBacks(); simulatedResults = true; } // Wait for this to be cancelled if (this.testDefinition.WaitForCancel) { this.cancellationToken.WaitHandle.WaitOne(); this.buildDone.Set(); throw new BuildAbortedException(); } if (this.testDefinition.ExecutionTime > 0) { Thread.Sleep(this.testDefinition.ExecutionTime); } TaskItem[] items = new TaskItem[] { new TaskItem("itemValue", this.requestEntry.RequestConfiguration.ProjectFullPath) }; TargetResult targetResult = new TargetResult(items, TestUtilities.GetSuccessResult()); result.AddResultsForTarget(target, targetResult); } buildDone.Set(); return(result); }
/// <summary> /// When a target build fails, we don't just stop building that target; we also pop all of the other dependency targets of its /// parent target off the stack. Extract that logic into a standalone method so that it can be used when dealing with targets that /// are skipped-unsuccessful as well as first-time failures. /// </summary> private void PopDependencyTargetsOnTargetFailure(TargetEntry topEntry, TargetResult targetResult, ref bool stopProcessingStack) { if (targetResult.WorkUnitResult.ActionCode == WorkUnitActionCode.Stop) { // Pop down to our parent, since any other dependencies our parent had should no longer // execute. If we encounter an error target on the way down, also stop since the failure // of one error target in a set declared in OnError should not cause the others to stop running. while ((!_targetsToBuild.IsEmpty) && (_targetsToBuild.Peek() != topEntry.ParentEntry) && !_targetsToBuild.Peek().ErrorTarget) { TargetEntry entry = _targetsToBuild.Pop(); entry.LeaveLegacyCallTargetScopes(); // This target is no longer actively building (if it was). _requestEntry.RequestConfiguration.ActivelyBuildingTargets.Remove(topEntry.Name); // If we come across an entry which requires us to stop processing (for instance, an aftertarget of the original // CallTarget target) then we need to use that flag, not the one from the top entry. if (entry.StopProcessingOnCompletion) { stopProcessingStack = true; } } // Mark our parent for error execution if (topEntry.ParentEntry != null && topEntry.ParentEntry.State != TargetEntryState.Completed) { topEntry.ParentEntry.MarkForError(); } } }
/// <summary> /// </summary> /// <param name="sender"> </param> /// <param name="e"> </param> private void ScanTimerElapsed(object sender, ElapsedEventArgs e) { if (this._isScanning) { return; } this._isScanning = true; double refresh = 100; if (double.TryParse(Settings.Default.TargetWorkerRefresh.ToString(CultureInfo.InvariantCulture), out refresh)) { this._scanTimer.Interval = refresh; } Func <bool> scanner = delegate { TargetResult readResult = Reader.GetTargetInfo(); AppContextHelper.Instance.RaiseTargetInfoUpdated(readResult.TargetInfo); this._isScanning = false; return(true); }; scanner.BeginInvoke(delegate { }, scanner); }
public void AddTargetResult(string targetName, TargetResult targetResult) { if (!Result.HasResultsForTarget(targetName)) { Result.AddResultsForTarget(targetName, targetResult); } }
public override ITargetResult Send(TestResult testResult, Action<object> outputProcessor, params object[] inputArgs) { TargetResult result = new TargetResult() { Sent = false }; // get the items that need to be scored List<ItemResponse> itemsToScore = GetItemsToScore(testResult); int updatedCount = 0; if (itemsToScore.Count > 0) { //write the items that will be scored to TestOpportunityItemScore table updatedCount = DAL.TISScoreMergerDAL.UpdateItemsToScore(testResult, itemsToScore, ItemScoringConfigManager.Instance.GetItemScoringConfig(base.Name).ScoreInvalidations, ItemScoringConfigManager.Instance.GetItemScoringConfig(base.Name).BatchRequest, ItemScoringConfigManager.Instance.GetItemScoringConfig(base.Name).UpdateSameReportingVersion, ItemScoringConfigManager.Instance.GetItemScoringConfig(base.Name).IsHandscoringTarget); result.Sent = true; } // allow the count of items actually updated in the db to be evaluated by the caller if (outputProcessor != null) outputProcessor(updatedCount); return result; }
private void FillResponseInfos(int Index) { listViewResponseHeaders.Items.Clear(); richTextBoxSource.Text = ""; webBrowserSource.Navigate("about:blank"); listViewResponseHeadersHTTPs.Items.Clear(); richTextBoxSourceHTTPs.Text = ""; webBrowserSourceHTTPs.Navigate("about:blank"); TargetResult Result = serverFinder.Results[Index]; richTextBoxSource.Text = Result.Html; webBrowserSource.Navigate(Result.Url); for (int i = 0; i < Result.ResponseHeaders.Count; i++) { ListViewItem Item = new ListViewItem(); Item.Text = Result.ResponseHeaders.Keys[i]; string Value = string.Empty; string[] HeaderValues = Result.ResponseHeaders.GetValues(i); for (int iHv = 0; iHv < HeaderValues.Length; iHv++) { Value += HeaderValues[iHv] + " "; } Item.SubItems.Add(Value); listViewResponseHeaders.Items.Add(Item); } }
public void TestConstructorNoItems() { TargetResult result = new TargetResult(new TaskItem[] { }, BuildResultUtilities.GetStopWithErrorResult()); Assert.Empty(result.Items); Assert.Null(result.Exception); Assert.Equal(TargetResultCode.Failure, result.ResultCode); }
public void TestConstructorNullItems() { Assert.Throws <ArgumentNullException>(() => { TargetResult result = new TargetResult(null, BuildResultUtilities.GetStopWithErrorResult()); } ); }
public TargetViewModel(string displayName, TargetResult source, bool?available = null) { DisplayName = displayName; Source = source; Name = source.Name; Version = source.LongVersion; Available = available; }
public void TestConstructorNoItems() { TargetResult result = new TargetResult(new TaskItem[] { }, TestUtilities.GetStopWithErrorResult()); Assert.AreEqual(0, result.Items.Length); Assert.IsNull(result.Exception); Assert.AreEqual(TargetResultCode.Failure, result.ResultCode); }
public void TestConstructorWithItems() { TaskItem item = new TaskItem("foo", "bar.proj"); TargetResult result = new TargetResult(new TaskItem[] { item }, TestUtilities.GetStopWithErrorResult()); Assert.AreEqual(1, result.Items.Length); Assert.AreEqual(item.ItemSpec, result.Items[0].ItemSpec); Assert.AreEqual(TargetResultCode.Failure, result.ResultCode); }
public void TestConstructorWithExceptionNull() { TaskItem item = new TaskItem("foo", "bar.proj"); TargetResult result = new TargetResult(new TaskItem[] { item }, BuildResultUtilities.GetStopWithErrorResult()); Assert.Single(result.Items); Assert.Null(result.Exception); Assert.Equal(TargetResultCode.Failure, result.ResultCode); }
public void TestConstructorWithExceptionNull() { TaskItem item = new TaskItem("foo", "bar.proj"); TargetResult result = new TargetResult(new TaskItem[] { item }, TestUtilities.GetStopWithErrorResult()); Assert.AreEqual(1, result.Items.Length); Assert.IsNull(result.Exception); Assert.AreEqual(TargetResultCode.Failure, result.ResultCode); }
private async Task NotifyDirectorRemoveTargetResult(Guid sessionId, TargetResult targetResult) { var session = await GetSession(sessionId); if (!string.IsNullOrEmpty(session.Director.ConnectionId)) { await _sessionHub.Clients.Client(session.Director.ConnectionId) .RemoveTargetResult(targetResult.TargetId, targetResult.ParticipantId); } }
public void ParseQuantity_Returns_Valid_Number(string firstParam, int expectedValue) { var result = new TargetResult { FirstParameter = firstParam }; var quantity = TargetLocation.ParseQuantity(result).Quantity; quantity.Should().Be(expectedValue); }
public void TestConstructorWithException() { TaskItem item = new TaskItem("foo", "bar.proj"); TargetResult result = new TargetResult(new TaskItem[] { item }, TestUtilities.GetStopWithErrorResult(new ArgumentException())); Assert.Equal(1, result.Items.Length); Assert.NotNull(result.Exception); Assert.Equal(typeof(ArgumentException), result.Exception.GetType()); Assert.Equal(TargetResultCode.Failure, result.ResultCode); }
private static IEnumerable <string> GetIncludesForTarget(TargetResult target, ProjectInformationCommandResult projectInformation) { return(projectInformation?.IncludePaths .Where(x => x.Targets == null || !x.Targets.Any() || (target != null && x.Targets.Any(t => t.Name.Equals(target.Name) && t.LongVersion.Equals(target.LongVersion)) ) ) .Select(p => p.PathValue)); }
/// <summary> /// Determines if the current target should be skipped, and logs the appropriate message. /// </summary> /// <returns>True to skip the target, false otherwise.</returns> private bool CheckSkipTarget(ref bool stopProcessingStack, TargetEntry currentTargetEntry) { if (_buildResult.HasResultsForTarget(currentTargetEntry.Name)) { TargetResult targetResult = _buildResult[currentTargetEntry.Name] as TargetResult; ErrorUtilities.VerifyThrowInternalNull(targetResult, "targetResult"); if (targetResult.ResultCode != TargetResultCode.Skipped) { // If we've already dealt with this target and it didn't skip, let's log appropriately // Otherwise we don't want anything more to do with it. var skippedTargetEventArgs = new TargetSkippedEventArgs( ResourceUtilities.GetResourceString(targetResult.ResultCode == TargetResultCode.Success ? "TargetAlreadyCompleteSuccess" : "TargetAlreadyCompleteFailure"), currentTargetEntry.Name) { BuildEventContext = _projectLoggingContext.BuildEventContext, TargetName = currentTargetEntry.Name, TargetFile = currentTargetEntry.Target.Location.File, ParentTarget = currentTargetEntry.ParentEntry?.Target.Name, BuildReason = currentTargetEntry.BuildReason }; _projectLoggingContext.LogBuildEvent(skippedTargetEventArgs); if (currentTargetEntry.StopProcessingOnCompletion) { stopProcessingStack = true; } if (targetResult.ResultCode == TargetResultCode.Success) { _targetsToBuild.Peek().LeaveLegacyCallTargetScopes(); _targetsToBuild.Pop(); } else { TargetEntry topEntry = _targetsToBuild.Pop(); // If this is a skip because of target failure, we should behave in the same way as we // would if this target actually failed -- remove all its dependencies from the stack as // well. Otherwise, we could encounter a situation where a failure target happens in the // middle of execution once, then exits, then a request comes through to build the same // targets, reaches that target, skips-already-failed, and then continues building. PopDependencyTargetsOnTargetFailure(topEntry, targetResult, ref stopProcessingStack); } return(true); } } return(false); }
private static IEnumerable <CompilerMacroResult> GetMacrosForTarget(TargetResult target, CompilerSpecificationCommandResult compilerSpecsCommandResult) { return(compilerSpecsCommandResult?.Specifications .FirstOrDefault(s => s.Targets .Any(t => t.Name.Equals(target.Name) && t.LongVersion.Equals(target.LongVersion) ) ) ?.CompilerMacros .Where(m => !m.Name.StartsWith("__has_include("))); }
internal static void AssertTargetResultsEqual(TargetResult a, TargetResult b) { TranslationHelpers.CompareExceptions(a.Exception, b.Exception).ShouldBeTrue(); TranslationHelpers.CompareCollections(a.Items, b.Items, TaskItemComparer.Instance).ShouldBeTrue(); a.ResultCode.ShouldBe(b.ResultCode); a.WorkUnitResult.ActionCode.ShouldBe(b.WorkUnitResult.ActionCode); a.WorkUnitResult.Exception.ShouldBe(b.WorkUnitResult.Exception); a.WorkUnitResult.ResultCode.ShouldBe(b.WorkUnitResult.ResultCode); }
private void ValidateRanInSeparateProcess(BuildResult result) { TargetResult targetresult = result.ResultsByTarget["GetCurrentProcessId"]; ITaskItem[] item = targetresult.Items; item.ShouldHaveSingleItem(); int.TryParse(item[0].ItemSpec, out int processId) .ShouldBeTrue($"Process ID passed from the 'test' target is not a valid integer (actual is '{item[0].ItemSpec}')"); processId.ShouldNotBe(Process.GetCurrentProcess().Id); }
/// <summary> /// Constructor allows you to set all the elements of the object /// </summary> public TargetDefinition(string name, string inputs, string outputs, string condition, string dependsOnTargets, XmlDocument projectXmlDoc) { this.name = name; this.inputs = inputs; this.outputs = outputs; this.condition = condition; this.dependsOnTargets = dependsOnTargets; this.tasks = new Dictionary <string, TaskDefinition>(); this.result = null; this.targetXmlElement = projectXmlDoc.CreateElement("Target", @"http://schemas.microsoft.com/developer/msbuild/2003"); GenerateTargetElementXml(); }
/// <summary> /// Get the current target actor /// </summary> /// <returns></returns> public static ActorItem GetCurrentTarget() { try { TargetResult readResult = Reader.GetTargetInfo(); return(readResult.TargetInfo.CurrentTarget); } catch (Exception ex) { Logger.Exception(ex, "GameMemory -> GetCurrentTarget"); } return(GetPlayer()); }
public void TestMergeResultsBad2() { BuildResult result = new BuildResult(1); result["foo"] = new TargetResult(new BuildItem[0] { }, BuildResultCode.Success); BuildResult result2 = new BuildResult(1); result2["foo"] = new TargetResult(new BuildItem[0] { }, BuildResultCode.Success); result.MergeResults(result2); }
public void TestTranslationWithException() { TaskItem item = new TaskItem("foo", "bar.proj"); item.SetMetadata("a", "b"); TargetResult result = new TargetResult(new TaskItem[] { item }, BuildResultUtilities.GetStopWithErrorResult(new BuildAbortedException())); ((ITranslatable)result).Translate(TranslationHelpers.GetWriteTranslator()); TargetResult deserializedResult = TargetResult.FactoryForDeserialization(TranslationHelpers.GetReadTranslator()); Assert.Equal(result.ResultCode, deserializedResult.ResultCode); Assert.True(TranslationHelpers.CompareCollections(result.Items, deserializedResult.Items, TaskItemComparer.Instance)); Assert.True(TranslationHelpers.CompareExceptions(result.Exception, deserializedResult.Exception)); }
private void ValidateResolverResults(BuildResult result) { TargetResult targetresult = result.ResultsByTarget["GetResolverResults"]; IEnumerable <string> GetResolverResults(string type) { return(targetresult.Items.Where(i => i.GetMetadata("Type").Equals(type, StringComparison.OrdinalIgnoreCase)) .Select(i => i.ItemSpec) .ToList()); } GetResolverResults("PropertyNameFromResolver").ShouldBeSameIgnoringOrder(new[] { "PropertyValueFromResolver" }); GetResolverResults("ItemFromResolver").ShouldBeSameIgnoringOrder(new[] { "ItemValueFromResolver" }); GetResolverResults("SdksImported").ShouldBeSameIgnoringOrder(new[] { "Sdk1", "Sdk2" }); }
/// <summary> /// Transfer the downloaded song to the given <see cref="SongTarget"/>s. /// </summary> /// <param name="targets"></param> /// <param name="downloadContainer"></param> /// <param name="cancellationToken"></param> /// <returns></returns> /// <exception cref="OperationCanceledException"></exception> protected async Task <TargetResult[]> TransferToTargets(IEnumerable <SongTarget> targets, DownloadContainer downloadContainer, CancellationToken cancellationToken) { List <TargetResult> completedTargets = new List <TargetResult>(_targets.Length); foreach (SongTarget?target in targets) { cancellationToken.ThrowIfCancellationRequested(); TargetResult result = await target.TransferAsync(Song, downloadContainer.GetResultStream(), cancellationToken).ConfigureAwait(false); completedTargets.Add(result); _stageIndex++; ReportProgress(JobProgress.CreateTargetCompletion(CurrentProgress, result)); } return(completedTargets.ToArray()); }
protected virtual string Build(FileInfo projectOrSolution, List <ProjectBuildResult> results) { StringBuilder message = new StringBuilder(); DirectoryInfo outputDir = new DirectoryInfo(OutputDirectory); DirectoryInfo sourceDir = new DirectoryInfo(SourceDirectory); string outputPath = Path.Combine(outputDir.FullName, Path.GetFileNameWithoutExtension(projectOrSolution.Name)); BuildResult buildResult = projectOrSolution.Compile(outputPath, Logger, BuildTarget); lock (_resultsLock) { results.Add(new ProjectBuildResult(projectOrSolution.FullName, buildResult)); OnResultAdded(projectOrSolution.FullName, buildResult); } if (buildResult.OverallResult != BuildResultCode.Success) { if (buildResult.Exception != null) { message.AppendLine("{0} Build failed: {1}"._Format(projectOrSolution.Name, buildResult.Exception.Message)); } else { message.AppendLine("{0} Build failed"._Format(projectOrSolution.Name)); } if (buildResult.ResultsByTarget != null) { IDictionary <string, TargetResult> resultsByTarget = buildResult.ResultsByTarget; resultsByTarget.Keys.Each(key => { TargetResult result = resultsByTarget[key]; message.AppendFormat("Target:{0}::ResultCode:{1}\r\n", key, result.ResultCode.ToString()); message.AppendLine("- Items"); result.Items.Each(item => { message.AppendFormat("\t{0}\r\n", item.ItemSpec); }); if (result.Exception != null) { message.AppendFormat("Exception Message: {0}\r\n", result.Exception.Message); } }); } } return(message.ToString()); }
public AI_Action(Tile t_,Tile t2_,TargetResult effect_) { t = t_; t2 = t2_; effect = effect_; }