Fix dart apptest flake on android.

There's a good discussion of this issue in dart-lang/test#333. In short,
tearDownAll is guaranteed to be called after all tests run. However,
apptest.dart explicitly calls close() in tearDownAll, which closes the shell.

This close races against the test framework getting around to outputting
"All tests pass!". So this patch works around it by instead looking for the
message about tearDownAll running with no previously failed tests.

BUG=Fixes #394
R=johnmccutchan@google.com, zra@google.com

Review URL: https://codereview.chromium.org/1569213004 .

Cr-Mirrored-From: https://github.com/domokit/mojo
Cr-Mirrored-Commit: 66269650afe77c016cd33903e5d02ea05d879660
diff --git a/devtoolslib/apptest_dart.py b/devtoolslib/apptest_dart.py
index fe6131f..3c7a685 100644
--- a/devtoolslib/apptest_dart.py
+++ b/devtoolslib/apptest_dart.py
@@ -12,7 +12,15 @@
 
 from devtoolslib.apptest import run_apptest
 
-SUCCESS_PATTERN = re.compile('^.+ .+: All tests passed!', re.MULTILINE)
+# The apptest framework guarantees that tearDownAll() is the last thing to be
+# called before the shell is terminated. Note that the shell may be terminated
+# before the "All tests passed!" string.
+#
+# So we pass on messages like:
+#   00:01 +3: (tearDownAll)
+# And fail on messages like:
+#   00:01 +2 -1: (tearDownAll)
+SUCCESS_PATTERN = re.compile(r'^\S+ \S+: \(tearDownAll\)', re.MULTILINE)
 
 
 def _dart_apptest_output_test(output):