diff --git a/Editor/Commandline.cs b/Editor/Commandline.cs index ebc35ee..32abfa2 100644 --- a/Editor/Commandline.cs +++ b/Editor/Commandline.cs @@ -119,7 +119,7 @@ private static void OnChangePlayModeState(PlayModeStateChange playModeStateChang // Exit Unity when returning from play mode to edit mode. // Because it may freeze when exiting without going through edit mode. var exitCode = (int)AutopilotState.Instance.exitCode; - Debug.Log($"Exit Unity-editor by autopilot, exit code={exitCode}"); + Debug.Log($"Exit Unity-editor by autopilot, exit code: {(int)exitCode}"); EditorApplication.Exit(exitCode); } } diff --git a/Runtime/Autopilot.cs b/Runtime/Autopilot.cs index c291d6e..70e60a0 100644 --- a/Runtime/Autopilot.cs +++ b/Runtime/Autopilot.cs @@ -145,10 +145,10 @@ public async UniTask TerminateAsync(ExitCode exitCode, string message = null, st JUnitReporter.Output(_state.settings.junitReportPath, (int)exitCode, message, stackTrace, time); } - DestroyImmediate(this.gameObject); + Destroy(this.gameObject); _logger.Log("Terminate Autopilot"); - await Launcher.TeardownLaunchAutopilotAsync(_state, _logger, exitCode, "Autopilot", token); + Launcher.TeardownLaunchAutopilotAsync(_state, _logger, exitCode, "Autopilot").Forget(); } [Obsolete("Use " + nameof(TerminateAsync))] diff --git a/Runtime/Launcher.cs b/Runtime/Launcher.cs index 88eee4a..75f5f7f 100644 --- a/Runtime/Launcher.cs +++ b/Runtime/Launcher.cs @@ -11,8 +11,8 @@ using DeNA.Anjin.Attributes; using DeNA.Anjin.Settings; using DeNA.Anjin.Utilities; -using NUnit.Framework; using UnityEngine; +using Assert = UnityEngine.Assertions.Assert; using Object = UnityEngine.Object; #if UNITY_INCLUDE_TESTS using NUnit.Framework; @@ -217,8 +217,8 @@ private static Dictionary> GetOrderedInitializeOnLaunchAut #endif } - internal static async UniTask TeardownLaunchAutopilotAsync(AutopilotState state, ILogger logger, - ExitCode exitCode, string caller, CancellationToken token = default) + internal static async UniTaskVoid TeardownLaunchAutopilotAsync(AutopilotState state, ILogger logger, + ExitCode exitCode, string caller) { state.settings = null; state.exitCode = exitCode; @@ -229,7 +229,7 @@ internal static async UniTask TeardownLaunchAutopilotAsync(AutopilotState state, // Play mode tests if (TestContext.CurrentContext != null && exitCode != ExitCode.Normally) { - throw new AssertionException($"{caller} failed with exit code {exitCode}"); + throw new AssertionException($"{caller} failed with exit code {(int)exitCode}"); } #endif return; // Only terminate autopilot run if starting from play mode. @@ -242,7 +242,7 @@ internal static async UniTask TeardownLaunchAutopilotAsync(AutopilotState state, // XXX: Avoid a problem that Editor stay playing despite isPlaying get assigned false. // SEE: https://github.com/DeNA/Anjin/issues/20 - await UniTask.NextFrame(token); + await UniTask.NextFrame(); #if UNITY_EDITOR EditorApplication.isPlaying = false; // Note: If launched from the command line, `DeNA.Anjin.Editor.Commandline.OnChangePlayModeState()` will be called, and the Unity editor will be terminated. @@ -251,7 +251,7 @@ internal static async UniTask TeardownLaunchAutopilotAsync(AutopilotState state, else { // Player build launch from commandline - logger.Log($"Exit Unity-player by {caller}, exit code={exitCode}"); + logger.Log($"Exit Unity-player by {caller}, exit code: {(int)exitCode}"); Application.Quit((int)exitCode); } } diff --git a/Runtime/Settings/AutopilotSettings.cs b/Runtime/Settings/AutopilotSettings.cs index eb2680e..177d59c 100644 --- a/Runtime/Settings/AutopilotSettings.cs +++ b/Runtime/Settings/AutopilotSettings.cs @@ -8,8 +8,8 @@ using DeNA.Anjin.Attributes; using DeNA.Anjin.Loggers; using DeNA.Anjin.Reporters; -using NUnit.Framework; using UnityEngine; +using UnityEngine.Assertions; namespace DeNA.Anjin.Settings { @@ -241,7 +241,7 @@ public void OverrideByCommandLineArguments(Arguments args) private static void Initialize() { var settings = AutopilotState.Instance.settings; - Assert.NotNull(settings); + Assert.IsNotNull(settings); settings.ConvertLoggersFromObsoleteLogger(); // Note: before create default logger. settings.CreateDefaultLoggerIfNeeded();