chore: fix directory search for smali tests

This commit is contained in:
Skylot
2020-09-17 19:53:18 +03:00
parent 6428f29373
commit e024628d46
@@ -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());
}
}