forked from ReVanced/revanced-patcher
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add warnings for Fuzzy resolver
- Loading branch information
Showing
5 changed files
with
121 additions
and
22 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
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,37 @@ | ||
package app.revanced.patcher | ||
|
||
import app.revanced.patcher.signature.PatternScanMethod | ||
import app.revanced.patcher.usage.ExamplePatch | ||
import org.junit.jupiter.api.Test | ||
import java.io.File | ||
import kotlin.test.assertTrue | ||
|
||
internal class PatcherTest { | ||
@Test | ||
fun testPatcher() { | ||
val patcher = Patcher(File(PatcherTest::class.java.getResource("/test1.dex")!!.toURI())) | ||
patcher.addPatches(listOf(ExamplePatch())) | ||
for (signature in patcher.resolveSignatures()) { | ||
if (!signature.resolved) { | ||
throw Exception("Signature ${signature.metadata.name} was not resolved!") | ||
} | ||
val patternScanMethod = signature.metadata.patternScanMethod | ||
if (patternScanMethod is PatternScanMethod.Fuzzy) { | ||
val warnings = patternScanMethod.warnings | ||
println("Signature ${signature.metadata.name} had ${warnings.size} warnings!") | ||
for (warning in warnings) { | ||
println(warning.toString()) | ||
} | ||
} | ||
} | ||
for ((metadata, result) in patcher.applyPatches()) { | ||
if (result.isFailure) { | ||
throw Exception("Patch ${metadata.shortName} failed", result.exceptionOrNull()!!) | ||
} else { | ||
println("Patch ${metadata.shortName} applied successfully!") | ||
} | ||
} | ||
val out = patcher.save() | ||
assertTrue(out.isNotEmpty(), "Expected the output of Patcher#save() to not be empty.") | ||
} | ||
} |
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