From b77fdb82ffafeefa102b5d9a42c30a6711e9cf4e Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Sun, 8 Nov 2026 05:24:42 +0900 Subject: [PATCH 1/3] Upgrade Unity versions used to run tests on CI --- .github/workflows/test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d7341d4..d643eca 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,8 +46,8 @@ jobs: - 6000.0.43f1 # Latest version that does not pin the test framework package. - 6000.0.44f1 # pin test-framework v1.5.1 - 6000.0.59f2 # pin test-framework v1.6.0 - - 6000.0.78f1 - - 6000.3.18f1 + - 6000.0.85f1 + - 6000.3.28f1 - &latest_unity_version 6000.5.1f1 # pin test-framework v1.7.0 testMode: - All # run tests in editor From 383797adf58198f5860600d41116b458e966c14c Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Sun, 8 Nov 2026 07:14:54 +0900 Subject: [PATCH 2/3] Fix flaky RecompileScripts examples caused by a delayed domain reload RecompileScripts returns once compilation finishes, but the domain reload can still be pending; the test then resumes on the old assemblies and fails (seen on CI with Unity 6.3 and 6.5, and locally with 6.0). Wait until the reload actually happens, and log the reload state so CI runs show whether the delay occurred. Create the generated script and csc.rsp under the APIExamples assembly instead of Assets/ so that only that assembly is recompiled, not every assembly in the project. Co-Authored-By: Claude Opus 5.5 --- .../EditModeTestYieldInstructionExample.cs | 35 ++++++++++++++++--- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/Assets/APIExamples/Tests/Editor/UnityTestFramework/EditModeTestYieldInstructionExample.cs b/Assets/APIExamples/Tests/Editor/UnityTestFramework/EditModeTestYieldInstructionExample.cs index 6aa6a7b..381d379 100644 --- a/Assets/APIExamples/Tests/Editor/UnityTestFramework/EditModeTestYieldInstructionExample.cs +++ b/Assets/APIExamples/Tests/Editor/UnityTestFramework/EditModeTestYieldInstructionExample.cs @@ -26,9 +26,10 @@ public class EditModeTestYieldInstructionExample private static bool s_wasUnitySetUpCalled; private static bool s_wasSetUpCalled; private static bool s_wasSetUpAsyncCalled; + private static bool s_isDomainReloadPending; - private const string CsPath = "Assets/CreateFileExample.cs"; - private const string RspPath = "Assets/csc.rsp"; + private const string CsPath = "Assets/APIExamples/Scripts/Runtime/CreateFileExample.cs"; + private const string RspPath = "Assets/APIExamples/Scripts/Runtime/csc.rsp"; private const string DLLSrcPath = "TestData/NativePluginExample.dll"; private const string DLLDstPath = "Assets/NativePluginExample.dll"; @@ -119,7 +120,24 @@ public IEnumerator ExitPlayModeで編集モードに切り替える例() Assert.That(EditorApplication.isPlaying, Is.False); } + private static IEnumerator WaitForPendingDomainReload() + { + // Note: InternalEditorUtility.IsScriptReloadRequested()はinternalのため、リフレクションで呼び出す + var isScriptReloadRequested = typeof(UnityEditorInternal.InternalEditorUtility) + .GetMethod("IsScriptReloadRequested", BindingFlags.Static | BindingFlags.NonPublic) + ?.Invoke(null, null); + Debug.Log($"After RecompileScripts: isDomainReloadPending={s_isDomainReloadPending}, isScriptReloadRequested={isScriptReloadRequested}, isCompiling={EditorApplication.isCompiling}"); + + // Note: RecompileScriptsはコンパイル完了までしか待たず、ドメインリロードが遅れて実行されることがあるため待機する。 + // WaitForDomainReloadを使わないのは、ドメインリロードがRecompileScripts中に完了していると例外をスローするため + while (s_isDomainReloadPending) + { + yield return null; + } + } + [UnityTest] + [Timeout(60000)] public IEnumerator RecompileScriptsでリコンパイルを実行する例_リコンパイルされたクラスのメソッドを呼び出せる() { Assume.That(Path.GetFullPath(CsPath), Does.Not.Exist, @@ -130,11 +148,14 @@ public IEnumerator RecompileScriptsでリコンパイルを実行する例_リ file.Write("public class Foo { public bool Bar(string msg) { return true; } }"); } + s_isDomainReloadPending = true; + // ここでAssetDatabase.Refresh()は不要 yield return new RecompileScripts(); + yield return WaitForPendingDomainReload(); // リフレクションでメソッド呼び出し - var assemblyName = new AssemblyName("Assembly-CSharp"); + var assemblyName = new AssemblyName("APIExamples"); var assembly = Assembly.Load(assemblyName); var fooType = assembly.GetType("Foo"); dynamic foo = Activator.CreateInstance(fooType); @@ -144,6 +165,7 @@ public IEnumerator RecompileScriptsでリコンパイルを実行する例_リ } [UnityTest] + [Timeout(60000)] public IEnumerator RecompileScriptsでリコンパイルを実行する例_csc_rspで追加したスクリプティングシンボルが有効になる() { Assume.That(Path.GetFullPath(RspPath), Does.Not.Exist, @@ -161,9 +183,14 @@ public IEnumerator RecompileScriptsでリコンパイルを実行する例_csc_r "#endif\n" + "} }"); + s_isDomainReloadPending = true; + + // ここでAssetDatabase.Refresh()は不要 yield return new RecompileScripts(); + yield return WaitForPendingDomainReload(); - var assembly = Assembly.Load(new AssemblyName("Assembly-CSharp")); + // リフレクションでメソッド呼び出し + var assembly = Assembly.Load(new AssemblyName("APIExamples")); var fooType = assembly.GetType("Foo"); var actual = (bool)fooType.GetMethod("IsDefined")!.Invoke(null, null); From 3c7547a8d84c4172aa21934426c7875cac9423df Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Sun, 8 Nov 2026 08:00:54 +0900 Subject: [PATCH 3/3] Remove domain reload state logging from RecompileScripts examples The logging was added to see whether the delayed domain reload occurs on CI. Five reruns across all Unity versions never showed it, so the log no longer earns its noise; the wait itself stays as a safeguard. Co-Authored-By: Claude Opus 5.5 --- .../EditModeTestYieldInstructionExample.cs | 6 ------ 1 file changed, 6 deletions(-) diff --git a/Assets/APIExamples/Tests/Editor/UnityTestFramework/EditModeTestYieldInstructionExample.cs b/Assets/APIExamples/Tests/Editor/UnityTestFramework/EditModeTestYieldInstructionExample.cs index 381d379..92bba73 100644 --- a/Assets/APIExamples/Tests/Editor/UnityTestFramework/EditModeTestYieldInstructionExample.cs +++ b/Assets/APIExamples/Tests/Editor/UnityTestFramework/EditModeTestYieldInstructionExample.cs @@ -122,12 +122,6 @@ public IEnumerator ExitPlayModeで編集モードに切り替える例() private static IEnumerator WaitForPendingDomainReload() { - // Note: InternalEditorUtility.IsScriptReloadRequested()はinternalのため、リフレクションで呼び出す - var isScriptReloadRequested = typeof(UnityEditorInternal.InternalEditorUtility) - .GetMethod("IsScriptReloadRequested", BindingFlags.Static | BindingFlags.NonPublic) - ?.Invoke(null, null); - Debug.Log($"After RecompileScripts: isDomainReloadPending={s_isDomainReloadPending}, isScriptReloadRequested={isScriptReloadRequested}, isCompiling={EditorApplication.isCompiling}"); - // Note: RecompileScriptsはコンパイル完了までしか待たず、ドメインリロードが遅れて実行されることがあるため待機する。 // WaitForDomainReloadを使わないのは、ドメインリロードがRecompileScripts中に完了していると例外をスローするため while (s_isDomainReloadPending)