diff --git a/.github/workflows/build-debug.yml b/.github/workflows/build-debug.yml index f6e4ba7..d36e1eb 100644 --- a/.github/workflows/build-debug.yml +++ b/.github/workflows/build-debug.yml @@ -13,7 +13,7 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: Cysharp/Actions/.github/actions/setup-dotnet@main - run: dotnet build -c Debug - run: dotnet test -c Debug @@ -21,10 +21,11 @@ jobs: build-unity: if: ${{ (github.event_name == 'push' && github.repository_owner == 'Cysharp') || startsWith(github.event.pull_request.head.label, 'Cysharp:') }} strategy: + fail-fast: false matrix: - unity: ["2019.3.9f1", "2019.4.13f1", "2020.1.12f1"] + unity: ["2021.3.41f1", "2022.3.39f1", "6000.0.12f1"] # Test with LTS runs-on: ubuntu-latest - timeout-minutes: 15 + timeout-minutes: 20 steps: - name: Load secrets id: op-load-secret @@ -37,23 +38,7 @@ jobs: UNITY_PASSWORD: "op://GitHubActionsPublic/UNITY_LICENSE/credential" UNITY_SERIAL: "op://GitHubActionsPublic/UNITY_LICENSE/serial" - - uses: actions/checkout@v3 - # Execute scripts: RuntimeUnitTestToolkit - # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend mono /BuildTarget StandaloneLinux64 - - name: Build UnitTest(Linux64, mono) - uses: Cysharp/Actions/.github/actions/unity-builder@main - env: - UNITY_EMAIL: ${{ steps.op-load-secret.outputs.UNITY_EMAIL }} - UNITY_PASSWORD: ${{ steps.op-load-secret.outputs.UNITY_PASSWORD }} - UNITY_SERIAL: ${{ steps.op-load-secret.outputs.UNITY_SERIAL }} - with: - projectPath: src/UniTask - unityVersion: ${{ matrix.unity }} - targetPlatform: StandaloneLinux64 - buildMethod: UnitTestBuilder.BuildUnitTest - customParameters: /headless /ScriptBackend mono - - name: Execute UnitTest - run: ./src/UniTask/bin/UnitTest/StandaloneLinux64_Mono2x/test + - uses: actions/checkout@v4 # Execute scripts: Export Package # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod PackageExporter.Export @@ -79,3 +64,45 @@ jobs: name: UniTask.unitypackage-${{ matrix.unity }}.zip path: ./src/UniTask/*.unitypackage retention-days: 1 + + test-unity: + needs: [build-unity] + if: ${{ (github.event_name == 'push' && github.repository_owner == 'Cysharp') || startsWith(github.event.pull_request.head.label, 'Cysharp:') }} + strategy: + fail-fast: false + matrix: + unity: ["2021.3.41f1", "2022.3.39f1", "6000.0.12f1"] # Test with LTS + runs-on: ubuntu-latest + timeout-minutes: 20 + steps: + - name: Load secrets + id: op-load-secret + uses: 1password/load-secrets-action@v2 + with: + export-env: false + env: + OP_SERVICE_ACCOUNT_TOKEN: ${{ secrets.OP_SERVICE_ACCOUNT_TOKEN_PUBLIC }} + UNITY_EMAIL: "op://GitHubActionsPublic/UNITY_LICENSE/username" + UNITY_PASSWORD: "op://GitHubActionsPublic/UNITY_LICENSE/credential" + UNITY_SERIAL: "op://GitHubActionsPublic/UNITY_LICENSE/serial" + + - uses: actions/checkout@v4 + + # Execute UnitTest + # /opt/Unity/Editor/Unity -quit -batchmode -nographics -silent-crashes -logFile -projectPath . -executeMethod UnitTestBuilder.BuildUnitTest /headless /ScriptBackend IL2CPP /BuildTarget StandaloneLinux64 + - name: Build UnitTest + uses: Cysharp/Actions/.github/actions/unity-builder@main + env: + UNITY_EMAIL: ${{ steps.op-load-secret.outputs.UNITY_EMAIL }} + UNITY_PASSWORD: ${{ steps.op-load-secret.outputs.UNITY_PASSWORD }} + UNITY_SERIAL: ${{ steps.op-load-secret.outputs.UNITY_SERIAL }} + with: + projectPath: src/UniTask + unityVersion: ${{ matrix.unity }} + targetPlatform: StandaloneLinux64 + buildMethod: UnitTestBuilder.BuildUnitTest + customParameters: "/headless /ScriptBackend IL2CPP" + - name: Check UnitTest file is generated + run: ls -lR ./src/UniTask/bin/UnitTest + - name: Execute UnitTest + run: ./src/UniTask/bin/UnitTest/StandaloneLinux64_IL2CPP/test diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 68b685d..be5c4b9 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -11,8 +11,8 @@ jobs: runs-on: ubuntu-latest timeout-minutes: 10 steps: - - uses: actions/checkout@v3 - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + - uses: actions/checkout@v4 with: repository: Cysharp/DocfxTemplate path: docs/_DocfxTemplate diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index 0befd82..832829a 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -26,7 +26,7 @@ jobs: timeout-minutes: 10 steps: - run: echo ${{ needs.update-packagejson.outputs.sha }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ needs.update-packagejson.outputs.sha }} - uses: Cysharp/Actions/.github/actions/setup-dotnet@main @@ -45,7 +45,7 @@ jobs: needs: [update-packagejson] strategy: matrix: - unity: ["2019.3.9f1"] + unity: ["2021.3.41f1"] runs-on: ubuntu-latest timeout-minutes: 15 steps: @@ -61,7 +61,7 @@ jobs: UNITY_SERIAL: "op://GitHubActionsPublic/UNITY_LICENSE/serial" - run: echo ${{ needs.update-packagejson.outputs.sha }} - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: ${{ needs.update-packagejson.outputs.sha }} # Execute scripts: Export Package diff --git a/.gitignore b/.gitignore index 724b27e..eb7ac3f 100644 --- a/.gitignore +++ b/.gitignore @@ -80,7 +80,7 @@ _ReSharper* *.ncrunch* .*crunch*.local.xml -# Installshield output folder +# Installshield output folder [Ee]xpress # DocProject is a documentation generator add-in @@ -148,116 +148,8 @@ UniRx\.Async\.unitypackage UniRx.Async.Tests.Editor.csproj -src/UniTask/UniTask.csproj +src/UniTask/*.csproj +.vsconfig -src/UniTask/UniTask.Editor.csproj - -src/UniTask/UniTask.Tests.csproj - -src/UniTask/UniTask.Tests.Editor.csproj - -src/UniTask/UniTask.*.unitypackage - -src/UniTask/UniTask.Linq.csproj - -src/UniTask/DOTween.Modules.csproj - -src/UniTask/Unity.Addressables.csproj - -src/UniTask/Unity.Addressables.Editor.csproj - -src/UniTask/Unity.Analytics.DataPrivacy.csproj - -src/UniTask/Unity.Recorder.csproj - -src/UniTask/Unity.Recorder.Editor.csproj - -src/UniTask/Unity.ResourceManager.csproj - -src/UniTask/Unity.Rider.Editor.csproj - -src/UniTask/Unity.ScriptableBuildPipeline.csproj - -src/UniTask/Unity.ScriptableBuildPipeline.Editor.csproj - -src/UniTask/Unity.TextMeshPro.csproj - -src/UniTask/Unity.TextMeshPro.Editor.csproj - -src/UniTask/Unity.Timeline.csproj - -src/UniTask/Unity.Timeline.Editor.csproj - -src/UniTask/Unity.VisualStudio.Editor.csproj - -src/UniTask/Unity.VSCode.Editor.csproj - -src/UniTask/UnityEditor.CacheServer.csproj - -src/UniTask/UnityEditor.TestRunner.csproj - -src/UniTask/UnityEditor.UI.csproj - -src/UniTask/UnityEngine.Advertisements.csproj - -src/UniTask/UnityEngine.Monetization.csproj - -src/UniTask/UnityEngine.TestRunner.csproj - -src/UniTask/UnityEngine.UI.csproj - -src/UniTask/TempAsm.csproj - -src/UniTask/UniTask.Addressables.csproj - -src/UniTask/UniTask.DOTween.csproj - -src/UniTask/UniTask.TextMeshPro.csproj - -src/UniTask/RuntimeUnitTestToolkit.Player.csproj - -src/UniTask/TempAsm.Player.csproj - -src/UniTask/UniTask.Addressables.Player.csproj - -src/UniTask/UniTask.DOTween.Player.csproj - -src/UniTask/UniTask.Linq.Player.csproj - -src/UniTask/UniTask.Player.csproj - -src/UniTask/UniTask.Tests.Player.csproj - -src/UniTask/UniTask.TextMeshPro.Player.csproj - -src/UniTask/Unity.Addressables.Player.csproj - -src/UniTask/Unity.Analytics.DataPrivacy.Player.csproj - -src/UniTask/Unity.ResourceManager.Player.csproj - -src/UniTask/Unity.ScriptableBuildPipeline.Player.csproj - -src/UniTask/Unity.TextMeshPro.Player.csproj - -src/UniTask/Unity.Timeline.Player.csproj - -src/UniTask/UnityEngine.Advertisements.Player.csproj - -src/UniTask/UnityEngine.Monetization.Player.csproj - -src/UniTask/UnityEngine.TestRunner.Player.csproj - -src/UniTask/UnityEngine.UI.Player.csproj - -src/UniTask/DOTween.Modules.Player.csproj - -src/UniTask/Assembly-CSharp.Player.csproj - -src/UniTask/Unity.EditorCoroutines.Editor.csproj - -src/UniTask/.vsconfig - -src/UniTask/Logs/ApiUpdaterCheck.txt - -src/UniTask/Assembly-CSharp-firstpass.csproj +# Unity +!src/UniTask/Packages/ diff --git a/src/UniTask/Assets/RuntimeUnitTestToolkit.meta b/src/UniTask/Assets/RuntimeUnitTestToolkit.meta deleted file mode 100644 index aa095c6..0000000 --- a/src/UniTask/Assets/RuntimeUnitTestToolkit.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 894f21dfce4e82343a91661e1ec1a455 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor.meta b/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor.meta deleted file mode 100644 index 903f676..0000000 --- a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 959c1472a5d812843bedf9341e87af3b -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs b/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs deleted file mode 100644 index 9a2adc2..0000000 --- a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs +++ /dev/null @@ -1,133 +0,0 @@ -#if UNITY_EDITOR - -using System; -using UnityEngine; - -namespace RuntimeUnitTestToolkit.Editor -{ - // functional declarative construction like flutter. - - internal interface IBuilder - { - GameObject GameObject { get; } - T GetComponent(); - } - - internal class Builder : IBuilder - where T : Component - { - public T Component1 { get; private set; } - public GameObject GameObject { get; private set; } - - public Transform Transform { get { return GameObject.transform; } } - public RectTransform RectTransform { get { return GameObject.GetComponent(); } } - - public Action SetTarget - { - set - { - value(this.GameObject); - } - } - - - public IBuilder Child - { - set - { - value.GameObject.transform.SetParent(GameObject.transform); - } - } - - public IBuilder[] Children - { - set - { - foreach (var item in value) - { - item.GameObject.transform.SetParent(GameObject.transform); - } - } - } - - public Builder(string name) - { - this.GameObject = new GameObject(name); - this.Component1 = GameObject.AddComponent(); - } - - public Builder(string name, out T referenceSelf) // out primary reference. - { - this.GameObject = new GameObject(name); - this.Component1 = GameObject.AddComponent(); - referenceSelf = this.Component1; - } - - public TComponent GetComponent() - { - return this.GameObject.GetComponent(); - } - } - - internal class Builder : Builder - where T1 : Component - where T2 : Component - { - public T2 Component2 { get; private set; } - - public Builder(string name) - : base(name) - { - this.Component2 = GameObject.AddComponent(); - } - - public Builder(string name, out T1 referenceSelf) - : base(name, out referenceSelf) - { - this.Component2 = GameObject.AddComponent(); - } - } - - internal class Builder : Builder - where T1 : Component - where T2 : Component - where T3 : Component - { - public T3 Component3 { get; private set; } - - public Builder(string name) - : base(name) - { - this.Component3 = GameObject.AddComponent(); - } - - public Builder(string name, out T1 referenceSelf) - : base(name, out referenceSelf) - { - this.Component3 = GameObject.AddComponent(); - } - } - - internal class Builder : Builder - where T1 : Component - where T2 : Component - where T3 : Component - where T4 : Component - { - public T4 Component4 { get; private set; } - - public Builder(string name) - : base(name) - { - this.Component4 = GameObject.AddComponent(); - } - - public Builder(string name, out T1 referenceSelf) - : base(name, out referenceSelf) - { - this.Component4 = GameObject.AddComponent(); - } - } -} - -#endif \ No newline at end of file diff --git a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta b/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta deleted file mode 100644 index 82c8e9b..0000000 --- a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/HierarchyTreeBuilder.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 8760bbbab905a534eb6fb7b61b736926 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs b/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs deleted file mode 100644 index 94508b5..0000000 --- a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs +++ /dev/null @@ -1,345 +0,0 @@ -#if UNITY_EDITOR -using UnityEditor; - -// Settings MenuItems. - -public static partial class UnitTestBuilder -{ - [MenuItem("Test/Settings/ScriptBackend/Mono", validate = true, priority = 1)] - static bool ValidateScriptBackendMono() - { - Menu.SetChecked("Test/Settings/ScriptBackend/Mono", LoadOrGetDefaultSettings().ScriptBackend == ScriptingImplementation.Mono2x); - return true; - } - - [MenuItem("Test/Settings/ScriptBackend/Mono", validate = false, priority = 1)] - static void ScriptBackendMono() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentScriptBackend = false; - settings.ScriptBackend = ScriptingImplementation.Mono2x; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/ScriptBackend/IL2CPP", validate = true, priority = 2)] - static bool ValidateScriptBackendIL2CPP() - { - Menu.SetChecked("Test/Settings/ScriptBackend/IL2CPP", LoadOrGetDefaultSettings().ScriptBackend == ScriptingImplementation.IL2CPP); - return true; - } - - [MenuItem("Test/Settings/ScriptBackend/IL2CPP", validate = false, priority = 2)] - static void ScriptBackendIL2CPP() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentScriptBackend = false; - settings.ScriptBackend = ScriptingImplementation.IL2CPP; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/AutoRunPlayer", validate = true, priority = 3)] - static bool ValidateAutoRun() - { - Menu.SetChecked("Test/Settings/AutoRunPlayer", LoadOrGetDefaultSettings().AutoRunPlayer); - return true; - } - - [MenuItem("Test/Settings/AutoRunPlayer", validate = false, priority = 3)] - static void AutoRun() - { - var settings = LoadOrGetDefaultSettings(); - settings.AutoRunPlayer = !settings.AutoRunPlayer; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/Headless", validate = true, priority = 4)] - static bool ValidateHeadless() - { - Menu.SetChecked("Test/Settings/Headless", LoadOrGetDefaultSettings().Headless); - return true; - } - - [MenuItem("Test/Settings/Headless", validate = false, priority = 4)] - static void Headless() - { - var settings = LoadOrGetDefaultSettings(); - settings.Headless = !settings.Headless; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/DisableAutoClose", validate = true, priority = 5)] - static bool ValidateDisableAutoClose() - { - Menu.SetChecked("Test/Settings/DisableAutoClose", LoadOrGetDefaultSettings().DisableAutoClose); - return true; - } - - [MenuItem("Test/Settings/DisableAutoClose", validate = false, priority = 5)] - static void DisableAutoClose() - { - var settings = LoadOrGetDefaultSettings(); - settings.DisableAutoClose = !settings.DisableAutoClose; - SaveSettings(settings); - } - - // generated - - /* - * - void Main() -{ -var sb = new StringBuilder(); - -var p = 1; -foreach (var target in Enum.GetNames(typeof(BuildTarget))) -{ - var path = $"Test/Settings/BuildTarget/{target}"; - var priority = p++; - - var template = $@" -[MenuItem(""{path}"", validate = true, priority = {priority})] -static bool ValidateBuildTarget{target}() -{{ -Menu.SetChecked(""{path}"", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.{target}); -return true; -}} - -[MenuItem(""{path}"", validate = false, priority = {priority})] -static void BuildTarget{target}() -{{ -var settings = LoadOrGetDefaultSettings(); -settings.UseCurrentBuildTarget = false; -settings.BuildTarget = BuildTarget.{target}; -SaveSettings(settings); -}}"; - - sb.AppendLine(template); -} - -sb.ToString().Dump(); -} - -public enum BuildTarget -{ -StandaloneWindows, -StandaloneWindows64, -StandaloneLinux, -StandaloneLinux64, -StandaloneOSX, -WebGL, -iOS, -Android, -WSAPlayer, -PS4, -XboxOne, -Switch, -} - */ - - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows", validate = true, priority = 1)] - static bool ValidateBuildTargetStandaloneWindows() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneWindows", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneWindows); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows", validate = false, priority = 1)] - static void BuildTargetStandaloneWindows() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneWindows; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows64", validate = true, priority = 2)] - static bool ValidateBuildTargetStandaloneWindows64() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneWindows64", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneWindows64); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneWindows64", validate = false, priority = 2)] - static void BuildTargetStandaloneWindows64() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneWindows64; - SaveSettings(settings); - } - -#if !UNITY_2019_2_OR_NEWER - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux", validate = true, priority = 3)] - static bool ValidateBuildTargetStandaloneLinux() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneLinux", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneLinux); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux", validate = false, priority = 3)] - static void BuildTargetStandaloneLinux() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneLinux; - SaveSettings(settings); - } - -#endif - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux64", validate = true, priority = 4)] - static bool ValidateBuildTargetStandaloneLinux64() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneLinux64", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneLinux64); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneLinux64", validate = false, priority = 4)] - static void BuildTargetStandaloneLinux64() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneLinux64; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneOSX", validate = true, priority = 5)] - static bool ValidateBuildTargetStandaloneOSX() - { - Menu.SetChecked("Test/Settings/BuildTarget/StandaloneOSX", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.StandaloneOSX); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/StandaloneOSX", validate = false, priority = 5)] - static void BuildTargetStandaloneOSX() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.StandaloneOSX; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/WebGL", validate = true, priority = 6)] - static bool ValidateBuildTargetWebGL() - { - Menu.SetChecked("Test/Settings/BuildTarget/WebGL", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.WebGL); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/WebGL", validate = false, priority = 6)] - static void BuildTargetWebGL() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.WebGL; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/iOS", validate = true, priority = 7)] - static bool ValidateBuildTargetiOS() - { - Menu.SetChecked("Test/Settings/BuildTarget/iOS", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.iOS); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/iOS", validate = false, priority = 7)] - static void BuildTargetiOS() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.iOS; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/Android", validate = true, priority = 8)] - static bool ValidateBuildTargetAndroid() - { - Menu.SetChecked("Test/Settings/BuildTarget/Android", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.Android); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/Android", validate = false, priority = 8)] - static void BuildTargetAndroid() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.Android; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/WSAPlayer", validate = true, priority = 9)] - static bool ValidateBuildTargetWSAPlayer() - { - Menu.SetChecked("Test/Settings/BuildTarget/WSAPlayer", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.WSAPlayer); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/WSAPlayer", validate = false, priority = 9)] - static void BuildTargetWSAPlayer() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.WSAPlayer; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/PS4", validate = true, priority = 10)] - static bool ValidateBuildTargetPS4() - { - Menu.SetChecked("Test/Settings/BuildTarget/PS4", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.PS4); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/PS4", validate = false, priority = 10)] - static void BuildTargetPS4() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.PS4; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/XboxOne", validate = true, priority = 11)] - static bool ValidateBuildTargetXboxOne() - { - Menu.SetChecked("Test/Settings/BuildTarget/XboxOne", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.XboxOne); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/XboxOne", validate = false, priority = 11)] - static void BuildTargetXboxOne() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.XboxOne; - SaveSettings(settings); - } - - [MenuItem("Test/Settings/BuildTarget/Switch", validate = true, priority = 12)] - static bool ValidateBuildTargetSwitch() - { - Menu.SetChecked("Test/Settings/BuildTarget/Switch", LoadOrGetDefaultSettings().BuildTarget == BuildTarget.Switch); - return true; - } - - [MenuItem("Test/Settings/BuildTarget/Switch", validate = false, priority = 12)] - static void BuildTargetSwitch() - { - var settings = LoadOrGetDefaultSettings(); - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = BuildTarget.Switch; - SaveSettings(settings); - } - - - - - - - - -} - -#endif diff --git a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta b/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta deleted file mode 100644 index 7c99172..0000000 --- a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.MenuItems.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 12bdad0556e999f4aa82da29415d361f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs b/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs deleted file mode 100644 index ca45d0b..0000000 --- a/src/UniTask/Assets/RuntimeUnitTestToolkit/Editor/UnitTestBuilder.cs +++ /dev/null @@ -1,546 +0,0 @@ -#if UNITY_EDITOR - -using RuntimeUnitTestToolkit; -using RuntimeUnitTestToolkit.Editor; -using System; -using UnityEditor; -using UnityEditor.Build.Reporting; -using UnityEditor.SceneManagement; -using UnityEngine; -using UnityEngine.EventSystems; -using UnityEngine.SceneManagement; -using UnityEngine.UI; - -internal class RuntimeUnitTestSettings -{ - public ScriptingImplementation ScriptBackend; - public bool UseCurrentScriptBackend; - public BuildTarget BuildTarget; - public bool UseCurrentBuildTarget; - - public bool Headless; - public bool AutoRunPlayer; - public bool DisableAutoClose; - - public RuntimeUnitTestSettings() - { - UseCurrentBuildTarget = true; - UseCurrentScriptBackend = true; - Headless = false; - AutoRunPlayer = true; - DisableAutoClose = false; - } - - public override string ToString() - { - return $"{ScriptBackend} {BuildTarget} Headless:{Headless} AutoRunPlayer:{AutoRunPlayer} DisableAutoClose:{DisableAutoClose}"; - } -} - -// no namespace(because invoke from commandline) -public static partial class UnitTestBuilder -{ - const string SettingsKeyBase = "RuntimeUnitTest.Settings."; - - [MenuItem("Test/BuildUnitTest")] - public static void BuildUnitTest() - { - var settings = new RuntimeUnitTestSettings(); // default - - string buildPath = null; - - if (Application.isBatchMode) // from commandline - { - settings.AutoRunPlayer = false; - settings.DisableAutoClose = false; - - var cmdArgs = Environment.GetCommandLineArgs(); - for (int i = 0; i < cmdArgs.Length; i++) - { - if (string.Equals(cmdArgs[i].Trim('-', '/'), "ScriptBackend", StringComparison.OrdinalIgnoreCase)) - { - settings.UseCurrentScriptBackend = false; - var str = cmdArgs[++i]; - if (str.StartsWith("mono", StringComparison.OrdinalIgnoreCase)) - { - settings.ScriptBackend = ScriptingImplementation.Mono2x; - } - else if (str.StartsWith("IL2CPP", StringComparison.OrdinalIgnoreCase)) - { - settings.ScriptBackend = ScriptingImplementation.IL2CPP; - } - else - { - settings.ScriptBackend = (ScriptingImplementation)Enum.Parse(typeof(ScriptingImplementation), str, true); - } - } - else if (string.Equals(cmdArgs[i].Trim('-', '/'), "BuildTarget", StringComparison.OrdinalIgnoreCase)) - { - settings.UseCurrentBuildTarget = false; - settings.BuildTarget = (BuildTarget)Enum.Parse(typeof(BuildTarget), cmdArgs[++i], true); - } - else if (string.Equals(cmdArgs[i].Trim('-', '/'), "Headless", StringComparison.OrdinalIgnoreCase)) - { - settings.Headless = true; - } - else if (string.Equals(cmdArgs[i].Trim('-', '/'), "buildPath", StringComparison.OrdinalIgnoreCase)) - { - buildPath = cmdArgs[++i]; - } - } - } - else - { - var key = SettingsKeyBase + Application.productName; - var settingsValue = EditorPrefs.GetString(key, null); - try - { - if (!string.IsNullOrWhiteSpace(settingsValue)) - { - settings = JsonUtility.FromJson(settingsValue); - } - } - catch - { - UnityEngine.Debug.LogError("Fail to load RuntimeUnitTest settings"); - EditorPrefs.SetString(key, null); - } - } - - if (settings.UseCurrentBuildTarget) - { - settings.BuildTarget = EditorUserBuildSettings.activeBuildTarget; - } - if (settings.UseCurrentScriptBackend) - { - settings.ScriptBackend = PlayerSettings.GetScriptingBackend(ToBuildTargetGroup(settings.BuildTarget)); - } - - if (buildPath == null) - { - buildPath = $"bin/UnitTest/{settings.BuildTarget}_{settings.ScriptBackend}/test" + GetExtensionForBuildTarget(settings.BuildTarget); - } - - var originalScene = SceneManager.GetActiveScene().path; - - BuildUnitTest(buildPath, settings.ScriptBackend, settings.BuildTarget, settings.Headless, settings.AutoRunPlayer, settings.DisableAutoClose); - - // reopen original scene - if (!string.IsNullOrWhiteSpace(originalScene)) - { - EditorSceneManager.OpenScene(originalScene, OpenSceneMode.Single); - } - else - { - EditorSceneManager.NewScene(NewSceneSetup.DefaultGameObjects); - } - } - - - [MenuItem("Test/LoadUnitTestScene")] - public static void LoadUnitTestScene() - { - var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); - BuildUnitTestRunnerScene(); - EditorSceneManager.MarkSceneDirty(scene); - } - - static RuntimeUnitTestSettings LoadOrGetDefaultSettings() - { - var key = SettingsKeyBase + Application.productName; - - var settingsValue = EditorPrefs.GetString(key, null); - RuntimeUnitTestSettings settings = null; - try - { - if (!string.IsNullOrWhiteSpace(settingsValue)) - { - settings = JsonUtility.FromJson(settingsValue); - } - } - catch - { - UnityEngine.Debug.LogError("Fail to load RuntimeUnitTest settings"); - EditorPrefs.SetString(key, null); - settings = null; - } - - if (settings == null) - { - // default - settings = new RuntimeUnitTestSettings - { - UseCurrentBuildTarget = true, - UseCurrentScriptBackend = true, - Headless = false, - AutoRunPlayer = true, - }; - } - - return settings; - } - - static void SaveSettings(RuntimeUnitTestSettings settings) - { - var key = SettingsKeyBase + Application.productName; - EditorPrefs.SetString(key, JsonUtility.ToJson(settings)); - } - - public static void BuildUnitTest(string buildPath, ScriptingImplementation scriptBackend, BuildTarget buildTarget, bool headless, bool autoRunPlayer, bool disableAutoClose) - { - var sceneName = "Assets/TempRuntimeUnitTestScene_" + DateTimeOffset.UtcNow.ToUnixTimeSeconds(); - if (disableAutoClose) - { - sceneName += "_DisableAutoClose"; - } - sceneName += ".unity"; - - var scene = EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single); - - BuildUnitTestRunnerScene(); - - EditorSceneManager.MarkSceneDirty(scene); - AssetDatabase.SaveAssets(); - EditorSceneManager.SaveScene(scene, sceneName, false); - try - { - Build(sceneName, buildPath, new RuntimeUnitTestSettings { ScriptBackend = scriptBackend, BuildTarget = buildTarget, Headless = headless, AutoRunPlayer = autoRunPlayer, DisableAutoClose = disableAutoClose }); - } - finally - { - AssetDatabase.DeleteAsset(sceneName); - } - } - - public static UnitTestRunner BuildUnitTestRunnerScene() - { - const string kStandardSpritePath = "UI/Skin/UISprite.psd"; - const string kBackgroundSpritePath = "UI/Skin/Background.psd"; - var uisprite = AssetDatabase.GetBuiltinExtraResource(kStandardSpritePath); - var background = AssetDatabase.GetBuiltinExtraResource(kBackgroundSpritePath); - - ScrollRect buttonList; - VerticalLayoutGroup listLayout; - Scrollbar refListScrollbar; - ScrollRect logList; - Scrollbar refLogScrollbar; - Button clearButton; - Text logText; - - // Flutter like coded build utility - - var rootObject = new Builder("SceneRoot") - { - Children = new IBuilder[] { - new Builder("EventSystem"), - new Builder("Canvas") { - Component1 = { renderMode = RenderMode.ScreenSpaceOverlay }, - Children = new IBuilder[] { - new Builder("HorizontalSplitter") { - RectTransform = { anchorMin = new Vector2(0, 0), anchorMax = new Vector2(1, 1) }, - Component1 = { childControlWidth = true, childControlHeight = true, spacing = 10 }, - Children = new IBuilder[] { - new Builder("ButtonList", out buttonList) { - RectTransform = { pivot = new Vector2(0.5f, 0.5f) }, - Component1 = { horizontal =false, vertical = true, movementType = ScrollRect.MovementType.Clamped }, - Children = new IBuilder[] { - new Builder("ListLayoutToAttach", out listLayout) { - RectTransform = { anchorMin = new Vector2(0, 0), anchorMax = new Vector2(1, 1), pivot = new Vector2(0, 1) }, - Component1 = { childControlWidth = true, childControlHeight = true, childForceExpandWidth = true, childForceExpandHeight = false, spacing = 10, padding = new RectOffset(10,20,10,10) }, - Component2 = { horizontalFit = ContentSizeFitter.FitMode.Unconstrained, verticalFit = ContentSizeFitter.FitMode.PreferredSize }, - SetTarget = self => { buttonList.content = self.GetComponent(); }, - Child = new Builder("ClearButton", out clearButton) { - Component2 = { sprite = uisprite, type = Image.Type.Sliced }, - Component3 = { minHeight = 50 }, - SetTarget = self => { self.GetComponent