From c55fba8ab2a1c9d3df65eda4a5a1e957f4aa1f78 Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sun, 19 Apr 2020 17:19:32 -0400 Subject: Inital commit --- .../TestRunner/Callbacks.meta | 8 + .../TestRunner/Callbacks/EditModeRunnerCallback.cs | 178 +++++++++ .../Callbacks/EditModeRunnerCallback.cs.meta | 11 + .../TestRunner/Callbacks/RerunCallback.cs | 86 ++++ .../TestRunner/Callbacks/RerunCallback.cs.meta | 11 + .../TestRunner/Callbacks/RerunCallbackData.cs | 15 + .../TestRunner/Callbacks/RerunCallbackData.cs.meta | 11 + .../Callbacks/RerunCallbackInitializer.cs | 17 + .../Callbacks/RerunCallbackInitializer.cs.meta | 11 + .../TestRunner/Callbacks/TestRunnerCallback.cs | 37 ++ .../Callbacks/TestRunnerCallback.cs.meta | 11 + .../TestRunner/Callbacks/WindowResultUpdater.cs | 44 +++ .../Callbacks/WindowResultUpdater.cs.meta | 11 + .../TestRunner/EditModePCHelper.cs | 32 ++ .../TestRunner/EditModePCHelper.cs.meta | 11 + .../TestRunner/EditModeRunner.cs | 438 +++++++++++++++++++++ .../TestRunner/EditModeRunner.cs.meta | 11 + .../TestRunner/EditmodeWorkItemFactory.cs | 14 + .../TestRunner/EditmodeWorkItemFactory.cs.meta | 11 + .../TestRunner/EditorEnumeratorTestWorkItem.cs | 179 +++++++++ .../EditorEnumeratorTestWorkItem.cs.meta | 11 + .../TestRunner/EnumeratorStepHelper.cs | 51 +++ .../TestRunner/EnumeratorStepHelper.cs.meta | 11 + .../TestRunner/Messages.meta | 8 + .../TestRunner/Messages/EnterPlayMode.cs | 39 ++ .../TestRunner/Messages/EnterPlayMode.cs.meta | 11 + .../TestRunner/Messages/ExitPlayMode.cs | 32 ++ .../TestRunner/Messages/ExitPlayMode.cs.meta | 11 + .../TestRunner/Messages/RecompileScripts.cs | 63 +++ .../TestRunner/Messages/RecompileScripts.cs.meta | 11 + .../TestRunner/Messages/WaitForDomainReload.cs | 44 +++ .../Messages/WaitForDomainReload.cs.meta | 11 + .../UnityEditor.TestRunner/TestRunner/Utils.meta | 8 + .../TestRunner/Utils/CachingTestListProvider.cs | 48 +++ .../Utils/CachingTestListProvider.cs.meta | 11 + .../TestRunner/Utils/EditorAssembliesProxy.cs | 13 + .../TestRunner/Utils/EditorAssembliesProxy.cs.meta | 11 + .../TestRunner/Utils/EditorAssemblyWrapper.cs | 18 + .../TestRunner/Utils/EditorAssemblyWrapper.cs.meta | 11 + .../Utils/EditorCompilationInterfaceProxy.cs | 17 + .../Utils/EditorCompilationInterfaceProxy.cs.meta | 11 + .../Utils/EditorLoadedTestAssemblyProvider.cs | 69 ++++ .../Utils/EditorLoadedTestAssemblyProvider.cs.meta | 11 + .../TestRunner/Utils/IEditorAssembliesProxy.cs | 9 + .../Utils/IEditorAssembliesProxy.cs.meta | 11 + .../Utils/IEditorCompilationInterfaceProxy.cs | 10 + .../Utils/IEditorCompilationInterfaceProxy.cs.meta | 11 + .../Utils/IEditorLoadedTestAssemblyProvider.cs | 12 + .../IEditorLoadedTestAssemblyProvider.cs.meta | 11 + .../TestRunner/Utils/ITestListCache.cs | 13 + .../TestRunner/Utils/ITestListCache.cs.meta | 11 + .../TestRunner/Utils/ITestListCacheData.cs | 13 + .../TestRunner/Utils/ITestListCacheData.cs.meta | 11 + .../TestRunner/Utils/ITestListProvider.cs | 11 + .../TestRunner/Utils/ITestListProvider.cs.meta | 11 + .../TestRunner/Utils/TestListCache.cs | 56 +++ .../TestRunner/Utils/TestListCache.cs.meta | 11 + .../TestRunner/Utils/TestListCacheData.cs | 27 ++ .../TestRunner/Utils/TestListCacheData.cs.meta | 11 + .../TestRunner/Utils/TestListJob.cs | 36 ++ .../TestRunner/Utils/TestListJob.cs.meta | 11 + .../TestRunner/Utils/TestListProvider.cs | 42 ++ .../TestRunner/Utils/TestListProvider.cs.meta | 11 + 63 files changed, 2017 insertions(+) create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/EditModeRunnerCallback.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/EditModeRunnerCallback.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallback.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallback.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackData.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackData.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackInitializer.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackInitializer.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/TestRunnerCallback.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/TestRunnerCallback.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/WindowResultUpdater.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/WindowResultUpdater.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModePCHelper.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModePCHelper.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModeRunner.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModeRunner.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditmodeWorkItemFactory.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditmodeWorkItemFactory.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditorEnumeratorTestWorkItem.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditorEnumeratorTestWorkItem.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EnumeratorStepHelper.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EnumeratorStepHelper.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/EnterPlayMode.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/EnterPlayMode.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/ExitPlayMode.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/ExitPlayMode.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/RecompileScripts.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/RecompileScripts.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/WaitForDomainReload.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/WaitForDomainReload.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/CachingTestListProvider.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/CachingTestListProvider.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssembliesProxy.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssembliesProxy.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssemblyWrapper.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssemblyWrapper.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorCompilationInterfaceProxy.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorCompilationInterfaceProxy.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorLoadedTestAssemblyProvider.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorLoadedTestAssemblyProvider.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorAssembliesProxy.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorAssembliesProxy.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorCompilationInterfaceProxy.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorCompilationInterfaceProxy.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorLoadedTestAssemblyProvider.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorLoadedTestAssemblyProvider.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCache.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCache.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCacheData.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCacheData.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListProvider.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListProvider.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCache.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCache.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCacheData.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCacheData.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListJob.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListJob.cs.meta create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListProvider.cs create mode 100644 Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListProvider.cs.meta (limited to 'Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner') diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks.meta new file mode 100644 index 0000000..d7be998 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5d7f0d6acfced954682a89e7002c04d9 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/EditModeRunnerCallback.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/EditModeRunnerCallback.cs new file mode 100644 index 0000000..7d026fa --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/EditModeRunnerCallback.cs @@ -0,0 +1,178 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework; +using NUnit.Framework.Interfaces; +using NUnit.Framework.Internal; +using UnityEditor.SceneManagement; +using UnityEngine; +using UnityEngine.TestTools.TestRunner; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class EditModeRunnerCallback : ScriptableObject, ITestRunnerListener + { + private EditModeLauncherContextSettings m_Settings; + public SceneSetup[] previousSceneSetup; + public EditModeRunner runner; + + private bool m_Canceled; + private ITest m_CurrentTest; + private int m_TotalTests; + + [SerializeField] + private List m_PendingTests; + [SerializeField] + private string m_LastCountedTestName; + [SerializeField] + private bool m_RunRestarted; + + public void OnDestroy() + { + CleanUp(); + } + + public void RunStarted(ITest testsToRun) + { + Setup(); + if (m_PendingTests == null) + { + m_PendingTests = GetTestsExpectedToRun(testsToRun, runner.GetFilter()); + m_TotalTests = m_PendingTests.Count; + } + } + + public void OnEnable() + { + if (m_RunRestarted) + { + Setup(); + } + } + + private void Setup() + { + m_Settings = new EditModeLauncherContextSettings(); + Application.logMessageReceivedThreaded += LogReceived; + EditorApplication.playModeStateChanged += WaitForExitPlaymode; + EditorApplication.update += DisplayProgressBar; + AssemblyReloadEvents.beforeAssemblyReload += BeforeAssemblyReload; + } + + private void BeforeAssemblyReload() + { + if (m_CurrentTest != null) + { + m_LastCountedTestName = m_CurrentTest.FullName; + m_RunRestarted = true; + } + } + + private void DisplayProgressBar() + { + if (m_CurrentTest == null) + return; + if (!m_Canceled && EditorUtility.DisplayCancelableProgressBar("Test Runner", "Running test " + m_CurrentTest.Name, Math.Min(1.0f, (float)(m_TotalTests - m_PendingTests.Count) / m_TotalTests))) + { + EditorApplication.update -= DisplayProgressBar; + m_Canceled = true; + EditorUtility.ClearProgressBar(); + runner.OnRunCancel(); + } + } + + private static void LogReceived(string message, string stacktrace, LogType type) + { + if (TestContext.Out != null) + TestContext.Out.WriteLine(message); + } + + private static void WaitForExitPlaymode(PlayModeStateChange state) + { + if (state == PlayModeStateChange.EnteredEditMode) + { + EditorApplication.playModeStateChanged -= WaitForExitPlaymode; + //because logMessage is reset on Enter EditMode + //we remove and add the callback + //because Unity + Application.logMessageReceivedThreaded -= LogReceived; + Application.logMessageReceivedThreaded += LogReceived; + } + } + + public void RunFinished(ITestResult result) + { + if (previousSceneSetup != null && previousSceneSetup.Length > 0) + { + try + { + EditorSceneManager.RestoreSceneManagerSetup(previousSceneSetup); + } + catch (ArgumentException e) + { + Debug.LogWarning(e.Message); + } + } + else + { + EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects, NewSceneMode.Single); + } + CleanUp(); + } + + private void CleanUp() + { + m_CurrentTest = null; + EditorUtility.ClearProgressBar(); + if (m_Settings != null) + { + m_Settings.Dispose(); + } + Application.logMessageReceivedThreaded -= LogReceived; + EditorApplication.update -= DisplayProgressBar; + } + + public void TestStarted(ITest test) + { + if (test.IsSuite || !(test is TestMethod)) + { + return; + } + + m_CurrentTest = test; + + if (m_RunRestarted) + { + if (test.FullName == m_LastCountedTestName) + m_RunRestarted = false; + } + } + + public void TestFinished(ITestResult result) + { + if (result.Test is TestMethod) + { + m_PendingTests.Remove(result.Test.FullName); + } + } + + private static List GetTestsExpectedToRun(ITest test, ITestFilter filter) + { + var expectedTests = new List(); + + if (filter.Pass(test)) + { + if (test.IsSuite) + { + expectedTests.AddRange(test.Tests.SelectMany(subTest => GetTestsExpectedToRun(subTest, filter))); + } + else + { + expectedTests.Add(test.FullName); + } + } + + return expectedTests; + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/EditModeRunnerCallback.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/EditModeRunnerCallback.cs.meta new file mode 100644 index 0000000..5c5501b --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/EditModeRunnerCallback.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cc456ba93311a3a43ad896449fee9868 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallback.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallback.cs new file mode 100644 index 0000000..2515ea7 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallback.cs @@ -0,0 +1,86 @@ +using UnityEditor.TestTools.TestRunner.Api; +using UnityEditor.TestTools.TestRunner.CommandLineTest; +using UnityEngine.TestTools.TestRunner.GUI; +using UnityEngine; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class RerunCallback : ScriptableObject, ICallbacks + { + public static bool useMockRunFilter = false; + public static TestRunnerFilter mockRunFilter = null; + + public void RunFinished(ITestResultAdaptor result) + { + if (RerunCallbackData.instance.runFilters == null || RerunCallbackData.instance.runFilters.Length == 0) + RerunCallbackData.instance.runFilters = new[] {new TestRunnerFilter()}; + + var runFilter = RerunCallbackData.instance.runFilters[0]; + + if (useMockRunFilter) + { + runFilter = mockRunFilter; + } + + runFilter.testRepetitions--; + if (runFilter.testRepetitions <= 0 || result.TestStatus != TestStatus.Passed) + { + ExitCallbacks.preventExit = false; + return; + } + + ExitCallbacks.preventExit = true; + if (EditorApplication.isPlaying) + { + EditorApplication.playModeStateChanged += WaitForExitPlaymode; + return; + } + + if (!useMockRunFilter) + { + ExecuteTestRunnerAPI(); + } + } + + private static void WaitForExitPlaymode(PlayModeStateChange state) + { + if (state == PlayModeStateChange.EnteredEditMode) + { + ExecuteTestRunnerAPI(); + } + } + + private static void ExecuteTestRunnerAPI() + { + var runFilter = RerunCallbackData.instance.runFilters[0]; + var testMode = RerunCallbackData.instance.testMode; + + var testRunnerApi = ScriptableObject.CreateInstance(); + testRunnerApi.Execute(new Api.ExecutionSettings() + { + filters = new[] + { + new Filter() + { + categoryNames = runFilter.categoryNames, + groupNames = runFilter.groupNames, + testMode = testMode, + testNames = runFilter.testNames + } + } + }); + } + + public void TestStarted(ITestAdaptor test) + { + } + + public void TestFinished(ITestResultAdaptor result) + { + } + + public void RunStarted(ITestAdaptor testsToRun) + { + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallback.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallback.cs.meta new file mode 100644 index 0000000..b4fc0e2 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallback.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b7ff2b2e91321ff4381d4ab45870a32e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackData.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackData.cs new file mode 100644 index 0000000..8aeeeec --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackData.cs @@ -0,0 +1,15 @@ +using UnityEditor.TestTools.TestRunner.Api; +using UnityEngine; +using UnityEngine.TestTools.TestRunner.GUI; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class RerunCallbackData : ScriptableSingleton + { + [SerializeField] + internal TestRunnerFilter[] runFilters; + + [SerializeField] + internal TestMode testMode; + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackData.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackData.cs.meta new file mode 100644 index 0000000..bc911fe --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 087cba9fa6ac867479a0b0fdc0a5864b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackInitializer.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackInitializer.cs new file mode 100644 index 0000000..86be497 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackInitializer.cs @@ -0,0 +1,17 @@ +using UnityEngine; +using UnityEditor.TestTools.TestRunner.Api; + +namespace UnityEditor.TestTools.TestRunner +{ + [InitializeOnLoad] + static class RerunCallbackInitializer + { + static RerunCallbackInitializer() + { + var testRunnerApi = ScriptableObject.CreateInstance(); + + var rerunCallback = ScriptableObject.CreateInstance(); + testRunnerApi.RegisterCallbacks(rerunCallback); + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackInitializer.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackInitializer.cs.meta new file mode 100644 index 0000000..1f50bcc --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/RerunCallbackInitializer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f73fc901e4b0f2d4daf11f46506054ba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/TestRunnerCallback.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/TestRunnerCallback.cs new file mode 100644 index 0000000..6e89c21 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/TestRunnerCallback.cs @@ -0,0 +1,37 @@ +using NUnit.Framework.Interfaces; +using UnityEngine; +using UnityEngine.TestTools.TestRunner; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class TestRunnerCallback : ScriptableObject, ITestRunnerListener + { + public void RunStarted(ITest testsToRun) + { + EditorApplication.playModeStateChanged += OnPlayModeStateChanged; + } + + private void OnPlayModeStateChanged(PlayModeStateChange state) + { + if (state == PlayModeStateChange.ExitingPlayMode) + { + EditorApplication.playModeStateChanged -= OnPlayModeStateChanged; + //We need to make sure we don't block NUnit thread in case we exit PlayMode earlier + PlaymodeTestsController.TryCleanup(); + } + } + + public void RunFinished(ITestResult testResults) + { + EditorApplication.isPlaying = false; + } + + public void TestStarted(ITest testName) + { + } + + public void TestFinished(ITestResult test) + { + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/TestRunnerCallback.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/TestRunnerCallback.cs.meta new file mode 100644 index 0000000..a592975 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/TestRunnerCallback.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d44e6804bc58be84ea71a619b468f150 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/WindowResultUpdater.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/WindowResultUpdater.cs new file mode 100644 index 0000000..831d769 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/WindowResultUpdater.cs @@ -0,0 +1,44 @@ +using UnityEditor.TestTools.TestRunner.Api; + +namespace UnityEditor.TestTools.TestRunner.GUI +{ + internal class WindowResultUpdater : ICallbacks, ITestTreeRebuildCallbacks + { + public void RunStarted(ITestAdaptor testsToRun) + { + } + + public void RunFinished(ITestResultAdaptor testResults) + { + if (TestRunnerWindow.s_Instance != null) + { + TestRunnerWindow.s_Instance.RebuildUIFilter(); + } + } + + public void TestStarted(ITestAdaptor testName) + { + } + + public void TestFinished(ITestResultAdaptor test) + { + if (TestRunnerWindow.s_Instance == null) + { + return; + } + + var result = new TestRunnerResult(test); + TestRunnerWindow.s_Instance.m_SelectedTestTypes.UpdateResult(result); + } + + public void TestTreeRebuild(ITestAdaptor test) + { + if (TestRunnerWindow.s_Instance == null) + { + return; + } + + TestRunnerWindow.s_Instance.m_SelectedTestTypes.UpdateTestTree(test); + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/WindowResultUpdater.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/WindowResultUpdater.cs.meta new file mode 100644 index 0000000..5273cf4 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Callbacks/WindowResultUpdater.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6d468ee3657be7a43a2ef2178ec14239 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModePCHelper.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModePCHelper.cs new file mode 100644 index 0000000..7968041 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModePCHelper.cs @@ -0,0 +1,32 @@ +using System.Collections; +using System.Reflection; +using UnityEngine.TestTools; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class EditModePcHelper : TestCommandPcHelper + { + public override void SetEnumeratorPC(IEnumerator enumerator, int pc) + { + GetPCFieldInfo(enumerator).SetValue(enumerator, pc); + } + + public override int GetEnumeratorPC(IEnumerator enumerator) + { + if (enumerator == null) + { + return 0; + } + return (int)GetPCFieldInfo(enumerator).GetValue(enumerator); + } + + private FieldInfo GetPCFieldInfo(IEnumerator enumerator) + { + var field = enumerator.GetType().GetField("$PC", BindingFlags.NonPublic | BindingFlags.Instance); + if (field == null) // Roslyn + field = enumerator.GetType().GetField("<>1__state", BindingFlags.NonPublic | BindingFlags.Instance); + + return field; + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModePCHelper.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModePCHelper.cs.meta new file mode 100644 index 0000000..2bb2d0b --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModePCHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6d16f2e78a356d34c9a32108929de932 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModeRunner.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModeRunner.cs new file mode 100644 index 0000000..c0d72b4 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModeRunner.cs @@ -0,0 +1,438 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework.Interfaces; +using NUnit.Framework.Internal; +using NUnit.Framework.Internal.Filters; +using UnityEngine; +using UnityEngine.TestTools.NUnitExtensions; +using UnityEngine.TestTools.TestRunner; +using UnityEngine.TestTools; +using UnityEngine.TestTools.TestRunner.GUI; +using UnityEditor.Callbacks; +using UnityEditor.TestTools.TestRunner.Api; +using UnityEngine.TestRunner.NUnitExtensions; +using UnityEngine.TestRunner.NUnitExtensions.Runner; + +namespace UnityEditor.TestTools.TestRunner +{ + internal interface IUnityTestAssemblyRunnerFactory + { + IUnityTestAssemblyRunner Create(TestPlatform testPlatform, WorkItemFactory factory); + } + + internal class UnityTestAssemblyRunnerFactory : IUnityTestAssemblyRunnerFactory + { + public IUnityTestAssemblyRunner Create(TestPlatform testPlatform, WorkItemFactory factory) + { + return new UnityTestAssemblyRunner(new UnityTestAssemblyBuilder(), factory); + } + } + + [Serializable] + internal class EditModeRunner : ScriptableObject, IDisposable + { + [SerializeField] + private Filter[] m_Filters; + + //The counter from the IEnumerator object + [SerializeField] + private int m_CurrentPC; + + [SerializeField] + private bool m_ExecuteOnEnable; + + [SerializeField] + private List m_AlreadyStartedTests; + + [SerializeField] + private List m_ExecutedTests; + + [SerializeField] + private List m_CallbackObjects = new List(); + + [SerializeField] + private TestStartedEvent m_TestStartedEvent = new TestStartedEvent(); + + [SerializeField] + private TestFinishedEvent m_TestFinishedEvent = new TestFinishedEvent(); + + [SerializeField] + private RunStartedEvent m_RunStartedEvent = new RunStartedEvent(); + + [SerializeField] + private RunFinishedEvent m_RunFinishedEvent = new RunFinishedEvent(); + + [SerializeField] + private TestRunnerStateSerializer m_TestRunnerStateSerializer = new TestRunnerStateSerializer(); + + [SerializeField] + private bool m_RunningTests; + + [SerializeField] + private TestPlatform m_TestPlatform; + + [SerializeField] + private object m_CurrentYieldObject; + + [SerializeField] + private BeforeAfterTestCommandState m_SetUpTearDownState; + [SerializeField] + private BeforeAfterTestCommandState m_OuterUnityTestActionState; + + [SerializeField] + public bool RunFinished = false; + + public bool RunningSynchronously { get; private set; } + + internal IUnityTestAssemblyRunner m_Runner; + + private ConstructDelegator m_ConstructDelegator; + + private IEnumerator m_RunStep; + + public IUnityTestAssemblyRunnerFactory UnityTestAssemblyRunnerFactory { get; set; } + + public void Init(Filter[] filters, TestPlatform platform, bool runningSynchronously) + { + m_Filters = filters; + m_TestPlatform = platform; + m_AlreadyStartedTests = new List(); + m_ExecutedTests = new List(); + RunningSynchronously = runningSynchronously; + InitRunner(); + } + + private void InitRunner() + { + //We give the EditMode platform here so we dont suddenly create Playmode work items in the test Runner. + m_Runner = (UnityTestAssemblyRunnerFactory ?? new UnityTestAssemblyRunnerFactory()).Create(TestPlatform.EditMode, new EditmodeWorkItemFactory()); + var testAssemblyProvider = new EditorLoadedTestAssemblyProvider(new EditorCompilationInterfaceProxy(), new EditorAssembliesProxy()); + var assemblies = testAssemblyProvider.GetAssembliesGroupedByType(m_TestPlatform).Select(x => x.Assembly).ToArray(); + var loadedTests = m_Runner.Load(assemblies, TestPlatform.EditMode, + UnityTestAssemblyBuilder.GetNUnitTestBuilderSettings(m_TestPlatform)); + loadedTests.ParseForNameDuplicates(); + CallbacksDelegator.instance.TestTreeRebuild(loadedTests); + hideFlags |= HideFlags.DontSave; + EnumerableSetUpTearDownCommand.ActivePcHelper = new EditModePcHelper(); + OuterUnityTestActionCommand.ActivePcHelper = new EditModePcHelper(); + } + + public void OnEnable() + { + if (m_ExecuteOnEnable) + { + InitRunner(); + m_ExecuteOnEnable = false; + foreach (var callback in m_CallbackObjects) + { + AddListeners(callback as ITestRunnerListener); + } + m_ConstructDelegator = new ConstructDelegator(m_TestRunnerStateSerializer); + + EnumeratorStepHelper.SetEnumeratorPC(m_CurrentPC); + + UnityWorkItemDataHolder.alreadyExecutedTests = m_ExecutedTests.Select(x => x.fullName).ToList(); + UnityWorkItemDataHolder.alreadyStartedTests = m_AlreadyStartedTests; + Run(); + } + } + + public void TestStartedEvent(ITest test) + { + m_AlreadyStartedTests.Add(test.FullName); + } + + public void TestFinishedEvent(ITestResult testResult) + { + m_AlreadyStartedTests.Remove(testResult.FullName); + m_ExecutedTests.Add(TestResultSerializer.MakeFromTestResult(testResult)); + } + + public void Run() + { + EditModeTestCallbacks.RestoringTestContext += OnRestoringTest; + var context = m_Runner.GetCurrentContext(); + if (m_SetUpTearDownState == null) + { + m_SetUpTearDownState = CreateInstance(); + } + context.SetUpTearDownState = m_SetUpTearDownState; + + if (m_OuterUnityTestActionState == null) + { + m_OuterUnityTestActionState = CreateInstance(); + } + context.OuterUnityTestActionState = m_OuterUnityTestActionState; + + if (!m_RunningTests) + { + m_RunStartedEvent.Invoke(m_Runner.LoadedTest); + } + + if (m_ConstructDelegator == null) + m_ConstructDelegator = new ConstructDelegator(m_TestRunnerStateSerializer); + + Reflect.ConstructorCallWrapper = m_ConstructDelegator.Delegate; + m_TestStartedEvent.AddListener(TestStartedEvent); + m_TestFinishedEvent.AddListener(TestFinishedEvent); + + AssemblyReloadEvents.beforeAssemblyReload += OnBeforeAssemblyReload; + + RunningTests = true; + + EditorApplication.LockReloadAssemblies(); + + var testListenerWrapper = new TestListenerWrapper(m_TestStartedEvent, m_TestFinishedEvent); + m_RunStep = m_Runner.Run(testListenerWrapper, GetFilter()).GetEnumerator(); + m_RunningTests = true; + + if (!RunningSynchronously) + EditorApplication.update += TestConsumer; + } + + public void CompleteSynchronously() + { + while (!m_Runner.IsTestComplete) + TestConsumer(); + } + + private void OnBeforeAssemblyReload() + { + EditorApplication.update -= TestConsumer; + + if (m_ExecuteOnEnable) + { + AssemblyReloadEvents.beforeAssemblyReload -= OnBeforeAssemblyReload; + return; + } + + if (m_Runner != null && m_Runner.TopLevelWorkItem != null) + m_Runner.TopLevelWorkItem.ResultedInDomainReload = true; + + if (RunningTests) + { + Debug.LogError("TestRunner: Unexpected assembly reload happened while running tests"); + + EditorUtility.ClearProgressBar(); + + if (m_Runner.GetCurrentContext() != null && m_Runner.GetCurrentContext().CurrentResult != null) + { + m_Runner.GetCurrentContext().CurrentResult.SetResult(ResultState.Cancelled, "Unexpected assembly reload happened"); + } + OnRunCancel(); + } + } + + private bool RunningTests; + + private Stack StepStack = new Stack(); + + private bool MoveNextAndUpdateYieldObject() + { + var result = m_RunStep.MoveNext(); + + if (result) + { + m_CurrentYieldObject = m_RunStep.Current; + while (m_CurrentYieldObject is IEnumerator) // going deeper + { + var currentEnumerator = (IEnumerator)m_CurrentYieldObject; + + // go deeper and add parent to stack + StepStack.Push(m_RunStep); + + m_RunStep = currentEnumerator; + m_CurrentYieldObject = m_RunStep.Current; + } + + if (StepStack.Count > 0 && m_CurrentYieldObject != null) // not null and not IEnumerator, nested + { + Debug.LogError("EditMode test can only yield null, but not <" + m_CurrentYieldObject.GetType().Name + ">"); + } + + return true; + } + + if (StepStack.Count == 0) // done + return false; + + m_RunStep = StepStack.Pop(); // going up + return MoveNextAndUpdateYieldObject(); + } + + private void TestConsumer() + { + var moveNext = MoveNextAndUpdateYieldObject(); + + if (m_CurrentYieldObject != null) + { + InvokeDelegator(); + } + + if (!moveNext && !m_Runner.IsTestComplete) + { + CompleteTestRun(); + throw new IndexOutOfRangeException("There are no more elements to process and IsTestComplete is false"); + } + + if (m_Runner.IsTestComplete) + { + CompleteTestRun(); + } + } + + private void CompleteTestRun() + { + if (!RunningSynchronously) + EditorApplication.update -= TestConsumer; + + TestLauncherBase.ExecutePostBuildCleanupMethods(this.GetLoadedTests(), this.GetFilter(), Application.platform); + + m_RunFinishedEvent.Invoke(m_Runner.Result); + RunFinished = true; + + if (m_ConstructDelegator != null) + m_ConstructDelegator.DestroyCurrentTestObjectIfExists(); + Dispose(); + UnityWorkItemDataHolder.alreadyExecutedTests = null; + } + + private void OnRestoringTest() + { + var item = m_ExecutedTests.Find(t => t.fullName == UnityTestExecutionContext.CurrentContext.CurrentTest.FullName); + if (item != null) + { + item.RestoreTestResult(UnityTestExecutionContext.CurrentContext.CurrentResult); + } + } + + private static bool IsCancelled() + { + return UnityTestExecutionContext.CurrentContext.ExecutionStatus == TestExecutionStatus.AbortRequested || UnityTestExecutionContext.CurrentContext.ExecutionStatus == TestExecutionStatus.StopRequested; + } + + private void InvokeDelegator() + { + if (m_CurrentYieldObject == null) + { + return; + } + + if (IsCancelled()) + { + return; + } + + if (m_CurrentYieldObject is RestoreTestContextAfterDomainReload) + { + if (m_TestRunnerStateSerializer.ShouldRestore()) + { + m_TestRunnerStateSerializer.RestoreContext(); + } + + return; + } + + try + { + if (m_CurrentYieldObject is IEditModeTestYieldInstruction) + { + var editModeTestYieldInstruction = (IEditModeTestYieldInstruction)m_CurrentYieldObject; + if (editModeTestYieldInstruction.ExpectDomainReload) + { + PrepareForDomainReload(); + } + return; + } + } + catch (Exception e) + { + UnityTestExecutionContext.CurrentContext.CurrentResult.RecordException(e); + return; + } + + Debug.LogError("EditMode test can only yield null"); + } + + private void CompilationFailureWatch() + { + if (EditorApplication.isCompiling) + return; + + EditorApplication.update -= CompilationFailureWatch; + + if (EditorUtility.scriptCompilationFailed) + { + EditorUtility.ClearProgressBar(); + OnRunCancel(); + } + } + + private void PrepareForDomainReload() + { + m_TestRunnerStateSerializer.SaveContext(); + m_CurrentPC = EnumeratorStepHelper.GetEnumeratorPC(TestEnumerator.Enumerator); + m_ExecuteOnEnable = true; + + RunningTests = false; + } + + public T AddEventHandler() where T : ScriptableObject, ITestRunnerListener + { + var eventHandler = CreateInstance(); + eventHandler.hideFlags |= HideFlags.DontSave; + m_CallbackObjects.Add(eventHandler); + + AddListeners(eventHandler); + + return eventHandler; + } + + private void AddListeners(ITestRunnerListener eventHandler) + { + m_TestStartedEvent.AddListener(eventHandler.TestStarted); + m_TestFinishedEvent.AddListener(eventHandler.TestFinished); + m_RunStartedEvent.AddListener(eventHandler.RunStarted); + m_RunFinishedEvent.AddListener(eventHandler.RunFinished); + } + + public void Dispose() + { + Reflect.MethodCallWrapper = null; + EditorApplication.update -= TestConsumer; + + DestroyImmediate(this); + + if (m_CallbackObjects != null) + { + foreach (var obj in m_CallbackObjects) + { + DestroyImmediate(obj); + } + m_CallbackObjects.Clear(); + } + RunningTests = false; + EditorApplication.UnlockReloadAssemblies(); + } + + public void OnRunCancel() + { + UnityWorkItemDataHolder.alreadyExecutedTests = null; + m_ExecuteOnEnable = false; + m_Runner.StopRun(); + RunFinished = true; + } + + public ITest GetLoadedTests() + { + return m_Runner.LoadedTest; + } + + public ITestFilter GetFilter() + { + return new OrFilter(m_Filters.Select(filter => filter.BuildNUnitFilter(RunningSynchronously)).ToArray()); + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModeRunner.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModeRunner.cs.meta new file mode 100644 index 0000000..faf2358 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditModeRunner.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c9219e99d466b7741a057132d1994f35 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditmodeWorkItemFactory.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditmodeWorkItemFactory.cs new file mode 100644 index 0000000..a81fcdc --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditmodeWorkItemFactory.cs @@ -0,0 +1,14 @@ +using NUnit.Framework.Interfaces; +using NUnit.Framework.Internal; +using UnityEngine.TestRunner.NUnitExtensions.Runner; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class EditmodeWorkItemFactory : WorkItemFactory + { + protected override UnityWorkItem Create(TestMethod method, ITestFilter filter, ITest loadedTest) + { + return new EditorEnumeratorTestWorkItem(method, filter); + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditmodeWorkItemFactory.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditmodeWorkItemFactory.cs.meta new file mode 100644 index 0000000..d775d1f --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditmodeWorkItemFactory.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3dde15f260b0dd1469e60d16eaa795dc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditorEnumeratorTestWorkItem.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditorEnumeratorTestWorkItem.cs new file mode 100644 index 0000000..14d12c2 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditorEnumeratorTestWorkItem.cs @@ -0,0 +1,179 @@ +using System; +using System.Collections; +using NUnit.Framework.Interfaces; +using NUnit.Framework.Internal; +using NUnit.Framework.Internal.Commands; +using NUnit.Framework.Internal.Execution; +using UnityEngine; +using UnityEngine.TestRunner.NUnitExtensions.Runner; +using UnityEngine.TestTools; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class EditorEnumeratorTestWorkItem : UnityWorkItem + { + private TestCommand m_Command; + + public EditorEnumeratorTestWorkItem(TestMethod test, ITestFilter filter) + : base(test, null) + { + m_Command = TestCommandBuilder.BuildTestCommand(test, filter); + } + + private static IEnumerableTestMethodCommand FindFirstIEnumerableTestMethodCommand(TestCommand command) + { + if (command == null) + { + return null; + } + + if (command is IEnumerableTestMethodCommand) + { + return (IEnumerableTestMethodCommand)command; + } + + if (command is DelegatingTestCommand) + { + var delegatingTestCommand = (DelegatingTestCommand)command; + return FindFirstIEnumerableTestMethodCommand(delegatingTestCommand.GetInnerCommand()); + } + return null; + } + + protected override IEnumerable PerformWork() + { + if (IsCancelledRun()) + { + yield break; + } + + if (m_DontRunRestoringResult) + { + if (EditModeTestCallbacks.RestoringTestContext == null) + { + throw new NullReferenceException("RestoringTestContext is not set"); + } + EditModeTestCallbacks.RestoringTestContext(); + Result = Context.CurrentResult; + yield break; + } + + try + { + if (IsCancelledRun()) + { + yield break; + } + + if (m_Command is SkipCommand) + { + m_Command.Execute(Context); + Result = Context.CurrentResult; + yield break; + } + + //Check if we can execute this test + var firstEnumerableCommand = FindFirstIEnumerableTestMethodCommand(m_Command); + if (firstEnumerableCommand == null) + { + Context.CurrentResult.SetResult(ResultState.Error, "Returning IEnumerator but not using test attribute supporting this"); + yield break; + } + + if (m_Command.Test.Method.ReturnType.IsType(typeof(IEnumerator))) + { + if (m_Command is ApplyChangesToContextCommand) + { + var applyChangesToContextCommand = ((ApplyChangesToContextCommand)m_Command); + applyChangesToContextCommand.ApplyChanges(Context); + m_Command = applyChangesToContextCommand.GetInnerCommand(); + } + + var innerCommand = m_Command as IEnumerableTestMethodCommand; + if (innerCommand == null) + { + Debug.Log("failed getting innerCommand"); + throw new Exception("Tests returning IEnumerator can only use test attributes handling those"); + } + + foreach (var workItemStep in innerCommand.ExecuteEnumerable(Context)) + { + if (IsCancelledRun()) + { + yield break; + } + + if (workItemStep is TestEnumerator) + { + if (EnumeratorStepHelper.UpdateEnumeratorPcIfNeeded(TestEnumerator.Enumerator)) + { + yield return new RestoreTestContextAfterDomainReload(); + } + continue; + } + + if (workItemStep is AsyncOperation) + { + var asyncOperation = (AsyncOperation)workItemStep; + while (!asyncOperation.isDone) + { + if (IsCancelledRun()) + { + yield break; + } + + yield return null; + } + continue; + } + + ResultedInDomainReload = false; + + if (workItemStep is IEditModeTestYieldInstruction) + { + var editModeTestYieldInstruction = (IEditModeTestYieldInstruction)workItemStep; + yield return editModeTestYieldInstruction; + var enumerator = editModeTestYieldInstruction.Perform(); + while (true) + { + bool moveNext; + try + { + moveNext = enumerator.MoveNext(); + } + catch (Exception e) + { + Context.CurrentResult.RecordException(e); + break; + } + + if (!moveNext) + { + break; + } + yield return null; + } + } + else + { + yield return workItemStep; + } + } + + Result = Context.CurrentResult; + EditorApplication.isPlaying = false; + yield return null; + } + } + finally + { + WorkItemComplete(); + } + } + + private bool IsCancelledRun() + { + return Context.ExecutionStatus == TestExecutionStatus.AbortRequested || Context.ExecutionStatus == TestExecutionStatus.StopRequested; + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditorEnumeratorTestWorkItem.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditorEnumeratorTestWorkItem.cs.meta new file mode 100644 index 0000000..9007130 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EditorEnumeratorTestWorkItem.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1ebc1994f9a3d5649a1201d3a84b38df +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EnumeratorStepHelper.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EnumeratorStepHelper.cs new file mode 100644 index 0000000..0809a6f --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EnumeratorStepHelper.cs @@ -0,0 +1,51 @@ +using System.Collections; +using System.Reflection; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class EnumeratorStepHelper + { + private static int m_PC; + + public static void SetEnumeratorPC(int pc) + { + m_PC = pc; + } + + /// + /// Gets the current enumerator PC + /// + /// + /// The PC + /// 0 if no current Enumeration + /// + public static int GetEnumeratorPC(IEnumerator enumerator) + { + if (enumerator == null) + { + return 0; + } + return (int)GetPCFieldInfo(enumerator).GetValue(enumerator); + } + + public static bool UpdateEnumeratorPcIfNeeded(IEnumerator enumerator) + { + if (m_PC > 0) + { + GetPCFieldInfo(enumerator).SetValue(enumerator, m_PC); + m_PC = 0; + return true; + } + return false; + } + + private static FieldInfo GetPCFieldInfo(IEnumerator enumerator) + { + var field = enumerator.GetType().GetField("$PC", BindingFlags.NonPublic | BindingFlags.Instance); + if (field == null) // Roslyn + field = enumerator.GetType().GetField("<>1__state", BindingFlags.NonPublic | BindingFlags.Instance); + + return field; + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EnumeratorStepHelper.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EnumeratorStepHelper.cs.meta new file mode 100644 index 0000000..92e993b --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/EnumeratorStepHelper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 901b761c5c1e22d4e8a3ba7d95bc1f5d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages.meta new file mode 100644 index 0000000..64ff2d2 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d9682e749d3efc642af54d789d9090a6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/EnterPlayMode.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/EnterPlayMode.cs new file mode 100644 index 0000000..e1ad8c7 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/EnterPlayMode.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections; +using UnityEditor; + +namespace UnityEngine.TestTools +{ + public class EnterPlayMode : IEditModeTestYieldInstruction + { + public bool ExpectDomainReload { get; } + public bool ExpectedPlaymodeState { get; private set; } + + public EnterPlayMode(bool expectDomainReload = true) + { + ExpectDomainReload = expectDomainReload; + } + + public IEnumerator Perform() + { + if (EditorApplication.isPlaying) + { + throw new Exception("Editor is already in PlayMode"); + } + if (EditorUtility.scriptCompilationFailed) + { + throw new Exception("Script compilation failed"); + } + yield return null; + ExpectedPlaymodeState = true; + + EditorApplication.UnlockReloadAssemblies(); + EditorApplication.isPlaying = true; + + while (!EditorApplication.isPlaying) + { + yield return null; + } + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/EnterPlayMode.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/EnterPlayMode.cs.meta new file mode 100644 index 0000000..f1775e7 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/EnterPlayMode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9bd5a110ed89025499ddee8c7e73778e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/ExitPlayMode.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/ExitPlayMode.cs new file mode 100644 index 0000000..85ef889 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/ExitPlayMode.cs @@ -0,0 +1,32 @@ +using System; +using System.Collections; +using UnityEditor; + +namespace UnityEngine.TestTools +{ + public class ExitPlayMode : IEditModeTestYieldInstruction + { + public bool ExpectDomainReload { get; } + public bool ExpectedPlaymodeState { get; private set; } + + public ExitPlayMode() + { + ExpectDomainReload = false; + ExpectedPlaymodeState = false; + } + + public IEnumerator Perform() + { + if (!EditorApplication.isPlayingOrWillChangePlaymode) + { + throw new Exception("Editor is already in EditMode"); + } + + EditorApplication.isPlaying = false; + while (EditorApplication.isPlaying) + { + yield return null; + } + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/ExitPlayMode.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/ExitPlayMode.cs.meta new file mode 100644 index 0000000..19c058a --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/ExitPlayMode.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 408674d91d506a54aac9a7f07951c018 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/RecompileScripts.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/RecompileScripts.cs new file mode 100644 index 0000000..96dc8f3 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/RecompileScripts.cs @@ -0,0 +1,63 @@ +using System; +using System.Collections; +using UnityEditor; + +namespace UnityEngine.TestTools +{ + public class RecompileScripts : IEditModeTestYieldInstruction + { + public RecompileScripts() : this(true) + { + } + + public RecompileScripts(bool expectScriptCompilation) : this(expectScriptCompilation, true) + { + } + + public RecompileScripts(bool expectScriptCompilation, bool expectScriptCompilationSuccess) + { + ExpectScriptCompilation = expectScriptCompilation; + ExpectScriptCompilationSuccess = expectScriptCompilationSuccess; + ExpectDomainReload = true; + } + + public bool ExpectDomainReload { get; private set; } + public bool ExpectedPlaymodeState { get; } + public bool ExpectScriptCompilation { get; private set; } + public bool ExpectScriptCompilationSuccess { get; private set; } + public static RecompileScripts Current { get; private set; } + + public IEnumerator Perform() + { + Current = this; + + // We need to yield, to give the test runner a chance to prepare for the domain reload + // If the script compilation happens very fast, then EditModeRunner.MoveNextAndUpdateYieldObject will not have a chance to set m_CurrentYieldObject + // This really should be fixed in EditModeRunner.MoveNextAndUpdateYieldObject + yield return null; + + AssetDatabase.Refresh(); + + if (ExpectScriptCompilation && !EditorApplication.isCompiling) + { + Current = null; + throw new Exception("Editor does not need to recompile scripts"); + } + + EditorApplication.UnlockReloadAssemblies(); + + while (EditorApplication.isCompiling) + { + yield return null; + } + + Current = null; + + if (ExpectScriptCompilationSuccess && EditorUtility.scriptCompilationFailed) + { + EditorApplication.LockReloadAssemblies(); + throw new Exception("Script compilation failed"); + } + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/RecompileScripts.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/RecompileScripts.cs.meta new file mode 100644 index 0000000..07895f3 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/RecompileScripts.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 9202fbba95ea8294cb5e718f028f21b0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/WaitForDomainReload.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/WaitForDomainReload.cs new file mode 100644 index 0000000..19920a1 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/WaitForDomainReload.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections; +using UnityEditor; + +namespace UnityEngine.TestTools +{ + public class WaitForDomainReload : IEditModeTestYieldInstruction + { + public WaitForDomainReload() + { + ExpectDomainReload = true; + } + + public bool ExpectDomainReload { get;  } + public bool ExpectedPlaymodeState { get; } + + public IEnumerator Perform() + { + EditorApplication.UnlockReloadAssemblies(); + + // Detect if AssetDatabase.Refresh was called (true) or if it will be called on next tick + bool isAsync = EditorApplication.isCompiling; + + yield return null; + + if (!isAsync) + { + EditorApplication.LockReloadAssemblies(); + throw new Exception("Expected domain reload, but it did not occur"); + } + + while (EditorApplication.isCompiling) + { + yield return null; + } + + if (EditorUtility.scriptCompilationFailed) + { + EditorApplication.LockReloadAssemblies(); + throw new Exception("Script compilation failed"); + } + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/WaitForDomainReload.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/WaitForDomainReload.cs.meta new file mode 100644 index 0000000..b827ea8 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Messages/WaitForDomainReload.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5df3c21c5237c994db89660fbdfee07d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils.meta new file mode 100644 index 0000000..9c23303 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1f5bbb88ca730434483440cbc0278ef6 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/CachingTestListProvider.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/CachingTestListProvider.cs new file mode 100644 index 0000000..9ec2333 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/CachingTestListProvider.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using UnityEditor.TestTools.TestRunner.Api; +using UnityEngine.TestRunner.NUnitExtensions; +using UnityEngine.TestTools; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class CachingTestListProvider + { + private readonly ITestListProvider m_InnerTestListProvider; + private readonly ITestListCache m_TestListCache; + private readonly ITestAdaptorFactory m_TestAdaptorFactory; + public CachingTestListProvider(ITestListProvider innerTestListProvider, ITestListCache testListCache, ITestAdaptorFactory testAdaptorFactory) + { + m_InnerTestListProvider = innerTestListProvider; + m_TestListCache = testListCache; + m_TestAdaptorFactory = testAdaptorFactory; + } + + public IEnumerator GetTestListAsync(TestPlatform platform) + { + var testFromCache = m_TestListCache.GetTestFromCacheAsync(platform); + while (testFromCache.MoveNext()) + { + yield return null; + } + + + if (testFromCache.Current != null) + { + yield return testFromCache.Current; + } + else + { + var test = m_InnerTestListProvider.GetTestListAsync(platform); + while (test.MoveNext()) + { + yield return null; + } + + test.Current.ParseForNameDuplicates(); + m_TestListCache.CacheTest(platform, test.Current); + yield return m_TestAdaptorFactory.Create(test.Current); + } + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/CachingTestListProvider.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/CachingTestListProvider.cs.meta new file mode 100644 index 0000000..2a44a64 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/CachingTestListProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 26f3e7301af463c4ca72fa98d59b429e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssembliesProxy.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssembliesProxy.cs new file mode 100644 index 0000000..ee0e5dc --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssembliesProxy.cs @@ -0,0 +1,13 @@ +using System.Linq; +using UnityEngine.TestTools.Utils; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class EditorAssembliesProxy : IEditorAssembliesProxy + { + public IAssemblyWrapper[] loadedAssemblies + { + get { return EditorAssemblies.loadedAssemblies.OrderBy(a => a.FullName).Select(x => new EditorAssemblyWrapper(x)).ToArray(); } + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssembliesProxy.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssembliesProxy.cs.meta new file mode 100644 index 0000000..711a965 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssembliesProxy.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f96d0ea807c081145a1170ed1b6d71e0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssemblyWrapper.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssemblyWrapper.cs new file mode 100644 index 0000000..8a18b12 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssemblyWrapper.cs @@ -0,0 +1,18 @@ +using System.Reflection; +using UnityEngine.TestTools.Utils; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class EditorAssemblyWrapper : AssemblyWrapper + { + public EditorAssemblyWrapper(Assembly assembly) + : base(assembly) {} + + public override AssemblyName[] GetReferencedAssemblies() + { + return Assembly.GetReferencedAssemblies(); + } + + public override string Location { get { return Assembly.Location; } } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssemblyWrapper.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssemblyWrapper.cs.meta new file mode 100644 index 0000000..14a03af --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorAssemblyWrapper.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 20cdb37e6fea6d946bbb84d2c923db85 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorCompilationInterfaceProxy.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorCompilationInterfaceProxy.cs new file mode 100644 index 0000000..5420719 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorCompilationInterfaceProxy.cs @@ -0,0 +1,17 @@ +using UnityEditor.Scripting.ScriptCompilation; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class EditorCompilationInterfaceProxy : IEditorCompilationInterfaceProxy + { + public ScriptAssembly[] GetAllEditorScriptAssemblies() + { + return EditorCompilationInterface.Instance.GetAllEditorScriptAssemblies(EditorCompilationInterface.GetAdditionalEditorScriptCompilationOptions()); + } + + public PrecompiledAssembly[] GetAllPrecompiledAssemblies() + { + return EditorCompilationInterface.Instance.GetAllPrecompiledAssemblies(); + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorCompilationInterfaceProxy.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorCompilationInterfaceProxy.cs.meta new file mode 100644 index 0000000..41e354d --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorCompilationInterfaceProxy.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c9b23632c77de204abfe8bf7168d48c0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorLoadedTestAssemblyProvider.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorLoadedTestAssemblyProvider.cs new file mode 100644 index 0000000..cffe42d --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorLoadedTestAssemblyProvider.cs @@ -0,0 +1,69 @@ +using System.Collections.Generic; +using System.IO; +using System.Linq; +using UnityEditor.Scripting.ScriptCompilation; +using UnityEngine.TestTools; +using UnityEngine.TestTools.Utils; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class EditorLoadedTestAssemblyProvider : IEditorLoadedTestAssemblyProvider + { + private const string k_NunitAssemblyName = "nunit.framework"; + private const string k_TestRunnerAssemblyName = "UnityEngine.TestRunner"; + internal const string k_PerformanceTestingAssemblyName = "Unity.PerformanceTesting"; + + private readonly IEditorAssembliesProxy m_EditorAssembliesProxy; + private readonly ScriptAssembly[] m_AllEditorScriptAssemblies; + private readonly PrecompiledAssembly[] m_AllPrecompiledAssemblies; + + public EditorLoadedTestAssemblyProvider(IEditorCompilationInterfaceProxy compilationInterfaceProxy, IEditorAssembliesProxy editorAssembliesProxy) + { + m_EditorAssembliesProxy = editorAssembliesProxy; + m_AllEditorScriptAssemblies = compilationInterfaceProxy.GetAllEditorScriptAssemblies(); + m_AllPrecompiledAssemblies = compilationInterfaceProxy.GetAllPrecompiledAssemblies(); + } + + public List GetAssembliesGroupedByType(TestPlatform mode) + { + var assemblies = GetAssembliesGroupedByTypeAsync(mode); + while (assemblies.MoveNext()) + { + } + + return assemblies.Current.Where(pair => mode.IsFlagIncluded(pair.Key)).SelectMany(pair => pair.Value).ToList(); + } + + public IEnumerator>> GetAssembliesGroupedByTypeAsync(TestPlatform mode) + { + IAssemblyWrapper[] loadedAssemblies = m_EditorAssembliesProxy.loadedAssemblies; + + IDictionary> result = new Dictionary>() + { + {TestPlatform.EditMode, new List() }, + {TestPlatform.PlayMode, new List() } + }; + + foreach (var loadedAssembly in loadedAssemblies) + { + if (loadedAssembly.GetReferencedAssemblies().Any(x => x.Name == k_NunitAssemblyName || x.Name == k_TestRunnerAssemblyName || x.Name == k_PerformanceTestingAssemblyName)) + { + var assemblyName = new FileInfo(loadedAssembly.Location).Name; + var scriptAssemblies = m_AllEditorScriptAssemblies.Where(x => x.Filename == assemblyName).ToList(); + var precompiledAssemblies = m_AllPrecompiledAssemblies.Where(x => new FileInfo(x.Path).Name == assemblyName).ToList(); + if (scriptAssemblies.Count < 1 && precompiledAssemblies.Count < 1) + { + continue; + } + + var assemblyFlags = scriptAssemblies.Any() ? scriptAssemblies.Single().Flags : precompiledAssemblies.Single().Flags; + var assemblyType = (assemblyFlags & AssemblyFlags.EditorOnly) == AssemblyFlags.EditorOnly ? TestPlatform.EditMode : TestPlatform.PlayMode; + result[assemblyType].Add(loadedAssembly); + yield return null; + } + } + + yield return result; + } + } +} \ No newline at end of file diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorLoadedTestAssemblyProvider.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorLoadedTestAssemblyProvider.cs.meta new file mode 100644 index 0000000..e2634ad --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/EditorLoadedTestAssemblyProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 033c884ba52437d49bc55935939ef1c6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorAssembliesProxy.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorAssembliesProxy.cs new file mode 100644 index 0000000..30dc758 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorAssembliesProxy.cs @@ -0,0 +1,9 @@ +using UnityEngine.TestTools.Utils; + +namespace UnityEditor.TestTools.TestRunner +{ + internal interface IEditorAssembliesProxy + { + IAssemblyWrapper[] loadedAssemblies { get; } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorAssembliesProxy.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorAssembliesProxy.cs.meta new file mode 100644 index 0000000..51988c7 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorAssembliesProxy.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 98808b11e78f6c84a841a6b4bc5a29d2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorCompilationInterfaceProxy.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorCompilationInterfaceProxy.cs new file mode 100644 index 0000000..330e83b --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorCompilationInterfaceProxy.cs @@ -0,0 +1,10 @@ +using UnityEditor.Scripting.ScriptCompilation; + +namespace UnityEditor.TestTools.TestRunner +{ + internal interface IEditorCompilationInterfaceProxy + { + ScriptAssembly[] GetAllEditorScriptAssemblies(); + PrecompiledAssembly[] GetAllPrecompiledAssemblies(); + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorCompilationInterfaceProxy.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorCompilationInterfaceProxy.cs.meta new file mode 100644 index 0000000..d6a3b78 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorCompilationInterfaceProxy.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 28c8fcb831e6e734a9f564bc4f495eba +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorLoadedTestAssemblyProvider.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorLoadedTestAssemblyProvider.cs new file mode 100644 index 0000000..1e06494 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorLoadedTestAssemblyProvider.cs @@ -0,0 +1,12 @@ +using System.Collections.Generic; +using UnityEngine.TestTools; +using UnityEngine.TestTools.Utils; + +namespace UnityEditor.TestTools.TestRunner +{ + internal interface IEditorLoadedTestAssemblyProvider + { + List GetAssembliesGroupedByType(TestPlatform mode); + IEnumerator>> GetAssembliesGroupedByTypeAsync(TestPlatform mode); + } +} \ No newline at end of file diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorLoadedTestAssemblyProvider.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorLoadedTestAssemblyProvider.cs.meta new file mode 100644 index 0000000..fa0b20b --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/IEditorLoadedTestAssemblyProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 936b6288befc460409cfdff3ac92fc95 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCache.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCache.cs new file mode 100644 index 0000000..9d61724 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCache.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using NUnit.Framework.Interfaces; +using UnityEditor.TestTools.TestRunner.Api; +using UnityEngine.TestTools; + +namespace UnityEditor.TestTools.TestRunner +{ + interface ITestListCache + { + void CacheTest(TestPlatform platform, ITest test); + IEnumerator GetTestFromCacheAsync(TestPlatform platform); + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCache.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCache.cs.meta new file mode 100644 index 0000000..6a5a615 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCache.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a704c010bcdb1ec4a9f3417b3c393164 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCacheData.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCacheData.cs new file mode 100644 index 0000000..3aa14e6 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCacheData.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using NUnit.Framework.Interfaces; +using UnityEngine.TestRunner.TestLaunchers; +using UnityEngine.TestTools; + +namespace UnityEditor.TestTools.TestRunner +{ + interface ITestListCacheData + { + List platforms { get; } + List cachedData { get; } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCacheData.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCacheData.cs.meta new file mode 100644 index 0000000..fd02cd0 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListCacheData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7043e9a330ac2d84a80a965ada4589ad +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListProvider.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListProvider.cs new file mode 100644 index 0000000..5657aca --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListProvider.cs @@ -0,0 +1,11 @@ +using System.Collections.Generic; +using NUnit.Framework.Interfaces; +using UnityEngine.TestTools; + +namespace UnityEditor.TestTools.TestRunner +{ + interface ITestListProvider + { + IEnumerator GetTestListAsync(TestPlatform platform); + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListProvider.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListProvider.cs.meta new file mode 100644 index 0000000..1d84e76 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/ITestListProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 64689f8b25eadac4da519e96f514b653 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCache.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCache.cs new file mode 100644 index 0000000..897b6b3 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCache.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; +using NUnit.Framework.Interfaces; +using UnityEditor.TestTools.TestRunner.Api; +using UnityEngine.TestRunner.TestLaunchers; +using UnityEngine.TestTools; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class TestListCache : ITestListCache + { + private readonly ITestAdaptorFactory m_TestAdaptorFactory; + private readonly IRemoteTestResultDataFactory m_TestResultDataFactory; + private readonly ITestListCacheData m_TestListCacheData; + + public TestListCache(ITestAdaptorFactory testAdaptorFactory, IRemoteTestResultDataFactory testResultDataFactory, ITestListCacheData testListCacheData) + { + m_TestAdaptorFactory = testAdaptorFactory; + m_TestResultDataFactory = testResultDataFactory; + m_TestListCacheData = testListCacheData; + } + + public void CacheTest(TestPlatform platform, ITest test) + { + var index = m_TestListCacheData.platforms.IndexOf(platform); + if (index < 0) + { + m_TestListCacheData.cachedData.Add(test); + m_TestListCacheData.platforms.Add(platform); + } + else + { + m_TestListCacheData.cachedData[index] = test; + } + } + + public IEnumerator GetTestFromCacheAsync(TestPlatform platform) + { + var index = m_TestListCacheData.platforms.IndexOf(platform); + if (index < 0) + { + yield return null; + yield break; + } + + var testData = m_TestListCacheData.cachedData[index]; + yield return m_TestAdaptorFactory.Create(testData); + } + + [Callbacks.DidReloadScripts] + private static void ScriptReloaded() + { + TestListCacheData.instance.cachedData.Clear(); + TestListCacheData.instance.platforms.Clear(); + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCache.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCache.cs.meta new file mode 100644 index 0000000..fae5fd1 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCache.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d685d97a1eb004f49afea0cc982ff728 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCacheData.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCacheData.cs new file mode 100644 index 0000000..8081b57 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCacheData.cs @@ -0,0 +1,27 @@ +using System.Collections.Generic; +using NUnit.Framework.Interfaces; +using UnityEngine; +using UnityEngine.TestRunner.TestLaunchers; +using UnityEngine.TestTools; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class TestListCacheData : ScriptableSingleton, ITestListCacheData + { + [SerializeField] + private List m_Platforms = new List(); + + [SerializeField] + private List m_CachedData = new List(); + + public List platforms + { + get { return m_Platforms; } + } + + public List cachedData + { + get { return m_CachedData; } + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCacheData.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCacheData.cs.meta new file mode 100644 index 0000000..ba5bab6 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListCacheData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f1b6399349763114d9361bc6dfcd025b +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListJob.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListJob.cs new file mode 100644 index 0000000..1864c78 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListJob.cs @@ -0,0 +1,36 @@ +using System; +using System.Collections.Generic; +using UnityEditor.TestTools.TestRunner.Api; +using UnityEngine.TestTools; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class TestListJob + { + private CachingTestListProvider m_TestListProvider; + private TestPlatform m_Platform; + private Action m_Callback; + private IEnumerator m_ResultEnumerator; + public TestListJob(CachingTestListProvider testListProvider, TestPlatform platform, Action callback) + { + m_TestListProvider = testListProvider; + m_Platform = platform; + m_Callback = callback; + } + + public void Start() + { + m_ResultEnumerator = m_TestListProvider.GetTestListAsync(m_Platform); + EditorApplication.update += EditorUpdate; + } + + private void EditorUpdate() + { + if (!m_ResultEnumerator.MoveNext()) + { + m_Callback(m_ResultEnumerator.Current); + EditorApplication.update -= EditorUpdate; + } + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListJob.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListJob.cs.meta new file mode 100644 index 0000000..38f8af8 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListJob.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dec9066d4afefe444be0dad3f137730d +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListProvider.cs b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListProvider.cs new file mode 100644 index 0000000..e1402a6 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListProvider.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using NUnit.Framework.Interfaces; +using UnityEngine.TestTools; +using UnityEngine.TestTools.NUnitExtensions; + +namespace UnityEditor.TestTools.TestRunner +{ + internal class TestListProvider : ITestListProvider + { + private readonly EditorLoadedTestAssemblyProvider m_AssemblyProvider; + private readonly UnityTestAssemblyBuilder m_AssemblyBuilder; + + public TestListProvider(EditorLoadedTestAssemblyProvider assemblyProvider, UnityTestAssemblyBuilder assemblyBuilder) + { + m_AssemblyProvider = assemblyProvider; + m_AssemblyBuilder = assemblyBuilder; + } + + public IEnumerator GetTestListAsync(TestPlatform platform) + { + var assembliesTask = m_AssemblyProvider.GetAssembliesGroupedByTypeAsync(platform); + while (assembliesTask.MoveNext()) + { + yield return null; + } + + var assemblies = assembliesTask.Current.Where(pair => platform.IsFlagIncluded(pair.Key)) + .SelectMany(pair => pair.Value.Select(assemblyInfo => Tuple.Create(assemblyInfo.Assembly, pair.Key))).ToArray(); + + var settings = UnityTestAssemblyBuilder.GetNUnitTestBuilderSettings(platform); + var test = m_AssemblyBuilder.BuildAsync(assemblies.Select(a => a.Item1).ToArray(), assemblies.Select(a => a.Item2).ToArray(), settings); + while (test.MoveNext()) + { + yield return null; + } + + yield return test.Current; + } + } +} diff --git a/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListProvider.cs.meta b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListProvider.cs.meta new file mode 100644 index 0000000..975a1a3 --- /dev/null +++ b/Library/PackageCache/com.unity.test-framework@1.1.11/UnityEditor.TestRunner/TestRunner/Utils/TestListProvider.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: f15cbb987069826429540d0ea0937442 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: -- cgit v1.2.3