diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 67d39a78..e6088361 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -132,11 +132,10 @@ jobs: shell: bash timeout-minutes: 60 run: | - # DISABLE: NUnit test is currently broken from Unity 2019 ./gradlew test -q \ -PINTERACTIVE_MODE_TESTS_ENABLED=0 \ -PINCLUDE_TEST_TYPES="${{ needs.check_and_prepare.outputs.include_test_types }}" \ - -PEXCLUDE_TEST_TYPES="NUnit,${{ needs.check_and_prepare.outputs.exclude_test_types }}" \ + -PEXCLUDE_TEST_TYPES="${{ needs.check_and_prepare.outputs.exclude_test_types }}" \ -PINCLUDE_TEST_MODULES="${{ needs.check_and_prepare.outputs.include_test_modules }}" \ -PEXCLUDE_TEST_MODULES="${{ needs.check_and_prepare.outputs.exclude_test_modules }}" \ -PEXCLUDE_TESTS="${{ needs.check_and_prepare.outputs.exclude_tests }}" diff --git a/build.gradle b/build.gradle index 28001511..a13348f3 100644 --- a/build.gradle +++ b/build.gradle @@ -166,35 +166,6 @@ project.ext { monoVersion)) } - // Find the NUnit framework dll. - unityNUnitDll = getFileFromPropertyOrFileTree( - "UNITY_NUNIT_PATH", true, { - unityRootDirTree.matching { - include "**/nunit.framework.dll" - exclude unitySearchDirExcludes - } - }) - if (unityNUnitDll == null) { - logger.warn("Unity NUnit DLL not found, tests will not build.") - } - saveProperty("UNITY_NUNIT_PATH", unityNUnitDll, cacheProperties) - - // nunit-console is used to run tests. - nunitConsoleExe = getFileFromPropertyOrFileTree( - "NUNIT_CONSOLE_EXE", false, { - unityRootDirTree.matching { - include (operatingSystem == OperatingSystem.WINDOWS ? - "**/bin/nunit-console2.bat" : - "**/nunit-console2") - exclude unitySearchDirExcludes - } - }) - if (nunitConsoleExe == null) { - logger.warn("nunit_console not found (NUNIT_CONSOLE_EXE) C# unit test " + - "execution will fail.") - } - saveProperty("NUNIT_CONSOLE_EXE", nunitConsoleExe, cacheProperties) - // Get the directory that contains this script. scriptDirectory = buildscript.sourceFile.getParentFile() @@ -740,24 +711,6 @@ void saveProperty(String name, value, Properties properties) { logger.info(sprintf("%s: %s", name, value)) } -/* - * Make sure the NUnit DLL property is set. - */ -void checkNUnitDllPath() { - if (project.ext.unityNUnitDll == null) { - throw new StopActionException("NUnit DLL not found.") - } -} - -/* - * Make sure the NUnit console property is set. - */ -void checkNUnitConsolePath() { - if (project.ext.nunitConsoleExe == null) { - throw new StopActionException("NUnit Console not found.") - } -} - /* * Removes the extension from a filename. * @@ -1082,9 +1035,6 @@ Task createXbuildTask(String taskName, String taskDescription, project.ext.unityDllPath.absolutePath), sprintf("/property:UnityIosPath=%s", project.ext.unityIosPath.absolutePath), - sprintf("/property:NUnityHintPath=%s", - project.ext.unityNUnitDll ? - project.ext.unityNUnitDll.absolutePath: ""), sprintf("/property:BaseIntermediateOutputPath=%s%s", intermediatesDir.absolutePath, File.separator), @@ -1197,41 +1147,43 @@ Task createBuildPluginDllTask(String componentName, } /* - * Create a Nunit test task. + * Creates a task which compiles and run an NUnit test. * - * @param name Name of the task. + * @param taskName Name of the test. * @param description Description of the task. - * @param testDll Test DLL to execute. The log file will be placed in the - * parent directory of this DLL path. * @param dependsOn Dependencies of the new task. - * - * @returns Task which executes nunit-console. + * @param unityProjectDir Directory containing a assets to copy into the + * integration test project. + * @param arguments Additional arguments for Unity when running the integration + * test. + * @param testType Type of the test + * @param testModule Module of the test */ -Task createNUnitTask(String name, String description, File testDll, - Iterable dependsOn) { - File logFileDir = testDll.parentFile.parentFile - File logFile = new File(logFileDir, name + ".log") - File xmlLogFile = new File(logFileDir, name + ".xml") - return tasks.create(name: name, - description: description, - type: Task, - dependsOn: dependsOn).with { - inputs.files testDll - outputs.files logFile - doFirst { checkNUnitConsolePath() } - doLast { - exec { - workingDir project.ext.pluginSourceDir - executable project.ext.nunitConsoleExe - args ([sprintf("-output:%s", logFile.absolutePath), - sprintf("-xml:%s", xmlLogFile.absolutePath), - testDll.absolutePath]) - // TODO: Support continueOnFailForTestsEnabled - // NUnit test is currently broken. Need to fix it before implementing - // continueOnFailForTestsEnabled - } - } - } +Task createUnityNUnitTest(String taskName, + String description, + Iterable dependsOn, + File unityProjectDir, + Iterable arguments, + TestTypeEnum testType, + TestModuleEnum testModule) { + createUnityTestBatchAndNonBatch( + taskName, + description, + ["buildPlugin"], + unityProjectDir, + [], + arguments + [ + "-runTests", + "-batchmode", + "-testResults", "results.xml", + "-testPlatform", "EditMode" + ], null, testType, testModule, + true, + new File(new File(new File( + project.ext.scriptDirectory, + "test_resources"), + "nunit_upm"), + "manifest.json")) } /* @@ -1408,7 +1360,9 @@ Task createUnityProjectTask(String taskName, Iterable dependsOn, * conform to tasks.create(name, description, type, dependsOn). * @param testType Type of the test * @param testModule Module of the test -* + * @param enableDlls Whether to enable dlls through Version Handlers before tests. + * @param upm_package_manifest Specify UPM package manifest (manifest.json) + * * @returns Test task. */ Task createUnityTestTask(String taskName, String description, @@ -1416,7 +1370,9 @@ Task createUnityTestTask(String taskName, String description, Iterable editorAssets, Iterable additionalArguments, Boolean batchMode, createTaskClosure, - TestTypeEnum testType, TestModuleEnum testModule) { + TestTypeEnum testType, TestModuleEnum testModule, + Boolean enableDlls = false, + File upm_package_manifest = null) { List testScripts = [] if (testScriptsDir) { testScripts = fileTree(testScriptsDir).collect { @@ -1426,6 +1382,7 @@ Task createUnityTestTask(String taskName, String description, } // Setup the Unity project. + List setupTasks = [] File testOutputDir = new File(project.ext.testDir, taskName) Task createProject = createUnityProjectTask( sprintf("createsetup%s", taskName), dependsOn, taskName, testOutputDir) @@ -1433,6 +1390,8 @@ Task createUnityTestTask(String taskName, String description, inputs.files files(project.ext.pluginExportFile) setTestProperties(task, testType, testModule) } + setupTasks += [createProject] + Task setupTestProject = createUnityTask( sprintf("setup%s", taskName), "import_plugin", [createProject], taskName, testOutputDir, ["-importPackage", project.ext.pluginExportFile.absolutePath, @@ -1441,6 +1400,36 @@ Task createUnityTestTask(String taskName, String description, inputs.files (testScripts + editorAssets) setTestProperties(task, testType, testModule) } + setupTasks += [setupTestProject] + + Task versionHandlerUpdate; + if (enableDlls) { + File updaterScriptDir = new File(new File(new File( + setupTestProject.ext.projectDir, + "Assets"), + "Editor"), + "VersionHandlerUpdater") + versionHandlerUpdate = createUnityTask( + sprintf("enableDlls%s", taskName), "enable_dlls", [setupTestProject], taskName, + testOutputDir, [], batchMode, null) + versionHandlerUpdate.with { task -> + setTestProperties(task, testType, testModule) + doFirst { + copy { + from new File(new File(new File( + project.ext.scriptDirectory, + "test_resources"), + "version_handler_update"), + "VersionHandlerUpdater.cs") + into updaterScriptDir + } + } + doLast { + delete updaterScriptDir + } + } + setupTasks += [versionHandlerUpdate] + } List copyTasks = [] @@ -1450,20 +1439,35 @@ Task createUnityTestTask(String taskName, String description, sprintf("copyScriptsFor%s", taskName), sprintf("Copy the test scripts into the %s Unity project.", taskName), testScripts, testScriptsDir, setupTestProject.ext.projectDir, - [setupTestProject], null) + setupTasks, null) copyTestScripts.with { task -> setTestProperties(task, testType, testModule) } copyTasks += [copyTestScripts] } + if (upm_package_manifest != null) { + Task copyPackageManifest = tasks.create( + name: sprintf("copyPackageManifestFor%s", taskName), + description: sprintf("Copy the package manifest into the %s Unity project.", + taskName), + type: Copy, + dependsOn: setupTasks) + copyPackageManifest.with { task -> + from upm_package_manifest + into new File(setupTestProject.ext.projectDir, "Packages") + setTestProperties(task, testType, testModule) + } + copyTasks += [copyPackageManifest] + } + // Task which copies editor scripts into the project. Task copyEditorAssets = tasks.create( name: sprintf("copyEditorAssetsFor%s", taskName), description: sprintf("Copy the editor assets into the %s Unity project.", taskName), type: Copy, - dependsOn: [setupTestProject]) + dependsOn: setupTasks) copyEditorAssets.with { task -> from editorAssets into new File(new File(setupTestProject.ext.projectDir, "Assets"), @@ -1482,7 +1486,7 @@ Task createUnityTestTask(String taskName, String description, true) testTask.description = description testTask.with { task -> - finalizedBy reportAllTestsResult + finalizedBy "reportAllTestsResult" doLast { EvaluateTestResult(task) } @@ -1518,6 +1522,8 @@ Task createUnityTestTask(String taskName, String description, * conform to tasks.create(name, description, type, dependsOn). * @param testType Type of the test * @param testModule Module of the test + * @param enableDlls Whether to enable dlls through Version Handlers before tests. + * @param upm_package_manifest Specify UPM package manifest (manifest.json) * * @returns Test task. */ @@ -1528,7 +1534,9 @@ Task createUnityTestBatchAndNonBatch(String taskName, String description, Iterable additionalArguments, createTaskClosure, TestTypeEnum testType, - TestModuleEnum testModule) { + TestModuleEnum testModule, + Boolean enableDlls = false, + File upm_package_manifest = null) { return tasks.create(name: taskName, description: description, dependsOn: [ @@ -1537,27 +1545,15 @@ Task createUnityTestBatchAndNonBatch(String taskName, String description, sprintf("%s (Batch Mode)", description), dependsOn, testScriptsDir, editorAssets, additionalArguments, true, createTaskClosure, - testType, testModule), + testType, testModule, + enableDlls, upm_package_manifest), createUnityTestTask( sprintf("%sInteractiveMode", taskName), sprintf("%s (Interactive Mode)", description), dependsOn, testScriptsDir, editorAssets, additionalArguments, false, createTaskClosure, - testType, testModule)]) -} - -Task compileResolverLibTests = createXbuildTask( - "compileResolverLibTests", - "Compile tests for the deprecated Jar Resolver library.", - project.ext.pluginSolutionFile, "JarResolverTests", - fileTree(new File(new File(project.ext.pluginSourceDir, - "JarResolverLib"), "src")), - new File(project.ext.testDir, "ResolverLibTests"), - [new File("JarResolverTests.dll")], []).with { - doFirst { checkNUnitDllPath() } -} -compileResolverLibTests.with { task -> - setTestProperties(task, TestTypeEnum.NUNIT, TestModuleEnum.ANDROIDRESOLVER) + testType, testModule, + enableDlls, upm_package_manifest)]) } /* @@ -1700,20 +1696,14 @@ Task createGenGuidTask(String taskName, } -Task testResolverLibTests = createNUnitTask( - "testResolverLibTests", - "Runs the tests for the deprecated Jar Resolver library", - compileResolverLibTests.outputs.files[0], - [compileResolverLibTests]) -testResolverLibTests.with { task -> - setTestProperties(task, TestTypeEnum.NUNIT, TestModuleEnum.ANDROIDRESOLVER) -} - -task cleanResolverLibTests() { - description "Clean test output for the deprecated Jar Resolver library" - doLast { delete files(compileResolverLibTests.ext.buildDir, - testResolverLibTests.outputs.files) } -} +createUnityNUnitTest( + "testAndroidResolverNUnitTests", + "Runs NUnit tests for the Android Resolver module.", + [], + new File(project.ext.scriptDirectory, + "source/AndroidResolver/unit_tests"), [], + TestTypeEnum.NUNIT, TestModuleEnum.ANDROIDRESOLVER +) task testDownloadArtifacts(type: GradleBuild) { task -> description "Run tests for the download_artifacts.gradle script." @@ -2226,7 +2216,7 @@ task gitTagRelease(type: Exec) { project.ext.pluginVersion)) } -// TODO: Version Handler tests to implement in both batch and interactive modes +// TODO: Version Handler tests // - Per platform targeting (iOS, Android, Editor, desktop) // - Version enablement, import newer plugin on top of older plugin and validate // new plugin is enabled, old plugin is removed. @@ -2236,7 +2226,7 @@ task gitTagRelease(type: Exec) { // - Import plugin into a project and wait for asset processor to enable it. // - Switch .NET version, validate DLLs are enabled / disabled as expected. -// TODO: Android Resolver tests to implement in both batch and interactive modes +// TODO: Android Resolver tests // - Resolve with: // - Conflicting dependencies // - FAT ABI vs. single ABI selection @@ -2249,57 +2239,23 @@ task gitTagRelease(type: Exec) { // - Project export // - Add a pod which changes the target SDK -Task compileVersionHandlerImplTests = createXbuildTask( - "compileVersionHandlerImplTests", - "Compile tests for VersionHandlerImpl.", - project.ext.pluginSolutionFile, "VersionHandlerImplTests", - fileTree(new File( - new File( - new File(project.ext.pluginSourceDir, - "VersionHandlerImpl"), - "unit_tests"), - "src")), - new File(project.ext.testDir, "VersionHandlerImplTests"), - [new File("Google.VersionHandlerImplTests.dll")], []).with { - doFirst { checkNUnitDllPath() } -} -compileVersionHandlerImplTests.with { task -> - setTestProperties(task, TestTypeEnum.NUNIT, TestModuleEnum.VERSIONHANDLER) -} -createNUnitTask( - "testVersionHandlerImpl", - "Runs tests for the VersionHandlerImpl module", - compileVersionHandlerImplTests.outputs.files[0], - [compileVersionHandlerImplTests]).with { task -> - setTestProperties(task, TestTypeEnum.NUNIT, TestModuleEnum.VERSIONHANDLER) -} - -Task compilePackageManagerResolverTests = createXbuildTask( - "compilePackageManagerResolverTests", - "Compile tests for PackageManagerResolver.", - project.ext.pluginSolutionFile, - "PackageManagerResolverTests", - fileTree(new File( - new File( - new File(project.ext.pluginSourceDir, - "PackageManagerResolver"), - "unit_tests"), - "src")), - new File(project.ext.testDir, "PackageManagerResolverTests"), - [new File("Google.PackageManagerResolverTests.dll")], - [buildPackageManagerResolver]) -compilePackageManagerResolverTests.with { task -> - setTestProperties(task, TestTypeEnum.NUNIT, TestModuleEnum.PACKAGEMANAGER) - doFirst { checkNUnitDllPath() } -} +createUnityNUnitTest( + "testVersionHandlerImplNUnitTests", + "Runs NUnit tests for the VersionHandlerImpl module.", + [], + new File(project.ext.scriptDirectory, + "source/VersionHandlerImpl/unit_tests"), [], + TestTypeEnum.NUNIT, TestModuleEnum.VERSIONHANDLER +) -createNUnitTask( - "testPackageManagerResolver", - "Runs tests for the PackageManagerResolver module", - compilePackageManagerResolverTests.outputs.files[0], - [compilePackageManagerResolverTests]).with { task -> - setTestProperties(task, TestTypeEnum.NUNIT, TestModuleEnum.PACKAGEMANAGER) -} +createUnityNUnitTest( + "testPackageManagerResolverNUnitTests", + "Runs NUnit tests for the PackageManagerResolver module.", + [], + new File(project.ext.scriptDirectory, + "source/PackageManagerResolver/unit_tests"), [], + TestTypeEnum.NUNIT, TestModuleEnum.PACKAGEMANAGER +) createUnityTestBatchAndNonBatch( "testVersionHandlerActivation", diff --git a/source/AndroidResolver/Properties/AssemblyInfo.cs b/source/AndroidResolver/Properties/AssemblyInfo.cs index a4691a3c..2d9fbd82 100644 --- a/source/AndroidResolver/Properties/AssemblyInfo.cs +++ b/source/AndroidResolver/Properties/AssemblyInfo.cs @@ -57,3 +57,4 @@ [assembly: InternalsVisibleTo("Google.IOSResolver")] // Uses all classes for testing. [assembly: InternalsVisibleTo("Google.AndroidResolverIntegrationTests")] +[assembly: InternalsVisibleTo("Google.AndroidResolverTests")] diff --git a/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/AndroidResolverTests.asmdef b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/AndroidResolverTests.asmdef new file mode 100644 index 00000000..1df88e66 --- /dev/null +++ b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/AndroidResolverTests.asmdef @@ -0,0 +1,25 @@ +{ + "name": "Google.AndroidResolverTests", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll", + "Google.VersionHandler.dll", + "Google.VersionHandlerImpl.dll", + "Google.JarResolver.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} diff --git a/source/JarResolverTests/src/Google.JarResolver.Tests/DependencyTests.cs b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/src/Google.JarResolver.Tests/DependencyTests.cs similarity index 100% rename from source/JarResolverTests/src/Google.JarResolver.Tests/DependencyTests.cs rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/src/Google.JarResolver.Tests/DependencyTests.cs diff --git a/source/JarResolverTests/src/Google.JarResolver.Tests/PlayServicesSupportTests.cs b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/src/Google.JarResolver.Tests/PlayServicesSupportTests.cs similarity index 100% rename from source/JarResolverTests/src/Google.JarResolver.Tests/PlayServicesSupportTests.cs rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/src/Google.JarResolver.Tests/PlayServicesSupportTests.cs diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/artifact/7.0.0/artifact-7.0.0.aar b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/7.0.0/artifact-7.0.0.aar similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/artifact/7.0.0/artifact-7.0.0.aar rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/7.0.0/artifact-7.0.0.aar diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/artifact/7.0.0/artifact-7.0.0.pom b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/7.0.0/artifact-7.0.0.pom similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/artifact/7.0.0/artifact-7.0.0.pom rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/7.0.0/artifact-7.0.0.pom diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/artifact/8.1.0/artifact-8.1.0.aar b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/8.1.0/artifact-8.1.0.aar similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/artifact/8.1.0/artifact-8.1.0.aar rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/8.1.0/artifact-8.1.0.aar diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/artifact/8.1.0/artifact-8.1.0.pom b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/8.1.0/artifact-8.1.0.pom similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/artifact/8.1.0/artifact-8.1.0.pom rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/8.1.0/artifact-8.1.0.pom diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/artifact/8.2.0-alpha/artifact-8.2.0-alpha.aar b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/8.2.0-alpha/artifact-8.2.0-alpha.aar similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/artifact/8.2.0-alpha/artifact-8.2.0-alpha.aar rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/8.2.0-alpha/artifact-8.2.0-alpha.aar diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/artifact/8.2.0-alpha/artifact-8.2.0-alpha.pom b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/8.2.0-alpha/artifact-8.2.0-alpha.pom similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/artifact/8.2.0-alpha/artifact-8.2.0-alpha.pom rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/8.2.0-alpha/artifact-8.2.0-alpha.pom diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/artifact/maven-metadata.xml b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/maven-metadata.xml similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/artifact/maven-metadata.xml rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/artifact/maven-metadata.xml diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/subdep/0.9/subdep-0.9.aar b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/subdep/0.9/subdep-0.9.aar similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/subdep/0.9/subdep-0.9.aar rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/subdep/0.9/subdep-0.9.aar diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/subdep/0.9/subdep-0.9.pom b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/subdep/0.9/subdep-0.9.pom similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/subdep/0.9/subdep-0.9.pom rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/subdep/0.9/subdep-0.9.pom diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/subdep/1.1.0/subdep-1.1.0.aar b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/subdep/1.1.0/subdep-1.1.0.aar similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/subdep/1.1.0/subdep-1.1.0.aar rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/subdep/1.1.0/subdep-1.1.0.aar diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/subdep/1.1.0/subdep-1.1.0.pom b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/subdep/1.1.0/subdep-1.1.0.pom similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/subdep/1.1.0/subdep-1.1.0.pom rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/subdep/1.1.0/subdep-1.1.0.pom diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/subdep/maven-metadata.xml b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/subdep/maven-metadata.xml similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/subdep/maven-metadata.xml rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/subdep/maven-metadata.xml diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/transdep/1.0.0/transdep-1.0.0.aar b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/transdep/1.0.0/transdep-1.0.0.aar similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/transdep/1.0.0/transdep-1.0.0.aar rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/transdep/1.0.0/transdep-1.0.0.aar diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/transdep/1.0.0/transdep-1.0.0.pom b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/transdep/1.0.0/transdep-1.0.0.pom similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/transdep/1.0.0/transdep-1.0.0.pom rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/transdep/1.0.0/transdep-1.0.0.pom diff --git a/source/JarResolverTests/testData/extras/google/m2repository/test/transdep/maven-metadata.xml b/source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/transdep/maven-metadata.xml similarity index 100% rename from source/JarResolverTests/testData/extras/google/m2repository/test/transdep/maven-metadata.xml rename to source/AndroidResolver/unit_tests/Assets/AndroidResolverTests/testData/extras/google/m2repository/test/transdep/maven-metadata.xml diff --git a/source/JarResolverTests/JarResolverTests.csproj b/source/JarResolverTests/JarResolverTests.csproj deleted file mode 100644 index 4a9acd0d..00000000 --- a/source/JarResolverTests/JarResolverTests.csproj +++ /dev/null @@ -1,75 +0,0 @@ - - - - Debug - AnyCPU - {593254D7-6358-40A6-B0C8-F0616BBF499D} - Library - JarResolverTests - JarResolverTests - v2.0 - 1.2 - 12.0.0 - 2.0 - - - True - full - False - bin\Debug - DEBUG; - prompt - 4 - False - - - none - True - bin\Release - prompt - 4 - False - - - ..\packages\NUnit.2.6.3\lib\ - - - - - - $(NUnityHintPath)/nunit.framework.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - {CC4F239D-3C7F-4164-830F-9215AE15B32A} - JarResolverLib - - - - - - diff --git a/source/JarResolverTests/packages.config b/source/JarResolverTests/packages.config deleted file mode 100644 index d4e241a2..00000000 --- a/source/JarResolverTests/packages.config +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/source/PackageManagerResolver/unit_tests/src/PackageManagerRegistryTest.cs b/source/PackageManagerResolver/unit_tests/Assets/PackageManagerResolverTests/PackageManagerRegistryTest.cs similarity index 100% rename from source/PackageManagerResolver/unit_tests/src/PackageManagerRegistryTest.cs rename to source/PackageManagerResolver/unit_tests/Assets/PackageManagerResolverTests/PackageManagerRegistryTest.cs diff --git a/source/PackageManagerResolver/unit_tests/Assets/PackageManagerResolverTests/PackageManagerResolverTests.asmdef b/source/PackageManagerResolver/unit_tests/Assets/PackageManagerResolverTests/PackageManagerResolverTests.asmdef new file mode 100644 index 00000000..1826febe --- /dev/null +++ b/source/PackageManagerResolver/unit_tests/Assets/PackageManagerResolverTests/PackageManagerResolverTests.asmdef @@ -0,0 +1,25 @@ +{ + "name": "Google.PackageManagerResolverTests", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll", + "Google.VersionHandler.dll", + "Google.VersionHandlerImpl.dll", + "Google.PackageManagerResolver.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} diff --git a/source/PackageManagerResolver/unit_tests/src/PackageManifestModifierTest.cs b/source/PackageManagerResolver/unit_tests/Assets/PackageManagerResolverTests/PackageManifestModifierTest.cs similarity index 100% rename from source/PackageManagerResolver/unit_tests/src/PackageManifestModifierTest.cs rename to source/PackageManagerResolver/unit_tests/Assets/PackageManagerResolverTests/PackageManifestModifierTest.cs diff --git a/source/PackageManagerResolver/unit_tests/src/XmlPackageManagerRegistriesTest.cs b/source/PackageManagerResolver/unit_tests/Assets/PackageManagerResolverTests/XmlPackageManagerRegistriesTest.cs similarity index 100% rename from source/PackageManagerResolver/unit_tests/src/XmlPackageManagerRegistriesTest.cs rename to source/PackageManagerResolver/unit_tests/Assets/PackageManagerResolverTests/XmlPackageManagerRegistriesTest.cs diff --git a/source/PackageManagerResolver/unit_tests/PackageManagerResolverTests.csproj b/source/PackageManagerResolver/unit_tests/PackageManagerResolverTests.csproj deleted file mode 100644 index fca6aba1..00000000 --- a/source/PackageManagerResolver/unit_tests/PackageManagerResolverTests.csproj +++ /dev/null @@ -1,55 +0,0 @@ - - - - Debug - AnyCPU - {FEECDCE1-F528-4931-A4CF-808DDBCE1A8D} - Library - Google.PackageManagerResolver.Tests - Google.PackageManagerResolverTests - v2.0 - 1.2 - 12.0.0 - 2.0 - - - True - full - False - bin\Debug - DEBUG; - prompt - 4 - False - - - none - True - bin\Release - prompt - 4 - False - - - ..\packages\NUnit.2.6.3\lib\ - - - - - - $(NUnityHintPath)/nunit.framework.dll - - - - - - - - - - - {77EBE819-CBE6-4CA8-A791-ED747EA29D30} - PackageManagerResolver - - - diff --git a/source/VersionHandlerImpl/unit_tests/src/EditorMeasurementTest.cs b/source/VersionHandlerImpl/unit_tests/Assets/VersionHandlerImplTests/EditorMeasurementTest.cs similarity index 100% rename from source/VersionHandlerImpl/unit_tests/src/EditorMeasurementTest.cs rename to source/VersionHandlerImpl/unit_tests/Assets/VersionHandlerImplTests/EditorMeasurementTest.cs diff --git a/source/VersionHandlerImpl/unit_tests/src/FileUtilsTest.cs b/source/VersionHandlerImpl/unit_tests/Assets/VersionHandlerImplTests/FileUtilsTest.cs similarity index 100% rename from source/VersionHandlerImpl/unit_tests/src/FileUtilsTest.cs rename to source/VersionHandlerImpl/unit_tests/Assets/VersionHandlerImplTests/FileUtilsTest.cs diff --git a/source/VersionHandlerImpl/unit_tests/src/ProjectSettingsTest.cs b/source/VersionHandlerImpl/unit_tests/Assets/VersionHandlerImplTests/ProjectSettingsTest.cs similarity index 100% rename from source/VersionHandlerImpl/unit_tests/src/ProjectSettingsTest.cs rename to source/VersionHandlerImpl/unit_tests/Assets/VersionHandlerImplTests/ProjectSettingsTest.cs diff --git a/source/VersionHandlerImpl/unit_tests/Assets/VersionHandlerImplTests/VersionHandlerImplTests.asmdef b/source/VersionHandlerImpl/unit_tests/Assets/VersionHandlerImplTests/VersionHandlerImplTests.asmdef new file mode 100644 index 00000000..7061f59d --- /dev/null +++ b/source/VersionHandlerImpl/unit_tests/Assets/VersionHandlerImplTests/VersionHandlerImplTests.asmdef @@ -0,0 +1,24 @@ +{ + "name": "Google.VersionHandlerImplTests", + "references": [ + "UnityEngine.TestRunner", + "UnityEditor.TestRunner" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": true, + "precompiledReferences": [ + "nunit.framework.dll", + "Google.VersionHandler.dll", + "Google.VersionHandlerImpl.dll" + ], + "autoReferenced": false, + "defineConstraints": [ + "UNITY_INCLUDE_TESTS" + ], + "versionDefines": [], + "noEngineReferences": false +} diff --git a/source/VersionHandlerImpl/unit_tests/VersionHandlerImplTests.csproj b/source/VersionHandlerImpl/unit_tests/VersionHandlerImplTests.csproj deleted file mode 100644 index a9301e0d..00000000 --- a/source/VersionHandlerImpl/unit_tests/VersionHandlerImplTests.csproj +++ /dev/null @@ -1,55 +0,0 @@ - - - - Debug - AnyCPU - {9FD33878-5B6B-411D-A3C7-D2A5E7E63182} - Library - Google.VersionHandlerImpl.Tests - Google.VersionHandlerImplTests - v2.0 - 1.2 - 12.0.0 - 2.0 - - - True - full - False - bin\Debug - DEBUG; - prompt - 4 - False - - - none - True - bin\Release - prompt - 4 - False - - - ..\packages\NUnit.2.6.3\lib\ - - - - - - $(NUnityHintPath)/nunit.framework.dll - - - - - - - - - - - {1E162334-8EA2-440A-9B3A-13FD8FE5C22E} - VersionHandlerImpl - - - diff --git a/test_resources/nunit_upm/manifest.json b/test_resources/nunit_upm/manifest.json new file mode 100644 index 00000000..807a360d --- /dev/null +++ b/test_resources/nunit_upm/manifest.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "com.unity.test-framework": "1.1.33" + } +} diff --git a/test_resources/version_handler_update/VersionHandlerUpdater.cs b/test_resources/version_handler_update/VersionHandlerUpdater.cs new file mode 100644 index 00000000..b80b1884 --- /dev/null +++ b/test_resources/version_handler_update/VersionHandlerUpdater.cs @@ -0,0 +1,48 @@ +// +// Copyright (C) 2023 Google Inc. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +using System; +using System.Collections.Generic; +using System.Collections; +using System.IO; + +/// +/// Run Version Handler to ensure all the libraries are properly enabled. +/// +[UnityEditor.InitializeOnLoad] +public class VersionHandlerUpdater { + /// + /// Register a method to call when the Version Handler has enabled all plugins in the project. + /// + static VersionHandlerUpdater() { + // Disable stack traces for more condensed logs. + UnityEngine.Application.stackTraceLogType = UnityEngine.StackTraceLogType.None; + UnityEngine.Debug.Log("Set up callback on Version Handler completion."); + Google.VersionHandler.UpdateCompleteMethods = new [] { + ":VersionHandlerUpdater:VersionHandlerReady" + }; + UnityEngine.Debug.Log("Enable plugin using the Version Handler."); + Google.VersionHandler.UpdateNow(); + } + + /// + /// Called when the Version Handler has enabled all managed plugins in a project. + /// + public static void VersionHandlerReady() { + UnityEngine.Debug.Log("The plugin should now be enabled by the Version Handler."); + UnityEditor.EditorApplication.Exit(0); + } +}