No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ExitCallbacks.cs 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. using System;
  2. using UnityEditor.TestTools.TestRunner.Api;
  3. using UnityEngine;
  4. namespace UnityEditor.TestTools.TestRunner.CommandLineTest
  5. {
  6. [Serializable]
  7. internal class ExitCallbacks : ScriptableObject, IErrorCallbacks
  8. {
  9. internal static bool preventExit;
  10. public void RunFinished(ITestResultAdaptor testResults)
  11. {
  12. if (preventExit)
  13. {
  14. return;
  15. }
  16. if (!ExitCallbacksDataHolder.instance.AnyTestsExecuted)
  17. {
  18. Debug.LogFormat(LogType.Warning, LogOption.NoStacktrace, null, "No tests were executed");
  19. }
  20. EditorApplication.Exit(ExitCallbacksDataHolder.instance.RunFailed ? (int)Executer.ReturnCodes.Failed : (int)Executer.ReturnCodes.Ok);
  21. }
  22. public void TestStarted(ITestAdaptor test)
  23. {
  24. if (!test.IsSuite)
  25. {
  26. ExitCallbacksDataHolder.instance.AnyTestsExecuted = true;
  27. }
  28. }
  29. public void TestFinished(ITestResultAdaptor result)
  30. {
  31. if (!result.Test.IsSuite && (result.TestStatus == TestStatus.Failed || result.TestStatus == TestStatus.Inconclusive))
  32. {
  33. ExitCallbacksDataHolder.instance.RunFailed = true;
  34. }
  35. }
  36. public void RunStarted(ITestAdaptor testsToRun)
  37. {
  38. }
  39. public void OnError(string message)
  40. {
  41. EditorApplication.Exit((int)Executer.ReturnCodes.RunError);
  42. }
  43. }
  44. }