summaryrefslogtreecommitdiff
path: root/ravenwood
diff options
context:
space:
mode:
author Jeff Sharkey <jsharkey@google.com> 2024-01-29 13:45:08 -0700
committer Jeff Sharkey <jsharkey@google.com> 2024-01-30 09:04:25 -0700
commit3d14bf44b11396366465536067c65c046c47d33e (patch)
tree2e9315660478598d0ec34aa33ee496999a18752d /ravenwood
parent9614500d620911e1cd670c7d8f8f7b6f85af7fc9 (diff)
Improve Ravenwood logging/messages.
Emit "TestRunner" log messages around each test method, so that our local debugging logs match what developers experience with tests run on a physical device. Refine `onThrowMethodCalled()` message to be more descriptive about Ravenwood and link to docs. Bug: 322817109, 322526754 Test: atest FrameworksCoreTestsRavenwood Change-Id: Id9f6a936145dd2024295c2eb14666fc43a5c7e34
Diffstat (limited to 'ravenwood')
-rw-r--r--ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java10
-rw-r--r--ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java8
-rw-r--r--ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java6
3 files changed, 24 insertions, 0 deletions
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
index a797b1d61b2a..5588f4f811d5 100644
--- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
@@ -20,9 +20,12 @@ import android.app.Instrumentation;
import android.os.Bundle;
import android.os.HandlerThread;
import android.os.Looper;
+import android.util.Log;
import androidx.test.platform.app.InstrumentationRegistry;
+import org.junit.runner.Description;
+
import java.io.PrintStream;
import java.util.Map;
import java.util.concurrent.Executors;
@@ -92,6 +95,13 @@ public class RavenwoodRuleImpl {
android.os.Process.reset$ravenwood();
}
+ public static void logTestRunner(String label, Description description) {
+ // This message string carefully matches the exact format emitted by on-device tests, to
+ // aid developers in debugging raw text logs
+ Log.e("TestRunner", label + ": " + description.getMethodName()
+ + "(" + description.getTestClass().getName() + ")");
+ }
+
private static void dumpStacks() {
final PrintStream out = System.err;
out.println("-----BEGIN ALL THREAD STACKS-----");
diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
index 1e7cbf6d802d..0285b386ed13 100644
--- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
+++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
@@ -280,9 +280,14 @@ public class RavenwoodRule implements TestRule {
public void evaluate() throws Throwable {
Assume.assumeTrue(shouldEnableOnRavenwood(description));
+ RavenwoodRuleImpl.logTestRunner("started", description);
RavenwoodRuleImpl.init(RavenwoodRule.this);
try {
base.evaluate();
+ RavenwoodRuleImpl.logTestRunner("finished", description);
+ } catch (Throwable t) {
+ RavenwoodRuleImpl.logTestRunner("failed", description);
+ throw t;
} finally {
RavenwoodRuleImpl.reset(RavenwoodRule.this);
}
@@ -300,6 +305,8 @@ public class RavenwoodRule implements TestRule {
@Override
public void evaluate() throws Throwable {
Assume.assumeFalse(shouldStillIgnoreInProbeIgnoreMode(description));
+
+ RavenwoodRuleImpl.logTestRunner("started", description);
RavenwoodRuleImpl.init(RavenwoodRule.this);
try {
base.evaluate();
@@ -309,6 +316,7 @@ public class RavenwoodRule implements TestRule {
Assume.assumeTrue(shouldEnableOnRavenwood(description));
throw t;
} finally {
+ RavenwoodRuleImpl.logTestRunner("finished", description);
RavenwoodRuleImpl.reset(RavenwoodRule.this);
}
diff --git a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
index d0c2e18be8df..7d172f2a83c0 100644
--- a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
+++ b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
@@ -16,6 +16,8 @@
package android.platform.test.ravenwood;
+import org.junit.runner.Description;
+
public class RavenwoodRuleImpl {
public static boolean isOnRavenwood() {
return false;
@@ -28,4 +30,8 @@ public class RavenwoodRuleImpl {
public static void reset(RavenwoodRule rule) {
// No-op when running on a real device
}
+
+ public static void logTestRunner(String label, Description description) {
+ // No-op when running on a real device
+ }
}