Better diagnostic for error configuration in debugger tests

This commit is contained in:
Nikolay Krasko
2017-07-07 19:04:45 +03:00
parent 68e0727894
commit a0f11f773b
@@ -109,7 +109,7 @@ public abstract class KotlinDebuggerTestCase extends DescriptorTestCase {
if (LOCAL_CACHE_DIR.exists()) { if (LOCAL_CACHE_DIR.exists()) {
if (isLocalCacheOutdated()) { if (isLocalCacheOutdated()) {
System.out.println("-- Local caches outdated --"); System.out.println("-- Local caches outdated --");
Assert.assertTrue("Failed to delete local cache!", FilesKt.deleteRecursively(LOCAL_CACHE_DIR)); deleteLocalCacheDirectory(true);
localCacheRebuild = true; localCacheRebuild = true;
} }
} }
@@ -129,6 +129,14 @@ public abstract class KotlinDebuggerTestCase extends DescriptorTestCase {
super.setUp(); super.setUp();
} }
private static void deleteLocalCacheDirectory(boolean assertDeleteSuccess) {
System.out.println("-- Remove local cache directory --");
boolean deleteResult = FilesKt.deleteRecursively(LOCAL_CACHE_DIR);
if (assertDeleteSuccess) {
Assert.assertTrue("Failed to delete local cache!", deleteResult);
}
}
private static long cachedDataTimeStamp() { private static long cachedDataTimeStamp() {
File testDataLastModifiedFile = JetTestUtilsKt.findLastModifiedFile( File testDataLastModifiedFile = JetTestUtilsKt.findLastModifiedFile(
TINY_APP_SRC, TINY_APP_SRC,
@@ -226,35 +234,30 @@ public abstract class KotlinDebuggerTestCase extends DescriptorTestCase {
File outDir = new File(outputDirPath); File outDir = new File(outputDirPath);
if (!IS_TINY_APP_COMPILED) { if (!IS_TINY_APP_COMPILED) {
String modulePath = getTestAppPath();
File jarDir;
try { try {
String modulePath = getTestAppPath();
//noinspection ConstantConditions //noinspection ConstantConditions
jarDir = LOCAL_CACHE_REUSE ? LOCAL_CACHE_DIR : KotlinTestUtils.tmpDir("debuggerCustomLibrary"); File jarDir = LOCAL_CACHE_REUSE ? LOCAL_CACHE_DIR : KotlinTestUtils.tmpDir("debuggerCustomLibrary");
}
catch (IOException e) {
throw ExceptionUtilsKt.rethrow(e);
}
CUSTOM_LIBRARY_JAR = MockLibraryUtil.compileLibraryToJar(CUSTOM_LIBRARY_SOURCES.getPath(), jarDir, "debuggerCustomLibrary"); CUSTOM_LIBRARY_JAR = MockLibraryUtil.compileLibraryToJar(CUSTOM_LIBRARY_SOURCES.getPath(), jarDir, "debuggerCustomLibrary");
String sourcesDir = modulePath + File.separator + "src"; String sourcesDir = modulePath + File.separator + "src";
MockLibraryUtil.compileKotlin(sourcesDir, outDir, CUSTOM_LIBRARY_JAR.getPath()); MockLibraryUtil.compileKotlin(sourcesDir, outDir, CUSTOM_LIBRARY_JAR.getPath());
List<String> options = List<String> options =
Arrays.asList("-d", outputDirPath, "-classpath", ForTestCompileRuntime.runtimeJarForTests().getPath(), "-g"); Arrays.asList("-d", outputDirPath, "-classpath", ForTestCompileRuntime.runtimeJarForTests().getPath(), "-g");
try {
KotlinTestUtils.compileJavaFiles(findJavaFiles(new File(sourcesDir)), options); KotlinTestUtils.compileJavaFiles(findJavaFiles(new File(sourcesDir)), options);
DexLikeBytecodePatchKt.patchDexTests(outDir);
IS_TINY_APP_COMPILED = true;
} }
catch (IOException e) { catch (Throwable e) {
deleteLocalCacheDirectory(false);
throw new RuntimeException(e); throw new RuntimeException(e);
} }
DexLikeBytecodePatchKt.patchDexTests(outDir);
IS_TINY_APP_COMPILED = true;
} }
CompilerUtil.refreshOutputRoots(Lists.newArrayList(outputDirPath)); CompilerUtil.refreshOutputRoots(Lists.newArrayList(outputDirPath));
@@ -265,6 +268,11 @@ public abstract class KotlinDebuggerTestCase extends DescriptorTestCase {
configureLibrary(model, KOTLIN_LIBRARY_NAME, ForTestCompileRuntime.runtimeJarForTests(), new File("libraries/stdlib/src")); configureLibrary(model, KOTLIN_LIBRARY_NAME, ForTestCompileRuntime.runtimeJarForTests(), new File("libraries/stdlib/src"));
model.commit(); model.commit();
}); });
if (!outDir.exists()) {
deleteLocalCacheDirectory(false);
Assert.fail("Output directory for module wasn't created: " + outDir.getAbsolutePath());
}
} }
private static List<File> findJavaFiles(@NotNull File directory) { private static List<File> findJavaFiles(@NotNull File directory) {