Chromium Code Reviews| Index: testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java |
| diff --git a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java |
| index a5cf4854df3f173a0233a35766bcf3ed4946fb1e..98571d5244c1f8e56ddf6e350267bd8e21eb11a6 100644 |
| --- a/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java |
| +++ b/testing/android/java/src/org/chromium/native_test/ChromeNativeTestInstrumentationTestRunner.java |
| @@ -27,9 +27,13 @@ import java.util.regex.Pattern; |
| * An Instrumentation that runs tests based on ChromeNativeTestActivity. |
| */ |
| public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation { |
| + // TODO(jbudorick): Remove this extra when b/18981674 is fixed. |
| + public static final String EXTRA_ONLY_OUTPUT_FAILURES = |
| + "org.chromium.native_test.ChromeNativeTestInstrumentationTestRunner." |
| + + "OnlyOutputFailures"; |
| private static final String TAG = "ChromeNativeTestInstrumentationTestRunner"; |
| - private static final Pattern RE_TEST_OUTPUT = Pattern.compile("\\[ *([^ ]*) *\\] ?([^ ]*) .*"); |
| + private static final Pattern RE_TEST_OUTPUT = Pattern.compile("\\[ *([^ ]*) *\\] ?([^ ]+) .*"); |
| private static interface ResultsBundleGenerator { |
| public Bundle generate(Map<String, TestResult> rawResults); |
| @@ -39,6 +43,7 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation { |
| private String mCommandLineFlags; |
| private Bundle mLogBundle; |
| private ResultsBundleGenerator mBundleGenerator; |
| + private boolean mOnlyOutputFailures; |
| @Override |
| public void onCreate(Bundle arguments) { |
| @@ -46,6 +51,7 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation { |
| mCommandLineFlags = arguments.getString(ChromeNativeTestActivity.EXTRA_COMMAND_LINE_FLAGS); |
| mLogBundle = new Bundle(); |
| mBundleGenerator = new RobotiumBundleGenerator(); |
| + mOnlyOutputFailures = arguments.containsKey(EXTRA_ONLY_OUTPUT_FAILURES); |
| start(); |
| } |
| @@ -117,17 +123,27 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation { |
| for (String l = r.readLine(); l != null && !l.equals("<<ScopedMainEntryLogger"); |
| l = r.readLine()) { |
| Matcher m = RE_TEST_OUTPUT.matcher(l); |
| + boolean isFailure = false; |
| if (m.matches()) { |
| if (m.group(1).equals("RUN")) { |
| results.put(m.group(2), TestResult.UNKNOWN); |
| } else if (m.group(1).equals("FAILED")) { |
| results.put(m.group(2), TestResult.FAILED); |
| + isFailure = true; |
| + mLogBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, l + "\n"); |
| + sendStatus(0, mLogBundle); |
| } else if (m.group(1).equals("OK")) { |
| results.put(m.group(2), TestResult.PASSED); |
| } |
| } |
| - mLogBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, l + "\n"); |
| - sendStatus(0, mLogBundle); |
| + |
| + // TODO(jbudorick): mOnlyOutputFailures is a workaround for b/18981674. Remove it |
| + // once that issue is fixed. |
| + if (!mOnlyOutputFailures || isFailure) { |
| + mLogBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, l + "\n"); |
| + sendStatus(0, mLogBundle); |
| + } |
| + Log.i(TAG, l); |
| } |
| } catch (InterruptedException e) { |
| Log.e(TAG, "Interrupted while waiting for FIFO file creation: " + e.toString()); |
| @@ -168,6 +184,7 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation { |
| ++testsPassed; |
| break; |
| case FAILED: |
| + Log.e(TAG, "FAILED: " + entry.getKey()); |
|
klundberg
2015/01/13 19:33:15
Leftover from debugging?
jbudorick
2015/01/13 19:38:42
No, this is intentional. I've seen a few weird fla
klundberg
2015/01/13 19:41:16
ok, I was just confused about Log.e. If this is so
jbudorick
2015/01/13 19:47:01
Switched to Log.d and added a TODO.
|
| ++testsFailed; |
| break; |
| default: |
| @@ -178,11 +195,12 @@ public class ChromeNativeTestInstrumentationTestRunner extends Instrumentation { |
| } |
| StringBuilder resultBuilder = new StringBuilder(); |
| - resultBuilder.append("\nOK (" + Integer.toString(testsPassed) + " tests)"); |
| if (testsFailed > 0) { |
| resultBuilder.append( |
| "\nFAILURES!!! Tests run: " + Integer.toString(rawResults.size()) |
| + ", Failures: " + Integer.toString(testsFailed) + ", Errors: 0"); |
| + } else { |
| + resultBuilder.append("\nOK (" + Integer.toString(testsPassed) + " tests)"); |
| } |
| resultsBundle.putString(Instrumentation.REPORT_KEY_STREAMRESULT, |
| resultBuilder.toString()); |