UnityTasks.UnityRunTests API does not DetectUnityVersion from project
Usage Information
Nuke 8.1.0 / 8.0.201 / net8.0 / macOS Sonoma 14.3.1
Description
When using UnityTasks.Unity without specifying a Unity editor version, it defaults to auto-detecting the version from the ProjectSettings/ProjectVersion.txt file.
However, when using UnityTasks.UnityRunTests this doesn't happen, but I would expect it to behave the same way and call DetectUnityVersion within.
Reproduction Steps
Open the repro project: Uploading NukeBugReport_UnityTasks_UnityAutoDetectNotImplementedForTests.zip…
This project uses Nuke 8.0.0, but the issue also happens in 8.1.0.
For full functionality, install Unity 2021.3.21.
Run:
Nuke Test
Expected Behavior
UnityTasks.UnityRunTests should detect the Unity editor version from the project and run successfully.
Actual Behavior
UnityTasks.UnityRunTests is used, but it doesn't detect the desired Unity editor version, instead it fails with:
System.ArgumentException: Expected file to exist: /Applications/Unity/Unity.app/Contents/MacOS/Unity (Parameter 'toolPath')
It is trying to run the (old legacy) default Unity editor path instead of the one specified in the project.
Analysis
Callstack with desired behaviour:
- IReadOnlyCollection<Output> Unity(Configure<UnitySettings> configurator)
- IReadOnlyCollection<Output> Unity(UnitySettings toolSettings = null)
- PreProcess(ref UnitySettings unitySettings) (line 65)
- DetectUnityVersion(ref UnitySettings unitySettings)
Callstack with undesired behaviour:
- IReadOnlyCollection<Output> UnityRunTests(Configure<UnityRunTestsSettings> configurator)
- IReadOnlyCollection<Output> UnityRunTests(UnityRunTestsSettings toolSettings = null)
- PreProcess<T>(ref T unitySettings) where T : UnityBaseSettings (line 99) (no DetectUnityVersion call)
Regression?
No response
Known Workarounds
Yes:
Nuke TestWorkaround
Output:
/Applications/Unity/Hub/Editor/2021.3.21f1/Unity.app/Contents/MacOS/Unity ...
This uses UnityTasks.Unity which uses DetectUnityVersion internally.
Could you help with a pull-request?
Yes
I went ahead and would like to propose a fix here: https://github.com/nuke-build/nuke/pull/1428 Feel free to implement a different solution. :)
I think this should be fixed in 9.0.1... but please check and reopen if necessary.