From 5b80ce107e47fa25489cf3e08f13bb9744b5fa89 Mon Sep 17 00:00:00 2001 From: Ivan Shakhov Date: Thu, 25 May 2023 10:54:46 +0200 Subject: [PATCH 1/3] allow stopping Rider part of the tests --- .../Feature/UnitTesting/RunViaUnityEditorStrategy.cs | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/resharper/resharper-unity/src/Unity.Rider/Integration/Core/Feature/UnitTesting/RunViaUnityEditorStrategy.cs b/resharper/resharper-unity/src/Unity.Rider/Integration/Core/Feature/UnitTesting/RunViaUnityEditorStrategy.cs index 8e3839427..0db041a9c 100644 --- a/resharper/resharper-unity/src/Unity.Rider/Integration/Core/Feature/UnitTesting/RunViaUnityEditorStrategy.cs +++ b/resharper/resharper-unity/src/Unity.Rider/Integration/Core/Feature/UnitTesting/RunViaUnityEditorStrategy.cs @@ -293,12 +293,9 @@ private Task Refresh(Lifetime lifetime, TaskCompletionSource tcs, Cancella cancellationToken.Register(() => { - // On cancel we don't want to stop run, if tests are already running, but we want to stop, if we are waiting for refresh - if (refreshLifetimeDef.Lifetime.IsAlive) - { - tcs.TrySetCanceled(); - refreshLifetimeDef.Terminate(); - } + // We may not be able to stop tests in Unity, but still we need to allow stopping Rider part of the tests + tcs.TrySetCanceled(); + refreshLifetimeDef.Terminate(); }); WaitForUnityEditorConnectedAndIdle(refreshLifetime) From d098f5b47e22d736f11a9678d235f3fc535f944e Mon Sep 17 00:00:00 2001 From: Ivan Shakhov Date: Thu, 25 May 2023 12:06:12 +0200 Subject: [PATCH 2/3] fix RIDER-91705, would help only with a corresponding changes in the Rider package, expected Rider package 3.0.23 --- .../UnitTesting/RunViaUnityEditorStrategy.cs | 1 + .../UnitTesting/UnityEditorTestLauncher.cs | 33 ++++++++----------- 2 files changed, 14 insertions(+), 20 deletions(-) diff --git a/resharper/resharper-unity/src/Unity.Rider/Integration/Core/Feature/UnitTesting/RunViaUnityEditorStrategy.cs b/resharper/resharper-unity/src/Unity.Rider/Integration/Core/Feature/UnitTesting/RunViaUnityEditorStrategy.cs index 0db041a9c..61e7fe931 100644 --- a/resharper/resharper-unity/src/Unity.Rider/Integration/Core/Feature/UnitTesting/RunViaUnityEditorStrategy.cs +++ b/resharper/resharper-unity/src/Unity.Rider/Integration/Core/Feature/UnitTesting/RunViaUnityEditorStrategy.cs @@ -233,6 +233,7 @@ private void RefreshAndRunTask(IUnitTestRun run, TaskCompletionSource tcs, launch.ClientControllerInfo); model.UnitTestLaunch.SetValue(launch); SubscribeResults(run, lt, launch); + launch.RunResult.Advise(lt, result => { tcs.SetResult(result.Passed); }); StartTests(model, run, tcs, lt); } }); diff --git a/unity/EditorPlugin/SinceUnity.5.6/UnitTesting/UnityEditorTestLauncher.cs b/unity/EditorPlugin/SinceUnity.5.6/UnitTesting/UnityEditorTestLauncher.cs index 306292da6..16517413c 100644 --- a/unity/EditorPlugin/SinceUnity.5.6/UnitTesting/UnityEditorTestLauncher.cs +++ b/unity/EditorPlugin/SinceUnity.5.6/UnitTesting/UnityEditorTestLauncher.cs @@ -102,27 +102,20 @@ internal static void SupportAbortNew(UnitTestLaunch launch) { try { - const string assemblyName = "UnityEditor.TestRunner"; - const string typeName = "UnityEditor.TestTools.TestRunner.Api.TestRunnerApi"; - const string methodName = "CancelAllTestRuns"; - - MethodInfo stopRunMethod = null; - - var assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault(a => a.GetName().Name.Equals(assemblyName)); - if (assembly == null) - ourLogger.Verbose($"Could not find {assemblyName} in the AppDomain."); - else + var riderPackageAssembly = RiderPackageInterop.GetAssembly(); + var apiType = riderPackageAssembly?.GetType("Packages.Rider.Editor.UnitTesting.RiderTestRunner"); + if (apiType == null) { - var apiType = assembly.GetType(typeName); - if (apiType == null) - ourLogger.Verbose($"Could not find {typeName} in the {assemblyName}."); - else - { - stopRunMethod = apiType.GetMethod(methodName); - if (stopRunMethod == null) - ourLogger.Verbose($"Could not find {methodName} in the {typeName}."); - } - } + ourLogger.Verbose($"Could not find RiderTestRunner in the {riderPackageAssembly}."); + return; + }; + + var methodName = "CancelTestRun"; + var stopRunMethod = apiType.GetMethod(methodName); + if (stopRunMethod == null) + stopRunMethod = apiType.GetMethod(methodName, BindingFlags.Static | BindingFlags.NonPublic); + if (stopRunMethod == null) + ourLogger.Verbose($"Could not find {methodName} in the {apiType.Name}."); launch.Abort.Set((lifetime, _) => { From 4839045917d593d757ede12d55cb7c2f8b692e04 Mon Sep 17 00:00:00 2001 From: "Arseny.Chernyaev" Date: Mon, 5 Jun 2023 10:54:51 +0200 Subject: [PATCH 3/3] fixed Unity plugin compilation --- .../src/SessionStartup/DelegatingDebuggerSessionOptions.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/debugger/debugger-worker/src/SessionStartup/DelegatingDebuggerSessionOptions.cs b/debugger/debugger-worker/src/SessionStartup/DelegatingDebuggerSessionOptions.cs index 72d0b8fca..368277645 100644 --- a/debugger/debugger-worker/src/SessionStartup/DelegatingDebuggerSessionOptions.cs +++ b/debugger/debugger-worker/src/SessionStartup/DelegatingDebuggerSessionOptions.cs @@ -38,6 +38,7 @@ protected DelegatingDebuggerSessionOptions(IDebuggerSessionOptions debuggerSessi public bool ForceLoadMethodByToken => DebuggerSessionOptionsImplementation.ForceLoadMethodByToken; public HotReloadInfo HotReload => DebuggerSessionOptionsImplementation.HotReload; public bool DisableRuntimeLoadTimeout => DebuggerSessionOptionsImplementation.DisableRuntimeLoadTimeout; + public bool DisableSteppingHandlers => DebuggerSessionOptionsImplementation.DisableSteppingHandlers; public bool TrackHandledExceptionsInAsyncCode => DebuggerSessionOptionsImplementation.TrackHandledExceptionsInAsyncCode; } } \ No newline at end of file