Skip to content

Commit

Permalink
[ci] Enable native tests for macOS+dotnet test (#806)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jpobst committed Feb 19, 2021
1 parent 27c7bf4 commit bba1f07
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 19 deletions.
2 changes: 2 additions & 0 deletions build-tools/automation/azure-pipelines.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,7 @@ jobs:
- template: templates\core-build.yaml

- template: templates\core-tests.yaml
parameters:
runNativeTests: true

- template: templates\fail-on-issue.yaml
41 changes: 22 additions & 19 deletions build-tools/automation/templates/core-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
parameters:
condition: succeeded()
runNativeTests: false

steps:
- task: DotNetCoreCLI@2
Expand Down Expand Up @@ -58,24 +59,26 @@ steps:
arguments: bin/Test$(Build.Configuration)/Xamarin.SourceWriter-Tests.dll
continueOnError: true

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

#- task: DotNetCoreCLI@2
# displayName: 'Tests: Java.Interop.Dynamic'
# inputs:
# command: test
# arguments: bin/Test$(Build.Configuration)/Java.Interop.Dynamic-Tests.dll
# continueOnError: true
- task: DotNetCoreCLI@2
displayName: 'Tests: Java.Interop.Dynamic'
condition: eq('${{ parameters.runNativeTests }}', 'true')
inputs:
command: test
arguments: bin/Test$(Build.Configuration)/Java.Interop.Dynamic-Tests.dll
continueOnError: true

#- task: DotNetCoreCLI@2
# displayName: 'Tests: Java.Interop.Export'
# inputs:
# command: test
# arguments: bin/Test$(Build.Configuration)/Java.Interop.Export-Tests.dll
# continueOnError: true
- task: DotNetCoreCLI@2
displayName: 'Tests: Java.Interop.Export'
condition: eq('${{ parameters.runNativeTests }}', 'true')
inputs:
command: test
arguments: bin/Test$(Build.Configuration)/Java.Interop.Export-Tests.dll
continueOnError: true

0 comments on commit bba1f07

Please sign in to comment.