Skip to content

Commit c859ad0

Browse files
committed
[java-source-utils] Fix regresion from 77c9c5f
Context: 77c9c5f Commit 77c9c5f introduced a regression in `tools/java-source-utils`, wherein the unit tests would fail, e.g. org.junit.ComparisonFailure: ../../../com/xamarin/JavaType.java Javadoc XML expected:<...um"> <javadoc>[<![CDATA[JNI sig: Lcom/xamarin/JavaEnum;]]></javadoc> … </m...> but was:<...um"> <javadoc>[ <![CDATA[JNI sig: Lcom/xamarin/JavaEnum;]]> Part of the problem is that this failure was *overlooked*; it's very common for PR builds to fail because mono SIGSEGVs, and we don't always take the time to restart failed PR builds to ensure that they're green (oops). The Windows builds, meanwhile, were green. Consequently, when commit 77c9c5f introduced a test failure in the `java-source-utils` unit tests, but we didn't see the failure. This "lack of seeing" is in part because we've become inured to test failures (mono SIGSEGVs), but also because the `java-source-utils` unit tests: 1. Are *only* run on the `mac_build` job, and 2. The results of the `java-source-utils` unit tests are not shown in DevOps' **Tests** tab. The only way to see the failure is to read the full **Mac - Mono** > **Run Tests** output, and know what you're looking for. Fix these two more fundamental issues: 1. Update `tools/java-source-utils/build.gradle` so that when `gradle test` is run, JUnit XML-formatted test result files are created. 2. Update `core-tests.yaml` so that the `java-source-utils` unit tests are executed. 3. Publish the XML files created between (1) and (2). This should ensure that future `java-source-utils` failures are appropriately seen and not ignored. I then ran a PR build without fixing anything, verifying that the **Tests** tab now shows the expected unit tests failures. Fix the `java-source-utils` unit test expected output, so that the `java-source-utils` unit tests pass once again…on macOS. They don't current pass on Windows, for currently unknown reasons (but probably line ending-related). We will enable Windows support later.
1 parent 7f1a5ab commit c859ad0

File tree

9 files changed

+50
-18
lines changed

9 files changed

+50
-18
lines changed

build-tools/automation/azure-pipelines.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,7 @@ jobs:
7070
msbuildArguments: /p:TestAssembly="bin\Test$(Build.Configuration)\generator-Tests.dll;bin\Test$(Build.Configuration)\Java.Interop.Tools.JavaCallableWrappers-Tests.dll;bin\Test$(Build.Configuration)\logcat-parse-Tests.dll;bin\Test$(Build.Configuration)\Xamarin.Android.Tools.ApiXmlAdjuster-Tests.dll;bin\Test$(Build.Configuration)\Xamarin.Android.Tools.Bytecode-Tests.dll;bin\Test$(Build.Configuration)\Java.Interop.Tools.Generator-Tests.dll;bin\Test$(Build.Configuration)\Xamarin.SourceWriter-Tests.dll"
7171
condition: succeededOrFailed()
7272

73-
- task: PublishTestResults@2
74-
displayName: Publish Test Results
75-
inputs:
76-
testResultsFormat: NUnit
77-
testResultsFiles: TestResult-*.xml
78-
condition: succeededOrFailed()
73+
- template: templates\publish-test-results.yaml
7974

8075
- job: windows_dotnet_build
8176
displayName: Windows - .NET Core
@@ -145,12 +140,7 @@ jobs:
145140
exit $r
146141
displayName: Run Tests
147142
148-
- task: PublishTestResults@2
149-
displayName: Publish Test Results
150-
inputs:
151-
testResultsFormat: NUnit
152-
testResultsFiles: TestResult-*.xml
153-
condition: succeededOrFailed()
143+
- template: templates\publish-test-results.yaml
154144

155145
- task: CopyFiles@2
156146
displayName: 'Copy Files to: Artifact Staging Directory'
@@ -189,5 +179,6 @@ jobs:
189179
- template: templates\core-tests.yaml
190180
parameters:
191181
runNativeTests: true
182+
runJavaTests: true
192183

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

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
parameters:
22
condition: succeeded()
33
runNativeTests: false
4+
runJavaTests: false
45

56
steps:
67
- task: DotNetCoreCLI@2
@@ -106,3 +107,18 @@ steps:
106107
command: test
107108
arguments: bin/Test$(Build.Configuration)$(NetCoreTargetFrameworkPathSuffix)/Java.Interop-PerformanceTests.dll
108109
continueOnError: true
110+
111+
- task: DotNetCoreCLI@2
112+
displayName: 'Tests: java-source-utils'
113+
condition: eq('${{ parameters.runJavaTests }}', 'true')
114+
inputs:
115+
command: build
116+
arguments: tools/java-source-utils/java-source-utils.csproj /t:RunTests
117+
continueOnError: true
118+
119+
- task: PublishTestResults@2
120+
displayName: Publish JUnit Test Results
121+
inputs:
122+
testResultsFormat: JUnit
123+
testResultsFiles: 'tools/java-source-utils/build/test-results/**/TEST-*.xml'
124+
condition: succeededOrFailed()
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
steps:
2+
- task: PublishTestResults@2
3+
displayName: Publish NUnit Test Results
4+
inputs:
5+
testResultsFormat: NUnit
6+
testResultsFiles: TestResult-*.xml
7+
condition: succeededOrFailed()
8+
9+
- task: PublishTestResults@2
10+
displayName: Publish JUnit Test Results
11+
inputs:
12+
testResultsFormat: JUnit
13+
testResultsFiles: '**/TEST-*.xml'
14+
condition: succeededOrFailed()

build-tools/scripts/RunNUnitTests.targets

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,10 @@
2929
WorkingDirectory="$(_TopDir)"
3030
ContinueOnError="ErrorAndContinue"
3131
/>
32+
<MSBuild
33+
Condition=" !$([MSBuild]::IsOSPlatform ('windows')) "
34+
Projects="$(MSBuildThisFileDirectory)..\..\tools\java-source-utils\java-source-utils.csproj"
35+
Targets="RunTests"
36+
/>
3237
</Target>
3338
</Project>

tools/java-source-utils/build.gradle

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,9 @@ jar {
5454
}
5555
archiveName 'java-source-utils.jar'
5656
}
57+
58+
test {
59+
reports {
60+
junitXml.enabled = true
61+
}
62+
}

