Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Detect minified classes and skip instrumentation to avoid build probl…
…ems (#362)
- Loading branch information
Showing
4 changed files
with
87 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...c/test/kotlin/io/sentry/android/gradle/instrumentation/util/MinifiedClassDetectionTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package io.sentry.android.gradle.instrumentation.util | ||
|
||
import kotlin.test.assertFalse | ||
import kotlin.test.assertTrue | ||
import org.junit.Test | ||
|
||
class MinifiedClassDetectionTest { | ||
|
||
@Test | ||
fun `detects minified class names`() { | ||
val classNames = listOf( | ||
"l0", | ||
"""a${'$'}a""", | ||
"ccc017zz", | ||
"""ccc017zz${'$'}a""", | ||
"aa", | ||
"aa${'$'}a", | ||
"ab", | ||
"aa${'$'}ab", | ||
"ab${'$'}a" | ||
) | ||
|
||
classNames.forEach { | ||
assertTrue(classNameLooksMinified(it, "com/example/$it"), it) | ||
} | ||
} | ||
|
||
@Test | ||
fun `detects minified class names with minified package name`() { | ||
val classNames = listOf( | ||
"""a${'$'}""", | ||
"aa" | ||
) | ||
|
||
classNames.forEach { | ||
assertTrue(classNameLooksMinified(it, "a/$it"), it) | ||
} | ||
} | ||
|
||
@Test | ||
fun `does not consider non minified classes as minified`() { | ||
val classNames = listOf( | ||
"ConstantPoolHelpers", | ||
"FileUtil", | ||
"""FileUtil${"$"}Inner""" | ||
) | ||
|
||
classNames.forEach { | ||
assertFalse(classNameLooksMinified(it, "com/example/$it"), it) | ||
} | ||
} | ||
} |