This commit is contained in:
2025-01-17 13:10:42 +01:00
commit 4536213c91
15115 changed files with 1442174 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4926c06156894939ba0a2680f1b0aa7a
timeCreated: 1658837036

View File

@@ -0,0 +1,23 @@
using System;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.TestRun
{
[Serializable]
internal class RunProgress
{
public const float progressPrTask = 0.0075f;
[SerializeField]
public float progressPrTest;
[SerializeField]
public float progress;
[SerializeField]
public string stageName;
[SerializeField]
public string stepName;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 19bb2cdbf1454aae9b90c628fb83ad9b
timeCreated: 1659007231

View File

@@ -0,0 +1,21 @@
using System;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.TestRun
{
[Serializable]
internal class TaskInfo
{
[SerializeField]
public int index;
[SerializeField]
public int stopBeforeIndex;
[SerializeField]
public int pc;
[SerializeField]
public TaskMode taskMode = TaskMode.Normal;
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 0d2e1e2a782748e6acb8565ad040df60
timeCreated: 1658837043

View File

@@ -0,0 +1,13 @@
using System;
namespace UnityEditor.TestTools.TestRunner.TestRun
{
internal enum TaskMode
{
Normal,
Error,
Resume,
EnteredEditMode,
Canceled,
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 06e624de88cb4a808350b63994eb39ed
timeCreated: 1658837058

View File

@@ -0,0 +1,157 @@
using System;
using System.Collections.Generic;
using NUnit.Framework.Interfaces;
using UnityEditor.SceneManagement;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEditor.TestTools.TestRunner.TestRun.Tasks;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
using UnityEngine.TestTools;
using UnityEngine.TestTools.NUnitExtensions;
using UnityEngine.TestTools.TestRunner;
namespace UnityEditor.TestTools.TestRunner.TestRun
{
[Serializable]
internal class TestJobData : ISerializationCallbackReceiver
{
[SerializeField]
public string guid;
[SerializeField]
public string startTime;
[NonSerialized]
public Stack<TaskInfo> taskInfoStack = new Stack<TaskInfo>();
[SerializeField]
public int taskPC;
[SerializeField]
public bool isRunning;
[SerializeField]
public ExecutionSettings executionSettings;
[SerializeField]
public RunProgress runProgress = new RunProgress();
[SerializeField]
public string[] existingFiles;
[SerializeField]
public int undoGroup = -1;
[SerializeField]
public EditModeRunner editModeRunner;
[SerializeField]
public BeforeAfterTestCommandState setUpTearDownState;
[SerializeField]
public BeforeAfterTestCommandState outerUnityTestActionState;
[SerializeField]
public TestRunnerStateSerializer testRunnerStateSerializer;
[SerializeField]
public EnumerableTestState enumerableTestState;
[SerializeField]
private TaskInfo[] savedTaskInfoStack;
[NonSerialized]
public bool isHandledByRunner;
[SerializeField]
public SceneSetup[] SceneSetup;
[NonSerialized]
public TestTaskBase[] Tasks;
[SerializeField]
public TestProgress testProgress;
public ITest testTree;
[NonSerialized]
public ITestFilter testFilter;
[NonSerialized]
public TestStartedEvent TestStartedEvent;
[NonSerialized]
public TestFinishedEvent TestFinishedEvent;
[NonSerialized]
public RunStartedEvent RunStartedEvent;
[NonSerialized]
public RunFinishedEvent RunFinishedEvent;
[NonSerialized]
public UnityTestExecutionContext Context;
[NonSerialized]
public ConstructDelegator ConstructDelegator;
[NonSerialized]
public ITestResult TestResults;
[SerializeField]
public Scene InitTestScene;
[SerializeField]
public string InitTestScenePath;
[SerializeField]
public BuildPlayerOptions PlayerBuildOptions;
[SerializeField]
public PlaymodeTestsController PlaymodeTestsController;
[SerializeField]
public PlaymodeTestsControllerSettings PlayModeSettings;
[SerializeField]
public PlatformSpecificSetup PlatformSpecificSetup;
[NonSerialized]
public RuntimePlatform? TargetRuntimePlatform;
[SerializeField]
public EnumerableTestState RetryRepeatState;
[SerializeField]
public SavedProjectSettings OriginalProjectSettings;
[SerializeField]
public int UserApplicationIdleTime = -1;
[SerializeField]
public int UserInteractionMode = -1;
public TestJobData(ExecutionSettings settings)
{
guid = Guid.NewGuid().ToString();
executionSettings = settings;
isRunning = false;
startTime = DateTime.Now.ToString("o");
}
public void OnBeforeSerialize()
{
savedTaskInfoStack = taskInfoStack.ToArray();
}
public void OnAfterDeserialize()
{
taskInfoStack = new Stack<TaskInfo>(savedTaskInfoStack);
}
[Serializable]
internal class SavedProjectSettings
{
public bool runInBackgroundValue;
public bool consoleErrorPaused;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 80ac8f5b2a7fa904dbc80111be88c8be
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.TestRun
{
[Serializable]
internal class TestProgress
{
[SerializeField]
public string CurrentTest;
[SerializeField]
public string[] AllTestsToRun;
[SerializeField]
public List<string> RemainingTests;
[SerializeField]
public List<string> CompletedTests;
public TestProgress(string[] allTestsToRun)
{
AllTestsToRun = allTestsToRun;
RemainingTests = allTestsToRun.ToList();
CompletedTests = new List<string>();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 881a6e4afaf6d1744a7aacea7f268f4c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,12 @@
using System;
namespace UnityEditor.TestTools.TestRunner.TestRun
{
internal interface ITestJobDataHolder
{
void RegisterRun(ITestJobRunner runner, TestJobData data);
void UnregisterRun(ITestJobRunner runner, TestJobData data);
ITestJobRunner GetRunner(string guid);
ITestJobRunner[] GetAllRunners();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 7d0a7ea6062a4f42bcea6cb642817537
timeCreated: 1658838617

View File

@@ -0,0 +1,12 @@
using System;
namespace UnityEditor.TestTools.TestRunner.TestRun
{
internal interface ITestJobRunner
{
string RunJob(TestJobData data);
bool CancelRun();
bool IsRunningJob();
TestJobData GetData();
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 8173ba5b162e4e5882521d173c36acec
timeCreated: 1582105869

View File

@@ -0,0 +1,14 @@
using System;
namespace UnityEditor.TestTools.TestRunner.TestRun
{
internal class RequiredTestRunDataMissingException : Exception
{
public RequiredTestRunDataMissingException(string fieldName) : base($"The test run data '{fieldName}' is required and could not be found.")
{
FieldName = fieldName;
}
public string FieldName;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 416b65350c010294db54ceca7fd02072
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,96 @@
using System;
using System.Collections.Generic;
using UnityEditor.SceneManagement;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEditor.TestTools.TestRunner.TestRun.Tasks;
using UnityEditor.TestTools.TestRunner.TestRun.Tasks.Events;
using UnityEditor.TestTools.TestRunner.TestRun.Tasks.Platform;
using UnityEditor.TestTools.TestRunner.TestRun.Tasks.Player;
using UnityEditor.TestTools.TestRunner.TestRun.Tasks.Scene;
using UnityEngine.TestTools;
namespace UnityEditor.TestTools.TestRunner.TestRun
{
// Note: Indentation of the tasklist is purposefully incorrect, to ease comparison with the 2.0 tasklist.
internal static class TaskList
{
public static IEnumerable<TestTaskBase> GetTaskList(ExecutionSettings settings)
{
if (settings == null)
{
yield break;
}
if (settings.PlayerIncluded())
{
yield return new SaveModifiedSceneTask();
yield return new StoreSceneSetupTask();
yield return new CreateBootstrapSceneTask(true, true, NewSceneSetup.EmptyScene);
yield return new DetermineRuntimePlatformTask();
yield return new PlatformSpecificSetupTask();
yield return new LegacyPlayerRunTask();
yield return new PlatformSpecificPostBuildTask();
yield return new PlatformSpecificSuccessfulBuildTask();
yield return new PlatformSpecificSuccessfulLaunchTask();
yield return new WaitForPlayerRunTask();
yield return new PlatformSpecificCleanupTask();
yield return new RestoreSceneSetupTask();
yield return new DeleteBootstrapSceneTask();
yield return new UnlockReloadAssembliesTask();
yield break;
}
// ReSharper disable once BadControlBracesIndent
var editMode = settings.EditModeIncluded() || (PlayerSettings.runPlayModeTestAsEditModeTest && settings.PlayModeInEditorIncluded());
if (!editMode)
{
yield return new MarkRunAsPlayModeTask();
}
yield return new SaveModifiedSceneTask();
yield return new RegisterFilesForCleanupVerificationTask();
yield return new SaveUndoIndexTask();
yield return new StoreSceneSetupTask();
yield return new SetInteractionModeTask();
yield return new RemoveAdditionalUntitledSceneTask();
yield return new ReloadModifiedScenesTask();
yield return new BuildNUnitFilterTask();
yield return new BuildTestTreeTask(editMode ? TestPlatform.EditMode : TestPlatform.PlayMode);
yield return new CreateBootstrapSceneTask(!editMode, !editMode, editMode ? NewSceneSetup.DefaultGameObjects : NewSceneSetup.EmptyScene);
yield return new CreateEventsTask();
yield return new RegisterCallbackDelegatorEventsTask();
yield return new RegisterTestRunCallbackEventsTask();
yield return new PrebuildSetupTask();
yield return new EnableTestOutLoggerTask();
yield return new InitializeTestProgressTask();
yield return new UpdateTestProgressTask();
if (editMode)
{
yield return new GenerateContextTask();
yield return new SetupConstructDelegatorTask();
yield return new RunStartedInvocationEvent();
yield return new EditModeRunTask();
yield return new RunFinishedInvocationEvent();
yield return new CleanupConstructDelegatorTask();
}
else
{
yield return new GenerateContextTask();
yield return new PreparePlayModeRunTask();
yield return new EnterPlayModeTask();
yield return new PlayModeRunTask();
yield return new ExitPlayModeTask();
yield return new RestoreProjectSettingsTask();
yield return new CleanupTestControllerTask();
}
yield return new PostbuildCleanupTask();
yield return new CleanUpContext();
yield return new ResetInteractionModeTask();
yield return new RestoreSceneSetupTask();
yield return new DeleteBootstrapSceneTask();
yield return new PerformUndoTask();
yield return new CleanupVerificationTask();
yield return new UnlockReloadAssembliesTask();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: b1516a46a16d458e8debc6b459b107ea
timeCreated: 1658846478

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6dba53789da15814387fa5b1445e81e0
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,72 @@
using System;
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework.Interfaces;
using UnityEngine;
using UnityEngine.TestTools.Logging;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal abstract class BuildActionTaskBase<T> : TestTaskBase
{
private string typeName;
internal IAttributeFinder attributeFinder;
internal Action<string> logAction = Debug.Log;
internal Func<ILogScope> logScopeProvider = () => new LogScope();
internal Func<Type, object> createInstance = Activator.CreateInstance;
protected BuildActionTaskBase(IAttributeFinder attributeFinder)
{
this.attributeFinder = attributeFinder;
typeName = typeof(T).Name;
}
protected abstract void Action(T target);
public override IEnumerator Execute(TestJobData testJobData)
{
if (testJobData.testTree == null)
{
throw new Exception($"Test tree is not available for {GetType().Name}.");
}
var enumerator = ExecuteMethods(testJobData.testTree, testJobData.testFilter, testJobData.TargetRuntimePlatform ?? Application.platform);
while (enumerator.MoveNext())
{
yield return null;
}
}
private IEnumerator ExecuteMethods(ITest testTree, ITestFilter testRunnerFilter, RuntimePlatform targetPlatform)
{
var exceptions = new List<Exception>();
foreach (var targetClassType in attributeFinder.Search(testTree, testRunnerFilter, targetPlatform))
{
try
{
var targetClass = (T)createInstance(targetClassType);
logAction($"Executing {typeName} for: {targetClassType.FullName}.");
using (var logScope = logScopeProvider())
{
Action(targetClass);
logScope.EvaluateLogScope(true);
}
}
catch (Exception ex)
{
exceptions.Add(ex);
}
}
if (exceptions.Count > 0)
{
throw new AggregateException($"One or more exceptions when executing {typeName}.", exceptions);
}
yield break;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: c2441d353f9c42a44af6e224e4901b52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using System.Collections;
using System.Linq;
using NUnit.Framework.Interfaces;
using NUnit.Framework.Internal.Filters;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class BuildNUnitFilterTask : TestTaskBase
{
public BuildNUnitFilterTask()
{
RerunAfterResume = true;
}
public override IEnumerator Execute(TestJobData testJobData)
{
var executionSettings = testJobData.executionSettings;
ITestFilter filter = new OrFilter(executionSettings.filters.Select(f => f.ToRuntimeTestRunnerFilter(executionSettings.runSynchronously).BuildNUnitFilter()).ToArray());
testJobData.testFilter = filter;
yield return null;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5640d0c51961421997c9f36f0ec45480
timeCreated: 1594728627

View File

@@ -0,0 +1,61 @@
using System;
using System.Collections;
using System.Linq;
using UnityEditor.TestTools.TestRunner.Api;
using UnityEngine.TestTools;
using UnityEngine.TestTools.NUnitExtensions;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class BuildTestTreeTask : TestTaskBase
{
private TestPlatform m_TestPlatform;
public BuildTestTreeTask(TestPlatform testPlatform)
{
m_TestPlatform = testPlatform;
RerunAfterResume = true;
}
internal IEditorLoadedTestAssemblyProvider m_testAssemblyProvider = new EditorLoadedTestAssemblyProvider(new EditorCompilationInterfaceProxy(), new EditorAssembliesProxy());
internal Func<string[], int, IAsyncTestAssemblyBuilder> m_testAssemblyBuilderFactory = (orderedTestNames, seed) => new UnityTestAssemblyBuilder(orderedTestNames, seed);
internal ICallbacksDelegator m_CallbacksDelegator = CallbacksDelegator.instance;
public override IEnumerator Execute(TestJobData testJobData)
{
if (testJobData.testTree != null)
{
yield break;
}
var assembliesEnumerator = m_testAssemblyProvider.GetAssembliesGroupedByTypeAsync(m_TestPlatform);
while (assembliesEnumerator.MoveNext())
{
yield return null;
}
if (assembliesEnumerator.Current == null)
{
throw new Exception("Assemblies not retrieved.");
}
var assemblies = assembliesEnumerator.Current.Where(pair => m_TestPlatform.IsFlagIncluded(pair.Key)).SelectMany(pair => pair.Value).Select(x => x.Assembly).ToArray();
var buildSettings = UnityTestAssemblyBuilder.GetNUnitTestBuilderSettings(m_TestPlatform);
var testAssemblyBuilder = m_testAssemblyBuilderFactory(testJobData.executionSettings.orderedTestNames, testJobData.executionSettings.randomOrderSeed);
var enumerator = testAssemblyBuilder.BuildAsync(assemblies, Enumerable.Repeat(m_TestPlatform, assemblies.Length).ToArray(), buildSettings);
while (enumerator.MoveNext())
{
yield return null;
}
var testList = enumerator.Current;
if (testList== null)
{
throw new Exception("Test list not retrieved.");
}
testJobData.testTree = testList;
m_CallbacksDelegator.TestTreeRebuild(testList);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: a0288e1c9324e824bab7e2044a72a434
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections;
using NUnit.Framework;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class CleanUpContext : TestTaskBase
{
public override IEnumerator Execute(TestJobData testJobData)
{
testJobData.Context = null;
TestContext.CurrentTestExecutionContext = null;
yield break;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1c97cd557b334b27bc325649466d1872
timeCreated: 1669207857

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class CleanupConstructDelegatorTask : TestTaskBase
{
public override IEnumerator Execute(TestJobData testJobData)
{
testJobData.ConstructDelegator.DestroyCurrentTestObjectIfExists();
yield break;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a155fee568ce42a4b561ee3a27d88532
timeCreated: 1584451388

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using UnityEngine.TestTools.TestRunner;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class CleanupTestControllerTask : TestTaskBase
{
public CleanupTestControllerTask()
{
RunOnCancel = true;
RunOnError = ErrorRunMode.RunAlways;
}
public override IEnumerator Execute(TestJobData testJobData)
{
if (testJobData.PlaymodeTestsController == null)
{
yield break;
}
testJobData.PlaymodeTestsController.Cleanup();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 822fa0a65be2467b95721422157c93f0
timeCreated: 1695389918

View File

@@ -0,0 +1,59 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.TestRunner.NUnitExtensions.Runner;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class CleanupVerificationTask : FileCleanupVerifierTaskBase
{
private const string k_Indent = " ";
internal Action<object> logWarning = Debug.LogWarning;
internal Action<object> logError = Debug.LogError;
public override IEnumerator Execute(TestJobData testJobData)
{
var currentFiles = GetAllFilesInAssetsDirectory();
var existingFiles = testJobData.existingFiles;
if (currentFiles.Length != existingFiles.Length)
{
var existingFilesHashSet = new HashSet<string>(existingFiles);
var newFiles = currentFiles.Where(file => !existingFilesHashSet.Contains(file)).ToArray();
LogWarningForFilesIfAny(newFiles, testJobData.executionSettings.featureFlags.fileCleanUpCheck);
}
yield return null;
}
private void LogWarningForFilesIfAny(string[] filePaths, bool fileCleanUpCheck)
{
if (filePaths.Length == 0)
{
return;
}
var stringWriter = new StringWriter();
stringWriter.WriteLine("Files generated by test without cleanup.");
stringWriter.WriteLine(k_Indent + "Found {0} new files.", filePaths.Length);
foreach (var filePath in filePaths)
{
stringWriter.WriteLine(k_Indent + filePath);
}
if (fileCleanUpCheck)
{
logError(stringWriter.ToString());
}
else
{
logWarning(stringWriter.ToString());
}
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 93eb6389f4fb6924987867ce0bc339ee
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,74 @@
using System;
using System.Collections;
using System.Linq;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.TestTools;
using UnityEngine.TestTools.TestRunner;
using Object = UnityEngine.Object;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class CreateBootstrapSceneTask : TestTaskBase
{
private bool m_includeTestController;
private bool m_saveScene;
private NewSceneSetup m_SceneSetup;
public CreateBootstrapSceneTask(bool mIncludeTestController, bool saveScene, NewSceneSetup sceneSetup)
{
m_includeTestController = mIncludeTestController;
m_saveScene = saveScene;
m_SceneSetup = sceneSetup;
}
public override IEnumerator Execute(TestJobData testJobData)
{
if (m_saveScene)
{
testJobData.InitTestScenePath = "Assets/InitTestScene" + Guid.NewGuid() + ".unity";
}
testJobData.InitTestScene = EditorSceneManager.NewScene(m_SceneSetup, NewSceneMode.Single);
/* This code from 2.0 is likely not needed and can be removed once backporting has finished.
while (PlaymodeTestsController.IsControllerOnScene())
{
var gameObject = PlaymodeTestsController.GetController().gameObject;
Object.DestroyImmediate(gameObject);
}
*/
var settings = PlaymodeTestsControllerSettings.CreateRunnerSettings(testJobData.executionSettings.filters
.Select(filter => filter.ToRuntimeTestRunnerFilter(testJobData.executionSettings.runSynchronously)).ToArray(), testJobData.executionSettings.orderedTestNames,
testJobData.executionSettings.randomOrderSeed, testJobData.executionSettings.featureFlags, testJobData.executionSettings.retryCount, testJobData.executionSettings.repeatCount, IsAutomated());
if (m_includeTestController)
{
var go = new GameObject(PlaymodeTestsController.kPlaymodeTestControllerName);
var editorLoadedTestAssemblyProvider =
new EditorLoadedTestAssemblyProvider(new EditorCompilationInterfaceProxy(),
new EditorAssembliesProxy());
var runner = go.AddComponent<PlaymodeTestsController>();
runner.AssembliesWithTests = editorLoadedTestAssemblyProvider
.GetAssembliesGroupedByType(TestPlatform.PlayMode).Select(x => x.Assembly.GetName().Name)
.ToList();
runner.settings = settings;
testJobData.PlaymodeTestsController = runner;
}
testJobData.PlayModeSettings = settings;
if (m_saveScene)
{
EditorSceneManager.MarkSceneDirty(testJobData.InitTestScene);
AssetDatabase.SaveAssets();
EditorSceneManager.SaveScene(testJobData.InitTestScene, testJobData.InitTestScenePath, false);
}
yield break;
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4400cdda235b4ea48b9078953ffc8e89
timeCreated: 1695384344

View File

@@ -0,0 +1,24 @@
using System;
using System.Collections;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class DeleteBootstrapSceneTask : TestTaskBase
{
public DeleteBootstrapSceneTask()
{
RunOnError = ErrorRunMode.RunAlways;
RunOnCancel = true;
}
public override IEnumerator Execute(TestJobData testJobData)
{
if (string.IsNullOrEmpty(testJobData.InitTestScenePath))
{
yield break;
}
AssetDatabase.DeleteAsset(testJobData.InitTestScenePath);
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 6465fa5b49fc4c739059189aca21f391
timeCreated: 1695390255

View File

@@ -0,0 +1,55 @@
using System;
using System.Collections;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class EditModeRunTask : TestTaskBase
{
public EditModeRunTask()
{
SupportsResumingEnumerator = true;
RerunAfterResume = true;
}
public override IEnumerator Execute(TestJobData testJobData)
{
if (testJobData.taskInfoStack.Peek().taskMode == TaskMode.Canceled)
{
var runner = testJobData.editModeRunner;
if (runner != null)
{
runner.OnRunCancel();
}
yield break;
}
else if (testJobData.taskInfoStack.Peek().taskMode == TaskMode.Resume)
{
var runner = testJobData.editModeRunner;
if (runner == null)
{
yield break;
}
runner.Resume(testJobData.executionSettings.BuildNUnitFilter(), testJobData.testTree, testJobData.TestStartedEvent, testJobData.TestFinishedEvent, testJobData.Context);
yield break;
}
yield return null; // Allow for setting the test job data after a resume.
var editModeRunner = ScriptableObject.CreateInstance<EditModeRunner>();
testJobData.editModeRunner = editModeRunner;
editModeRunner.UnityTestAssemblyRunnerFactory = new UnityTestAssemblyRunnerFactory();
editModeRunner.Init(testJobData.executionSettings.BuildNUnitFilter(), testJobData.executionSettings.runSynchronously, testJobData.testTree, testJobData.TestStartedEvent,
testJobData.TestFinishedEvent, testJobData.Context, testJobData.executionSettings.orderedTestNames, testJobData.executionSettings.randomOrderSeed, testJobData.executionSettings.featureFlags.disableNestedEnumeratorBugfix);
while (testJobData.editModeRunner != null && !testJobData.editModeRunner.RunFinished)
{
testJobData.editModeRunner.TestConsumer(testJobData.testRunnerStateSerializer);
yield return null;
}
testJobData.TestResults = testJobData.editModeRunner.m_Runner.Result;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b4246555189b5ee43b4857220f9fd29b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,68 @@
using System;
using System.Collections;
using System.IO;
using NUnit.Framework;
using UnityEditor.TestTools.TestRunner.UnityTestProtocol;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class EnableTestOutLoggerTask : TestTaskBase, IDisposable
{
internal Action<Action<PlayModeStateChange>> SubscribePlayModeStateChanged = callback =>
EditorApplication.playModeStateChanged += callback;
internal Action<Action<PlayModeStateChange>> UnsubscribePlayModeStateChanged = callback =>
EditorApplication.playModeStateChanged -= callback;
internal Action<Application.LogCallback> SubscribeLogMessageReceivedThreaded =
callback => Application.logMessageReceived += callback;
internal Action<Application.LogCallback> UnsubscribeLogMessageReceivedThreaded =
callback => Application.logMessageReceived -= callback;
internal Func<TextWriter> GetCurrentContextWriter = () => TestContext.Out;
public EnableTestOutLoggerTask()
{
RerunAfterResume = true;
}
public override IEnumerator Execute(TestJobData testJobData)
{
SubscribePlayModeStateChanged(WaitForExitPlaymode);
SubscribeLogMessageReceivedThreaded(LogReceived);
yield break;
}
private void WaitForExitPlaymode(PlayModeStateChange state)
{
if (state == PlayModeStateChange.EnteredEditMode)
{
UnsubscribePlayModeStateChanged(WaitForExitPlaymode);
UnsubscribeLogMessageReceivedThreaded(LogReceived);
SubscribeLogMessageReceivedThreaded(LogReceived);
}
}
private void LogReceived(string message, string stacktrace, LogType type)
{
if (message.StartsWith(UtpDebugLogger.UtpPrefix))
{
return;
}
var writer = GetCurrentContextWriter();
if (writer != null)
{
writer.WriteLine(message);
if (type == LogType.Exception)
{
writer.WriteLine(stacktrace);
}
}
}
public void Dispose()
{
UnsubscribeLogMessageReceivedThreaded(LogReceived);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1a9f3fcee3bd2334593373b00d7b5ca2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections;
using UnityEngine;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks
{
internal class EnterPlayModeTask : TestTaskBase
{
public Func<bool> IsInPlayMode = () => Application.isPlaying;
public Action EnterPlayMode = () => EditorApplication.isPlaying = true;
public override IEnumerator Execute(TestJobData testJobData)
{
if (IsInPlayMode())
{
yield break;
}
// Give the UI a change to update the progress bar, sa entering playmode freezes.
yield return null;
EnterPlayMode();
while (!IsInPlayMode())
{
yield return null;
}
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 4b45f42910304b00a63958173ee2c76f
timeCreated: 1588855708

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: cca5935142d6c754f9ecdce1294f7079
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,25 @@
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.TestTools.TestRunner;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Events
{
internal class CreateEventsTask : TestTaskBase
{
public CreateEventsTask()
{
RerunAfterResume = true;
}
public override IEnumerator Execute(TestJobData testJobData)
{
testJobData.RunStartedEvent = new RunStartedEvent();
testJobData.TestStartedEvent = new TestStartedEvent();
testJobData.TestFinishedEvent = new TestFinishedEvent();
testJobData.RunFinishedEvent = new RunFinishedEvent();
yield break;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f2675f346a0926b4aa7928805fd8bc9c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections;
using UnityEditor.TestTools.TestRunner.Api;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Events
{
internal class RegisterCallbackDelegatorEventsTask : TestTaskBase
{
public RegisterCallbackDelegatorEventsTask()
{
RerunAfterResume = true;
}
internal ICallbacksDelegator ApiCallbacksDelegator = CallbacksDelegator.instance;
public override IEnumerator Execute(TestJobData testJobData)
{
ApiCallbacksDelegator.SetTestRunFilter(testJobData.executionSettings.BuildNUnitFilter());
testJobData.RunStartedEvent.AddListener(ApiCallbacksDelegator.RunStarted);
testJobData.TestStartedEvent.AddListener(ApiCallbacksDelegator.TestStarted);
testJobData.TestFinishedEvent.AddListener(ApiCallbacksDelegator.TestFinished);
testJobData.RunFinishedEvent.AddListener(ApiCallbacksDelegator.RunFinished);
yield break;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 311d065aced2092409deadf0c0934f61
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections;
using UnityEngine;
using UnityEngine.TestRunner.Utils;
namespace UnityEditor.TestTools.TestRunner.TestRun.Tasks.Events
{
internal class RegisterTestRunCallbackEventsTask : TestTaskBase
{
public RegisterTestRunCallbackEventsTask()
{
RerunAfterResume = true;
}
internal Func<TestRunCallbackListener> GetListener = () => ScriptableObject.CreateInstance<TestRunCallbackListener>();
public override IEnumerator Execute(TestJobData testJobData)
{
var listener = GetListener();
testJobData.RunStartedEvent.AddListener(v => listener.RunStarted(v));
testJobData.TestStartedEvent.AddListener(v => listener.TestStarted(v));
testJobData.TestFinishedEvent.AddListener(v => listener.TestFinished(v));
testJobData.RunFinishedEvent.AddListener(v => listener.RunFinished(v));
yield break;
}
}
}

Some files were not shown because too many files have changed in this diff Show More