From 7e6b7df60d3b4a0aed90c938c932493464303704 Mon Sep 17 00:00:00 2001 From: David Allison <62114487+david-allison@users.noreply.github.com> Date: Fri, 15 Dec 2023 08:45:48 +0000 Subject: [PATCH] Revert "test: consolidate Timber config" This reverts commit b3359928c48570b3a9b1f3b5944fa20555a40797. The old code used println() as Timber may not work under the Jvm --- .../test/java/com/ichi2/testutils/JvmTest.kt | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/AnkiDroid/src/test/java/com/ichi2/testutils/JvmTest.kt b/AnkiDroid/src/test/java/com/ichi2/testutils/JvmTest.kt index 8584bb4efb79..72c2ef900ea6 100644 --- a/AnkiDroid/src/test/java/com/ichi2/testutils/JvmTest.kt +++ b/AnkiDroid/src/test/java/com/ichi2/testutils/JvmTest.kt @@ -16,8 +16,8 @@ package com.ichi2.testutils +import android.annotation.SuppressLint import androidx.annotation.CallSuper -import com.ichi2.anki.AnkiDroidApp import com.ichi2.anki.CollectionManager import com.ichi2.libanki.ChangeManager import com.ichi2.libanki.Collection @@ -33,6 +33,7 @@ import org.junit.After import org.junit.Assume import org.junit.Before import timber.log.Timber +import timber.log.Timber.Forest.plant open class JvmTest : TestClass { private fun maybeSetupBackend() { @@ -58,7 +59,20 @@ open class JvmTest : TestClass { maybeSetupBackend() - Timber.plant(AnkiDroidApp.RobolectricDebugTree()) + plant(object : Timber.DebugTree() { + @SuppressLint("PrintStackTraceUsage") + override fun log(priority: Int, tag: String?, message: String, t: Throwable?) { + // This is noisy in test environments + if (tag == "Backend\$checkMainThreadOp") { + return + } + // use println(): Timber may not work under the Jvm + System.out.println(tag + ": " + message) + if (t != null) { + t.printStackTrace() + } + } + }) Storage.setUseInMemory(true) }