From e024628d466b6a66a7ef92fecaaacfc373b54da4 Mon Sep 17 00:00:00 2001 From: Skylot Date: Thu, 17 Sep 2020 19:53:18 +0300 Subject: [PATCH] chore: fix directory search for smali tests --- .../src/test/java/jadx/tests/api/SmaliTest.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/jadx-core/src/test/java/jadx/tests/api/SmaliTest.java b/jadx-core/src/test/java/jadx/tests/api/SmaliTest.java index ea2d3781..a3693e91 100644 --- a/jadx-core/src/test/java/jadx/tests/api/SmaliTest.java +++ b/jadx-core/src/test/java/jadx/tests/api/SmaliTest.java @@ -68,7 +68,7 @@ public abstract class SmaliTest extends IntegrationTest { } else { smaliFilesDir = pkg + File.separatorChar + testDir + File.separatorChar; } - File smaliDir = new File(SMALI_TESTS_DIR, smaliFilesDir); + File smaliDir = getSmaliDir(smaliFilesDir); String[] smaliFileNames = smaliDir.list((dir, name) -> name.endsWith(".smali")); assertThat("Smali files not found in " + smaliDir, smaliFileNames, notNullValue()); return Stream.of(smaliFileNames) @@ -87,4 +87,16 @@ public abstract class SmaliTest extends IntegrationTest { } throw new AssertionError("Smali file not found: " + smaliFile.getPath()); } + + private static File getSmaliDir(String baseName) { + File smaliDir = new File(SMALI_TESTS_DIR, baseName); + if (smaliDir.exists()) { + return smaliDir; + } + File pathFromRoot = new File(SMALI_TESTS_PROJECT, smaliDir.getPath()); + if (pathFromRoot.exists()) { + return pathFromRoot; + } + throw new AssertionError("Smali dir not found: " + smaliDir.getPath()); + } } -- GitLab