Testrunner: Fix output parsing issue

Android build system determines failure info in the build log
by looking for a line starting with "FAILED: ".

The new format of the testrunner makes sure that the build system
is able to parse the error from the log.

Test: ./art/test.py -r -t 00
Change-Id: Iab29f254f600d4c3ee74cae2675da3a624e724ef
diff --git a/test/testrunner/run_build_test_target.py b/test/testrunner/run_build_test_target.py
index e105da3..282ac48 100755
--- a/test/testrunner/run_build_test_target.py
+++ b/test/testrunner/run_build_test_target.py
@@ -53,7 +53,8 @@
   build_command += ' ' + target.get('target')
   # Add 'dist' to avoid Jack issues b/36169180.
   build_command += ' dist'
-  print build_command.split()
+  sys.stdout.write(str(build_command))
+  sys.stdout.flush()
   if subprocess.call(build_command.split()):
     sys.exit(1)
 
@@ -66,7 +67,8 @@
   run_test_command += ['--host']
   run_test_command += ['--verbose']
 
-  print run_test_command
+  sys.stdout.write(str(run_test_command))
+  sys.stdout.flush()
   if subprocess.call(run_test_command):
     sys.exit(1)
 
diff --git a/test/testrunner/testrunner.py b/test/testrunner/testrunner.py
index 3203f7a..99e87c0 100755
--- a/test/testrunner/testrunner.py
+++ b/test/testrunner/testrunner.py
@@ -480,7 +480,7 @@
       if test_passed:
         print_test_info(test_name, 'PASS')
       else:
-        failed_tests.append(test_name)
+        failed_tests.append((test_name, script_output))
         if not env.ART_TEST_KEEP_GOING:
           stop_testrunner = True
         print_test_info(test_name, 'FAIL', ('%s\n%s') % (
@@ -491,13 +491,13 @@
     else:
       print_test_info(test_name, '')
   except subprocess.TimeoutExpired as e:
-    failed_tests.append(test_name)
-    print_test_info(test_name, 'TIMEOUT', 'timed out in %d\n%s' % (
+    failed_tests.append((test_name, 'Timed out in %d seconds'))
+    print_test_info(test_name, 'TIMEOUT', 'Timed out in %d seconds\n%s' % (
         timeout, command))
   except Exception as e:
-    failed_tests.append(test_name)
-    print_test_info(test_name, 'FAIL')
-    print_text(('%s\n%s\n\n') % (command, str(e)))
+    failed_tests.append((test_name, str(e)))
+    print_test_info(test_name, 'FAIL',
+    ('%s\n%s\n\n') % (command, str(e)))
   finally:
     semaphore.release()
 
@@ -711,16 +711,16 @@
 
   # Prints the list of skipped tests, if any.
   if skipped_tests:
-    print_text(COLOR_SKIP + 'SKIPPED TESTS' + COLOR_NORMAL + '\n')
+    print_text(COLOR_SKIP + 'SKIPPED TESTS: ' + COLOR_NORMAL + '\n')
     for test in skipped_tests:
       print_text(test + '\n')
     print_text('\n')
 
   # Prints the list of failed tests, if any.
   if failed_tests:
-    print_text(COLOR_ERROR + 'FAILED TESTS' + COLOR_NORMAL + '\n')
-    for test in failed_tests:
-      print_text(test + '\n')
+    print_text(COLOR_ERROR + 'FAILED: ' + COLOR_NORMAL + '\n')
+    for test_info in failed_tests:
+      print_text(('%s\n%s\n' % (test_info[0], test_info[1])))
 
 
 def parse_test_name(test_name):