From 95ace8c4b1051470b9a68a9617bebbe0f8b39a43 Mon Sep 17 00:00:00 2001 From: pinzart90 Date: Wed, 10 Jan 2024 11:17:25 -0500 Subject: [PATCH] update --- src/DynamoUtilities/TestUtilities.cs | 2 + .../LibraryViewController.cs | 2 - .../PackageManager/PackageManagerUITests.cs | 53 ------------------- .../PublishPackageViewModelTests.cs | 6 --- test/DynamoCoreWpfTests/Setup.cs | 3 -- .../SystemTestServices/SystemTestBase.cs | 26 --------- 6 files changed, 2 insertions(+), 90 deletions(-) diff --git a/src/DynamoUtilities/TestUtilities.cs b/src/DynamoUtilities/TestUtilities.cs index 8d4a3d7e13b..d0124406645 100644 --- a/src/DynamoUtilities/TestUtilities.cs +++ b/src/DynamoUtilities/TestUtilities.cs @@ -6,8 +6,10 @@ namespace DynamoUtilities { + // Bag of utilities designed for use during tests internal static class TestUtilities { + // Simple string that we can store in DynamoWebView2 instances so that we can track them down more easily internal static string WebView2Stamp; } } diff --git a/src/LibraryViewExtensionWebView2/LibraryViewController.cs b/src/LibraryViewExtensionWebView2/LibraryViewController.cs index 4d7ec4efd13..7552e92fd88 100644 --- a/src/LibraryViewExtensionWebView2/LibraryViewController.cs +++ b/src/LibraryViewExtensionWebView2/LibraryViewController.cs @@ -22,8 +22,6 @@ using Dynamo.Wpf.UI.GuidedTour; using Dynamo.Wpf.Utilities; using Dynamo.Wpf.ViewModels; -using DynamoUtilities; -using ICSharpCode.AvalonEdit.Document; using Microsoft.Web.WebView2.Core; using Microsoft.Web.WebView2.Wpf; using Newtonsoft.Json; diff --git a/test/DynamoCoreWpfTests/PackageManager/PackageManagerUITests.cs b/test/DynamoCoreWpfTests/PackageManager/PackageManagerUITests.cs index 27320ee8131..33bc4984e4e 100644 --- a/test/DynamoCoreWpfTests/PackageManager/PackageManagerUITests.cs +++ b/test/DynamoCoreWpfTests/PackageManager/PackageManagerUITests.cs @@ -7,7 +7,6 @@ using System.Windows; using System.Windows.Controls; using System.Windows.Controls.Primitives; -using System.Windows.Threading; using Dynamo.Core; using Dynamo.Extensions; using Dynamo.PackageManager; @@ -1876,58 +1875,6 @@ public void RemoveMultipleRootItemsCorrectly() Assert.DoesNotThrow(() => vm.RemoveItemCommand.Execute(packageContents.First())); } - private async void AsyncException() - { - await Task.Delay(500); - throw new Exception("Async Exception"); - } - - /// - /// DispatcherUtil.DoEvents (during testing) handles exceptions in a different way than the way Dynamo Live. - /// This test crashes Dynamo live but during testing the exception seems to be caught inside the internals of DispatcherUtil.DoEvents - /// Some tests might trigger continuation of async methods through other codepaths (not DoEvents) which might cause the test runner to crash - /// - [Test, Category("Failure")] - [Description("Does not crash the test runner. Hits CurrentDispatcher_UnhandledException.")] - public void Crash1() - { - AsyncException(); - } - - [Test, Category("Failure")] - [Description("Run together with Crash1.")] - public void Crash1Continuation() - { - int ii = 0; - while (ii < 10) { Utility.DispatcherUtil.DoEvents(); Thread.Sleep(100); ii++; } - } - - - /// - /// DispatcherUtil.DoEvents (during testing) handles exceptions in a different way than the way Dynamo Live. - /// This test crashes Dynamo live but during testing the exception seems to be caught inside the internals of DispatcherUtil.DoEvents - /// Some tests might trigger continuation of async methods through other codepaths (not DoEvents) which might cause the test runner to crash - /// - [Test, Category("Failure")] - [Description("Does not crash the test runner. Hits CurrentDispatcher_UnhandledException.")] - public void Crash2() - { - Dispatcher.CurrentDispatcher.BeginInvoke(AsyncException); - - int ii = 0; - while (ii < 10) { Utility.DispatcherUtil.DoEvents(); Thread.Sleep(100); ii++; } - } - - [Test, Category("Failure")] - [Description("Crashes the test runner. Hits CurrentDomain_UnhandledException")] - public void Crash3() - { - Task.Run(AsyncException).Wait(); - - int ii = 0; - while (ii < 10) { Utility.DispatcherUtil.DoEvents(); Thread.Sleep(100); ii++; } - } - [Test] public void AddsFilesAndFoldersFromMultipleFilePathsCorrectly() { diff --git a/test/DynamoCoreWpfTests/PublishPackageViewModelTests.cs b/test/DynamoCoreWpfTests/PublishPackageViewModelTests.cs index 738a4ea00b5..37bee64f615 100644 --- a/test/DynamoCoreWpfTests/PublishPackageViewModelTests.cs +++ b/test/DynamoCoreWpfTests/PublishPackageViewModelTests.cs @@ -18,7 +18,6 @@ public class PublishPackageViewModelTests: DynamoViewModelUnitTest { [Test] - [Category("Failure")] public void AddingDyfRaisesCanExecuteChangeOnDelegateCommand() { @@ -46,7 +45,6 @@ public void AddingDyfRaisesCanExecuteChangeOnDelegateCommand() } [Test] - [Category("Failure")] public void SetsErrorState() { //open a dyf file and modify it @@ -80,7 +78,6 @@ public void SetsErrorState() } [Test] - [Category("Failure")] public void CanPublishLateInitializedJsonCustomNode() { @@ -102,7 +99,6 @@ public void CanPublishLateInitializedJsonCustomNode() [Test] - [Category("Failure")] public void NewPackageDoesNotThrow_NativeBinaryIsAddedAsAdditionalFile_NotBinary() { string packagesDirectory = Path.Combine(TestDirectory, "pkgs"); @@ -130,7 +126,6 @@ public void NewPackageDoesNotThrow_NativeBinaryIsAddedAsAdditionalFile_NotBinary } [Test] - [Category("Failure")] public void NewPackageVersionUpload_DoesNotThrowExceptionWhenDLLIsLoadedSeveralTimes() { string packagesDirectory = Path.Combine(TestDirectory, "pkgs"); @@ -155,7 +150,6 @@ public void NewPackageVersionUpload_DoesNotThrowExceptionWhenDLLIsLoadedSeveralT } [Test] - [Category("Failure")] public void NewPackageVersionUpload_CanAddAndRemoveFiles() { string packagesDirectory = Path.Combine(TestDirectory, "pkgs"); diff --git a/test/DynamoCoreWpfTests/Setup.cs b/test/DynamoCoreWpfTests/Setup.cs index 67f344b485f..3ce71588a75 100644 --- a/test/DynamoCoreWpfTests/Setup.cs +++ b/test/DynamoCoreWpfTests/Setup.cs @@ -21,9 +21,6 @@ private void CurrentDispatcher_UnhandledException(object sender, DispatcherUnhan private void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e) { var ex = e.ExceptionObject as Exception; - - string flPath = Path.Combine(new FileInfo(Assembly.GetExecutingAssembly().Location).DirectoryName, "crash.log"); - File.WriteAllText(flPath, $"PID {Process.GetCurrentProcess().Id} Unhandled exception thrown during test {TestContext.CurrentContext.Test.Name} with message : {ex.Message + Environment.NewLine + ex.StackTrace}"); System.Console.WriteLine($"PID {Process.GetCurrentProcess().Id} Unhandled exception thrown during test {TestContext.CurrentContext.Test.Name} with message : {ex.Message + Environment.NewLine + ex.StackTrace}"); } diff --git a/test/Libraries/SystemTestServices/SystemTestBase.cs b/test/Libraries/SystemTestServices/SystemTestBase.cs index f6d94450707..7f2aa27a680 100644 --- a/test/Libraries/SystemTestServices/SystemTestBase.cs +++ b/test/Libraries/SystemTestServices/SystemTestBase.cs @@ -15,11 +15,9 @@ using Dynamo.Models; using Dynamo.Scheduler; using Dynamo.Tests; -using Dynamo.Updates; using Dynamo.ViewModels; using DynamoShapeManager; using DynamoUtilities; -using ICSharpCode.AvalonEdit.Document; using NUnit.Framework; using ProtoCore.Mirror; @@ -28,30 +26,6 @@ namespace SystemTestServices { - public sealed class CustomSynchronizationContext : SynchronizationContext - { - private void EnsureExceptionHandlers() - { - Dispatcher.FromThread(Thread.CurrentThread).UnhandledException += QueueSynchronizationContext_UnhandledException; - } - - private void QueueSynchronizationContext_UnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e) - { - e.Handled = true; - System.Console.WriteLine($"Unhandled exception thrown with message : {e.Exception.Message}"); - } - - public override void Post(SendOrPostCallback d, object? state) - { - EnsureExceptionHandlers(); - base.Post(d, state); - } - public override void Send(SendOrPostCallback d, object? state) - { - EnsureExceptionHandlers(); - base.Send(d, state); - } - } /// /// SystemTestBase is the base class for all /// Dynamo system tests.