Repository navigation
Let the v3 engine run tests on Android in Debug builds - #1967
Conversation
Two desktop assumptions stopped a Debug `dotnet test --device` run on an Android emulator before any test ran (nunit#1966): - The extension scan walks every parent folder of the engine, and Android denies listing some of them, such as /data/user/0. DirectoryFinder now treats a folder it may not list as having no matches. - TestAssemblyResolver constructs an AssemblyDependencyResolver, which throws PlatformNotSupportedException on mobile runtimes. There is no deps.json to read there, so the resolver now goes without it and relies on its other strategies.
In an Android Release build the engine is packed inside the APK, so its
Assembly.Location is empty. FindExtensionAssemblies passed
Path.GetDirectoryName("") (null) to Path.Combine, which threw
ArgumentNullException before any test could run (nunit#1966). An assembly that
is not a file has no folders around it to search, so the scan now returns
early.
oznetmaster
left a comment
There was a problem hiding this comment.
@zhollis21, I reviewed head e943786 and ran the additional Windows desktop checks requested by @CharliePoole.
- Complete engine-core suite on .NET 8: 452 passed, zero failed, one skipped.
- Complete engine-core suite on .NET Framework: 622 passed, zero failed, fourteen inconclusive, one skipped.
- All three new desktop regressions fail with the original DirectoryFinder/ExtensionManager code and pass after restoring the PR, on both targets.
- Our existing NUnit 5 entry-point probes pass on Framework, .NET 8 and .NET 10: discovery, exact filtering, passing/failing results and cooperative cancellation, including token delivery and finally/teardown receipts.
Building the complete solution supplies the FakeExtensions test data, so the twelve missing-fixture failures in the description do not reproduce here. The full build succeeds with the SDK's existing net6.0 end-of-support warning; no source change or warning suppression was needed.
I found no blocking issue in the narrow desktop changes. I also checked that the current filesystem wrapper materializes its directory results within GetDirectories, so its access-denied exception is inside the new catch. The resolver fallback catches PlatformNotSupportedException specifically, preserving other initialization failures.
These results do not independently validate Android or resolve Release APK discovery. The reporter's device evidence remains the validation for the unsupported-resolver path, and the zero-test Release case should remain tracked separately. The PR can be assessed as these scoped corrections without claiming full Android support.
No merge while Charlie's hold remains in effect.
Neil Colvin, with assistance from OpenAI Codex.
|
@oznetmaster My request to hold back updates applies to main, not version3. However, we still need to decide whether this is worth doing without the Release portion. @zhollis21 placed this in draft status as well. A key question is whether we can pass a loaded assembly as a byte array and load it that way. I haven't had time to examine the V3 code but I believe we once had that ability. Since we never really used it as intended, it may have been removed. We won't be releasing 3.23.0 until the .NET 11.0 agent is merged to it, so this could be a problem for next week. :-) |
|
@CharliePoole, thanks for clarifying that the hold applies to main rather than version3. I will keep that distinction explicit; #1967 remains a draft pending the scope decision. I checked the current v3 path and ran a small desktop probe against this PR's unchanged engine binaries. A fixture loaded with Assembly.Load(byte[]) has an empty Location. The existing file-based lookup does not select it, the driver rejects an empty path, and DriverService rejects a missing file before selecting a framework driver. IFrameworkDriver.Load still accepts a string path; I have not found a current public engine entry point accepting an Assembly or its bytes. The lower-level framework capability does exist: passing that same byte-loaded Assembly directly to FrameworkController discovers all ten fixture cases. That probe used NUnit 5.1.0-alpha.0.50 on Windows/.NET 10; it is not Android validation. It demonstrates the distinction between framework support and the adapter/engine plumbing needed to reach it. I have not established when any earlier engine byte-array support was removed. My preference is to agree the limited scope with @zhollis21: the three robustness fixes can be useful independently, but the PR should not imply complete Android support. If Debug-only support is acceptable for 3.23.0, I would keep the Release/loaded-assembly work tracked in #1966 and describe this PR accordingly. If the acceptance requirement is working Release packaging, it should remain a draft until that path is proven. I would avoid making a broader adapter redesign an implicit part of these three fixes. Neil Colvin, with assistance from OpenAI Codex. |
|
@zhollis21 If you want to have the PR merged into the version3 branch for inclusion in the next release, please remove the draft status and let @oznetmaster know. |
|
@oznetmaster Thanks for the review and the extra probes. I've taken this out of draft and retitled it for Debug builds, so it doesn't claim full Android support. Release and the loaded-assembly path stay tracked in #1966. It's ready for you whenever suits. |
oznetmaster
left a comment
There was a problem hiding this comment.
@zhollis21, thank you for narrowing the title and description to the three robustness fixes and Debug support, with Release APK discovery remaining in #1966.
The source is still e943786, which I reviewed and validated above. The complete desktop core suites, additional NUnit 5 entry-point probes and three before/after regressions remain applicable; hosted CI and CLA are green.
Approved for this scoped change to version3. This does not establish Android Release support or a file-free adapter/engine loading path. Charlie has clarified that his synchronization hold applies to main, not version3.
Neil Colvin, with assistance from OpenAI Codex.
|
@oznetmaster Note labeling change and assignment to @zhollis21. In those rare cases where a PR does not close an issue but accomplishes some improvement that should be included in the generated release notes, this is how I do it. |
|
This issue has been resolved in version 3.23.0 The release is available on: |
Part of #1966. Scoped to three robustness fixes: they let Debug builds run on Android, but Release still runs no tests (see below), and that stays tracked in #1966.
With these changes and nunit/nunit3-vs-adapter#1550, a Debug
dotnet test --devicerun on an Android emulator gets through discovery and execution: 1 passed, 1 failed, 1 skipped, which is what the repro's tests are written to produce.Changes
DirectoryFinder: skip folders that cannot be listed. The extension scan walks every parent folder of the engine. On Android the engine is under/data/user/0/<package>/files/..., and listing/data/user/0throwsUnauthorizedAccessException, which ended the whole scan. A folder we may not list now contributes no matches. Two new tests inDirectoryFinderTestscover the single-level and**cases; both fail without the change.ExtensionManager.FindExtensionAssemblies: return early when the host assembly has no location. In Release the engine is packed inside the APK, soAssembly.Locationis empty, andPath.Combine(Path.GetDirectoryName(""), ...)threwArgumentNullException. An assembly that is not a file has no folders around it to search. The new test loads an assembly from bytes, which has an emptyLocationon desktop too, and fails without the change with the same exception seen on the device.TestAssemblyResolver: go withoutAssemblyDependencyResolverwhere it is not supported. Its constructor throwsPlatformNotSupportedExceptionon mobile runtimes, which surfaced as "Failed to load the test assembly" fromNUnitNetCore31Driver.Load. There is no deps.json to read there, so the resolver now catches that one exception and relies on its other strategies. This one only happens on a mobile runtime, so it's verified on the emulator only.Not covered: Release
With the
ExtensionManagerchange, a Release run no longer errors, but it reports zero tests. The test assembly is also inside the APK, with an emptyLocation, and the adapter and engine identify test assemblies by file path, so there is no path to hand the engine. #1808's already-loaded lookup matches by path too. I don't think that has a narrow fix: it needs a way to pass an already-loadedAssemblythrough, which is the design question in #1966.Testing
nunit.engine.core.testson .NET 8 and .NET Framework: no failures on a full solution build (thanks @oznetmaster, who also ran the NUnit 5 entry-point probes). The three new tests fail without these changes and pass with them.dotnet new androidtestrepro described in Running NUnit tests on an Android device withdotnet test --devicefails inside the NUnit engine #1966, with the adapter built from Skip Console.CancelKeyPress where the platform does not support it nunit3-vs-adapter#1550 and this engine packed into it.