Skip to content

Commit 476597b

Browse files
pjcollinsjonathanpeppers
authored andcommitted
[tests] Convert to Unix style line endings (#551)
Context: dotnet/android@130905e Context: xamarin/QualityAssurance#3478 We've recently started running `Java.Interop` tests on an Android target as part of the `Mono.Android-Tests` suite. This has introduced some seemingly harmless failures[0] when building this suite on Windows and then running it on Android. We can fix this by converting line endings before comparing strings. [0]: 01-02 16:18:11.949 I/NUnit (23743): Failed tests: 01-02 16:18:11.949 I/NUnit (23743): 1) Java.InteropTests.JniValueMarshaler_Boolean_ContractTests.JniValueMarshalerContractTests`1.CreateReturnValueFromManagedExpression (Java.Interop-Tests) 01-02 16:18:11.949 I/NUnit (23743): Expected string length 111 but was 99. Strings differ at index 1. 01-02 16:18:11.949 I/NUnit (23743): Expected: "{\r\n\tJniRuntime __jvm;\r\n\tbool __value;\r\n\r\n\ttry\r\n\t{\r\n\t\treturn _..." 01-02 16:18:11.949 I/NUnit (23743): But was: "{\n\tJniRuntime __jvm;\n\tbool __value;\n\n\ttry\n\t{\n\t\treturn __value..." 01-02 16:18:11.949 I/NUnit (23743): -------------^ 01-02 16:18:11.949 I/NUnit (23743): 01-02 16:18:11.949 I/NUnit (23743): at Java.InteropTests.JniValueMarshalerContractTests`1[T].CheckExpression (Java.Interop.Expressions.JniValueMarshalerContext context, System.String expected, System.Linq.Expressions.Expression ret) [0x00083] in <59a94475f2544934836dac1b5c1cf1e1>:0 01-02 16:18:11.949 I/NUnit (23743): 2) Java.InteropTests.JniValueMarshaler_Char_ContractTests.JniValueMarshalerContractTests`1.CreateReturnValueFromManagedExpression (Java.Interop-Tests) 01-02 16:18:11.949 I/NUnit (23743): Expected string length 111 but was 99. Strings differ at index 1. 01-02 16:18:11.949 I/NUnit (23743): Expected: "{\r\n\tJniRuntime __jvm;\r\n\tchar __value;\r\n\r\n\ttry\r\n\t{\r\n\t\treturn _..." 01-02 16:18:11.949 I/NUnit (23743): But was: "{\n\tJniRuntime __jvm;\n\tchar __value;\n\n\ttry\n\t{\n\t\treturn __value..." 01-02 16:18:11.949 I/NUnit (23743): -------------^ 01-02 16:18:11.949 I/NUnit (23743): 01-02 16:18:11.949 I/NUnit (23743): at Java.InteropTests.JniValueMarshalerContractTests`1[T].CheckExpression (Java.Interop.Expressions.JniValueMarshalerContext context, System.String expected, System.Linq.Expressions.Expression ret) [0x00083] in <59a94475f2544934836dac1b5c1cf1e1>:0
1 parent d61b329 commit 476597b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/Java.Interop-Tests/Java.Interop/JniValueMarshalerContractTests.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,13 @@ void CheckExpression (JniValueMarshalerContext context, string expected, Express
260260
: (Expression) Expression.Empty ();
261261
var expr = Expression.TryFinally (body, cleanup);
262262
var block = Expression.Block (context.LocalVariables, expr);
263+
// Convert line endings to Unix style to support building and running on different OS types.
264+
string blockCSharp = block.ToCSharpCode ();
265+
blockCSharp = blockCSharp.Replace ("\r\n", "\n");
266+
expected = expected.Replace ("\r\n", "\n");
263267
Console.WriteLine ("# jonp: expected: {0}", GetType ().Name);
264-
Console.WriteLine (block.ToCSharpCode ());
265-
Assert.AreEqual (expected, block.ToCSharpCode ());
268+
Console.WriteLine (blockCSharp);
269+
Assert.AreEqual (expected, blockCSharp);
266270
}
267271

268272
protected static string GetTypeName (Type type)

0 commit comments

Comments
 (0)