Skip to content

Commit

Permalink
Revert "test: consolidate Timber config"
Browse files Browse the repository at this point in the history
This reverts commit b335992.

The old code used println() as Timber may not work under the Jvm
  • Loading branch information
david-allison committed Dec 16, 2023
1 parent d5472fa commit 7e6b7df
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions AnkiDroid/src/test/java/com/ichi2/testutils/JvmTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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() {
Expand All @@ -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)
}
Expand Down

0 comments on commit 7e6b7df

Please sign in to comment.