Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
pinzart90 committed Jan 10, 2024
1 parent 6d35115 commit 95ace8c
Show file tree
Hide file tree
Showing 6 changed files with 2 additions and 90 deletions.
2 changes: 2 additions & 0 deletions src/DynamoUtilities/TestUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 0 additions & 2 deletions src/LibraryViewExtensionWebView2/LibraryViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
53 changes: 0 additions & 53 deletions test/DynamoCoreWpfTests/PackageManager/PackageManagerUITests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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");
}

/// <summary>
/// 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
/// </summary>
[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++; }
}


/// <summary>
/// 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
/// </summary>
[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()
{
Expand Down
6 changes: 0 additions & 6 deletions test/DynamoCoreWpfTests/PublishPackageViewModelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public class PublishPackageViewModelTests: DynamoViewModelUnitTest
{

[Test]
[Category("Failure")]
public void AddingDyfRaisesCanExecuteChangeOnDelegateCommand()
{

Expand Down Expand Up @@ -46,7 +45,6 @@ public void AddingDyfRaisesCanExecuteChangeOnDelegateCommand()
}

[Test]
[Category("Failure")]
public void SetsErrorState()
{
//open a dyf file and modify it
Expand Down Expand Up @@ -80,7 +78,6 @@ public void SetsErrorState()
}

[Test]
[Category("Failure")]
public void CanPublishLateInitializedJsonCustomNode()
{

Expand All @@ -102,7 +99,6 @@ public void CanPublishLateInitializedJsonCustomNode()


[Test]
[Category("Failure")]
public void NewPackageDoesNotThrow_NativeBinaryIsAddedAsAdditionalFile_NotBinary()
{
string packagesDirectory = Path.Combine(TestDirectory, "pkgs");
Expand Down Expand Up @@ -130,7 +126,6 @@ public void NewPackageDoesNotThrow_NativeBinaryIsAddedAsAdditionalFile_NotBinary
}

[Test]
[Category("Failure")]
public void NewPackageVersionUpload_DoesNotThrowExceptionWhenDLLIsLoadedSeveralTimes()
{
string packagesDirectory = Path.Combine(TestDirectory, "pkgs");
Expand All @@ -155,7 +150,6 @@ public void NewPackageVersionUpload_DoesNotThrowExceptionWhenDLLIsLoadedSeveralT
}

[Test]
[Category("Failure")]
public void NewPackageVersionUpload_CanAddAndRemoveFiles()
{
string packagesDirectory = Path.Combine(TestDirectory, "pkgs");
Expand Down
3 changes: 0 additions & 3 deletions test/DynamoCoreWpfTests/Setup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
}

Expand Down
26 changes: 0 additions & 26 deletions test/Libraries/SystemTestServices/SystemTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
}
/// <summary>
/// SystemTestBase is the base class for all
/// Dynamo system tests.
Expand Down

0 comments on commit 95ace8c

Please sign in to comment.