Skip to content

Commit bba1f07

Browse files
authored
[ci] Enable native tests for macOS+dotnet test (#806)
Context: #804 Two changes within commit 89a5a22 allow `dotnet test` to be used to run the net472 mono-required NUnit tests: 1. The `java-interop` native library is reliably copied to the `$(OutputPath)` of referencing projects. This ensures that e.g. `bin/TestDebug/libjava-interop.dylib` exists without extra `make` commands or an `msbuild /t:RunTests` invocation. 2. More importantly, `tests/TestJVM` was updated to use `Xamarin.Android.Tools.AndroidSdk.dll` along with `JdkInfo.GetKnownSystemJdkInfos()`. (2) means that the `JI_JVM_PATH` environment variable doesn't *need* to be set before running unit tests, and is largely responsible for allowing `dotnet test` to work: % make prepare all % dotnet test bin/TestDebug/Java.Interop-Tests.dll … Passed! - Failed: 0, Passed: 631, Skipped: 1, Total: 632, Duration: 686 ms Note that these tests are *not* executed under .NET Core/CoreCLR! It's simply using `dotnet test` as an equivalent to/replacement for `mono nunit3-console.exe`. Java.Interop-Tests to be run under .NET Core are built into e.g. `bin/TestDebug-netcoreapp3.1/Java.Interop-Tests.dll`, and trying to run *that* test suite crashes and burns: % dotnet test bin/TestDebug-netcoreapp3.1/Java.Interop-Tests.dll … Failed! - Failed: 16, Passed: 325, Skipped: 1, Total: 342, Duration: 311 ms See e.g. PR #804 for an attempt to make .NET Core support work.
1 parent 27c7bf4 commit bba1f07

File tree

2 files changed

+24
-19
lines changed

2 files changed

+24
-19
lines changed

build-tools/automation/azure-pipelines.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,7 @@ jobs:
160160
- template: templates\core-build.yaml
161161

162162
- template: templates\core-tests.yaml
163+
parameters:
164+
runNativeTests: true
163165

164166
- template: templates\fail-on-issue.yaml

build-tools/automation/templates/core-tests.yaml

+22-19
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
parameters:
22
condition: succeeded()
3+
runNativeTests: false
34

45
steps:
56
- task: DotNetCoreCLI@2
@@ -58,24 +59,26 @@ steps:
5859
arguments: bin/Test$(Build.Configuration)/Xamarin.SourceWriter-Tests.dll
5960
continueOnError: true
6061

61-
# Running native Java.Interop tests are not yet supported on .NET Core
62-
#- task: DotNetCoreCLI@2
63-
# displayName: 'Tests: Java.Interop'
64-
# inputs:
65-
# command: test
66-
# arguments: bin/Test$(Build.Configuration)/Java.Interop-Tests.dll
67-
# continueOnError: true
62+
- task: DotNetCoreCLI@2
63+
displayName: 'Tests: Java.Interop'
64+
condition: eq('${{ parameters.runNativeTests }}', 'true')
65+
inputs:
66+
command: test
67+
arguments: bin/Test$(Build.Configuration)/Java.Interop-Tests.dll
68+
continueOnError: true
6869

69-
#- task: DotNetCoreCLI@2
70-
# displayName: 'Tests: Java.Interop.Dynamic'
71-
# inputs:
72-
# command: test
73-
# arguments: bin/Test$(Build.Configuration)/Java.Interop.Dynamic-Tests.dll
74-
# continueOnError: true
70+
- task: DotNetCoreCLI@2
71+
displayName: 'Tests: Java.Interop.Dynamic'
72+
condition: eq('${{ parameters.runNativeTests }}', 'true')
73+
inputs:
74+
command: test
75+
arguments: bin/Test$(Build.Configuration)/Java.Interop.Dynamic-Tests.dll
76+
continueOnError: true
7577

76-
#- task: DotNetCoreCLI@2
77-
# displayName: 'Tests: Java.Interop.Export'
78-
# inputs:
79-
# command: test
80-
# arguments: bin/Test$(Build.Configuration)/Java.Interop.Export-Tests.dll
81-
# continueOnError: true
78+
- task: DotNetCoreCLI@2
79+
displayName: 'Tests: Java.Interop.Export'
80+
condition: eq('${{ parameters.runNativeTests }}', 'true')
81+
inputs:
82+
command: test
83+
arguments: bin/Test$(Build.Configuration)/Java.Interop.Export-Tests.dll
84+
continueOnError: true

0 commit comments

Comments
 (0)