Record crashes on the device so "two weeks without one" can be checked
All checks were successful
Build TV app / build (push) Successful in 46s
All checks were successful
Build TV app / build (push) Successful in 46s
The milestone asks for two weeks in the living room without a crash. Nobody reads logcat on a TV, and by the time someone says "it was gone yesterday" the log has rotated — the criterion had no evidence behind it. CrashLog keeps the last ten crashes in the app's own files: timestamp, version, and the top of the stack. Nothing is sent anywhere. The settings show either "Kein Absturz aufgezeichnet" or the newest one, and clicking the row clears the record — so the two weeks start when you say they do. Verified by crashing the app on purpose: the entry appears as "26.08.2026 18:10 · 0.11.5" with the exception below it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
47
tests/unit/CrashLogTest.kt
Normal file
47
tests/unit/CrashLogTest.kt
Normal file
@@ -0,0 +1,47 @@
|
||||
package dev.castarr.tv
|
||||
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
|
||||
class CrashLogTest {
|
||||
|
||||
@Test
|
||||
fun `an entry names the time, the version and the top of the stack`() {
|
||||
val error = IllegalStateException("Senderliste leer")
|
||||
// 26.08.2026, 19:12 (MESZ)
|
||||
val entry = CrashLog.render(1787764320000L, "0.12.0", error)
|
||||
val lines = entry.lines()
|
||||
assertTrue(lines.first().contains("0.12.0"))
|
||||
assertTrue(lines.first().contains("26.08.2026"))
|
||||
assertTrue(entry.contains("IllegalStateException"))
|
||||
assertTrue(entry.contains("Senderliste leer"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `a long stack is cut down to something readable`() {
|
||||
val error = RuntimeException("tief")
|
||||
val entry = CrashLog.render(0L, "0.12.0", error)
|
||||
// Kopfzeile plus höchstens TRACE_LINES Zeilen Stack.
|
||||
assertTrue(entry.lines().size <= CrashLog.TRACE_LINES + 1)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `only the newest entries are kept`() {
|
||||
val entries = (1..15).map { "Absturz $it" }
|
||||
val kept = CrashLog.trim(entries)
|
||||
assertEquals(CrashLog.KEEP, kept.size)
|
||||
assertEquals("Absturz 15", kept.last())
|
||||
assertEquals("Absturz 6", kept.first())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `blank entries are dropped instead of counting`() {
|
||||
assertEquals(listOf("echt"), CrashLog.trim(listOf("", " ", "echt")))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `nothing recorded stays nothing`() {
|
||||
assertEquals(emptyList<String>(), CrashLog.trim(emptyList()))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user