Skip to content

Commit 9fecba2

Browse files
jonpryoratsushieno
authored andcommitted
[tests] Export JI_JVM_PATH in NUnit tests
Context: https://jenkins.mono-project.com/job/xamarin-android-pr-builder/3640/ Commit d1cce19 broke unit test execution within xamarin-android, as d1cce19 requires that the path to `jvm.dll` be specified within the `$JI_JVM_PATH` environment variable, but `RunNUnitTests.targets` never set or exported that environment variable. The result is that `$JI_JVM_PATH` wasn't set, causing tests to fail: OneTimeSetUp: System.TypeInitializationException : The type initializer for 'Java.InteropTests.JavaVMFixture' threw an exception. ----> System.NotSupportedException : The JDK supports creating at most one JVM per process, ever; do you have a JVM running already, or have you already created (and destroyed?) one? (JNI_CreateJavaVM returned -1002). Code -1002 is `JAVA_INTEROP_JVM_FAILED_NOT_LOADED`, because it wasn't specified and couldn't be found. Update `RunNUnitTests.targets` so that `$JI_JVM_PATH` is exported, allowing `jvm.dll` to be found, in turn allowing unit tests to run.
1 parent a2deeab commit 9fecba2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

build-tools/scripts/RunNUnitTests.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
<_NUnit>$(_Runtime) packages\NUnit.ConsoleRunner.3.7.0\tools\nunit3-console.exe</_NUnit>
99
<_Run Condition=" '$(RUN)' != '' ">--run=&quot;$(RUN)&quot;</_Run>
1010
</PropertyGroup>
11+
<Import
12+
Condition=" Exists('..\..\bin\Build$(Configuration)\JdkInfo.props') "
13+
Project="..\..\bin\Build$(Configuration)\JdkInfo.props"
14+
/>
1115
<UsingTask AssemblyFile="$(MSBuildThisFileDirectory)..\..\bin\Build$(Configuration)\Java.Interop.BootstrapTasks.dll" TaskName="Java.Interop.BootstrapTasks.SetEnvironmentVariable" />
1216
<ItemGroup>
1317
<_TestAssembly Include="$(_TopDir)\bin\Test$(Configuration)\*-*Tests.dll" Condition=" '$(TestAssembly)' == '' " />
@@ -27,6 +31,7 @@
2731
<SetEnvironmentVariable Name="MONO_TRACE_LISTENER" Value="Console.Out" />
2832
<SetEnvironmentVariable Name="JAVA_INTEROP_GREF_LOG" Value="bin\Test$(Configuration)\g-%(_TestAssembly.Filename).txt" />
2933
<SetEnvironmentVariable Name="JAVA_INTEROP_LREF_LOG" Value="bin\Test$(Configuration)\l-%(_TestAssembly.Filename).txt" />
34+
<SetEnvironmentVariable Name="JI_JVM_PATH" Value="$(JdkJvmPath)" />
3035
<Exec
3136
Command="$(_NUnit) $(NUNIT_EXTRA) %(_TestAssembly.Identity) $(_Run) --result=&quot;TestResult-%(Filename).xml;format=nunit2&quot; --output=&quot;bin\Test$(Configuration)\TestOutput-%(Filename).txt&quot;"
3237
WorkingDirectory="$(_TopDir)"

0 commit comments

Comments
 (0)