tools/java-source-utils/src/test/resources/UnresolvedTypes.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ public class UnresolvedTypes {
44
/**
55
* Method using unresolvable types. As such, we make do.
66
*
7-
* JNI Sig: method.(L.*example.name.UnresolvedParameterType;)L.*UnresolvedReturnType;
7+
* JNI Sig: method.([L.*example.name.UnresolvedParameterType;)L.*UnresolvedReturnType;
88
*/
99
public static UnresolvedReturnType<String, Integer> method(example.name.UnresolvedParameterType<Class>... parameter) {
1010
}

tools/java-source-utils/src/test/resources/UnresolvedTypes.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
<api api-source="java-source-utils">
33
<package jni-name="example" name="example">
44
<class jni-signature="Lexample/UnresolvedTypes;" name="UnresolvedTypes">
5-
<method jni-return="L.*UnresolvedReturnType;" jni-signature="(L.*example.name.UnresolvedParameterType;)L.*UnresolvedReturnType;" name="method" return=".*UnresolvedReturnType">
5+
<method jni-return="L.*UnresolvedReturnType;" jni-signature="([L.*example.name.UnresolvedParameterType;)L.*UnresolvedReturnType;" name="method" return=".*UnresolvedReturnType">
66
<parameter jni-type="[L.*example.name.UnresolvedParameterType;" name="parameter" type=".*example.name.UnresolvedParameterType..."/>
77
<javadoc><![CDATA[Method using unresolvable types. As such, we make do.
88
9-
JNI Sig: method.(L.*example.name.UnresolvedParameterType;)L.*UnresolvedReturnType;]]></javadoc>
9+
JNI Sig: method.([L.*example.name.UnresolvedParameterType;)L.*UnresolvedReturnType;]]></javadoc>
1010
</method>
1111
</class>
1212
</package>

tools/java-source-utils/src/test/resources/com/microsoft/android/JavaType.params.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ package com.xamarin
1010
func(java.lang.String[] values)
1111
<T> instanceActionWithGenerics(T value1, E value2)
1212
<T, TExtendsNumber, TThrowable> staticActionWithGenerics(T value1, TExtendsNumber value2, java.util.List<?> unboundedList, java.util.List<? extends java.lang.Number> extendsList, java.util.List<? super java.lang.Throwable> superList)
13-
sum(int first, int remaining)
13+
sum(int first, int... remaining)
1414
class JavaType.ASC<E>
1515
class JavaType.PSC<E>
1616
class JavaType.RNC<E,E2>

tools/java-source-utils/src/test/resources/com/microsoft/android/JavaType.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@
127127
<parameter jni-type="Ljava/util/List;" name="superList" type="java.util.List&lt;? super java.lang.Throwable&gt;"/>
128128
<javadoc><![CDATA[JNI sig: staticActionWithGenerics.(Ljava/lang/Object;Ljava/lang/Number;Ljava/util/List;Ljava/util/List;Ljava/util/List;)V]]></javadoc>
129129
</method>
130-
<method jni-return="I" jni-signature="(II)I" name="sum" return="int">
130+
<method jni-return="I" jni-signature="(I[I)I" name="sum" return="int">
131131
<parameter jni-type="I" name="first" type="int"/>
132-
<parameter jni-type="I" name="remaining" type="int"/>
132+
<parameter jni-type="[I" name="remaining" type="int..."/>
133133
<javadoc><![CDATA[JNI sig: sum.(I[I)I]]></javadoc>
134134
</method>
135135
</class>

0 commit comments

Comments
 (0)