Return exit code 1 in android test runner if a test failed (#36319)
authorSantiago Fernandez Madero <safern@microsoft.com>
Wed, 13 May 2020 16:00:23 +0000 (09:00 -0700)
committerGitHub <noreply@github.com>
Wed, 13 May 2020 16:00:23 +0000 (09:00 -0700)
* Return exit code 1 in android test runner if a test failed

* Exit instrumentation with runner exit code

src/mono/msbuild/AndroidTestRunner/AndroidTestRunner.cs

index c223eba130cc755aff14da4c2134bd756712e3f6..8500bebd069d9eba8ec4b9a6955e259920ba6b28 100644 (file)
@@ -24,11 +24,18 @@ public class SimpleAndroidTestRunner : AndroidApplicationEntryPoint, IDevice
             Console.WriteLine($"Test libs were not found (*.Tests.dll was not found in {Environment.CurrentDirectory})");
             return -1;
         }
+        int exitCode = 0;
         s_MainTestName = Path.GetFileNameWithoutExtension(s_testLibs[0]);
         var simpleTestRunner = new SimpleAndroidTestRunner(true);
+        simpleTestRunner.TestsCompleted += (e, result) => 
+        {
+            if (result.FailedTests > 0)
+                exitCode = 1;
+        };
+
         await simpleTestRunner.RunAsync();
         Console.WriteLine("----- Done -----");
-        return 0;
+        return exitCode;
     }
 
     public SimpleAndroidTestRunner(bool verbose)