[Test] Use rethrow for checked exception in java-written tests
In 9b5a9ccb `throws Exception` was removed from java test sources and
all checked exceptions were wrapped with `RuntimeException`
But it was forgotten that there is a `rethrow` utility, which doesn't
wrap exception but makes the javac happy at the same time
This commit is contained in:
committed by
Space Team
parent
09c27d78b8
commit
f288163cbc
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.resolve.BindingContext;
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||
import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.KotlinTestWithEnvironmentManagement;
|
||||
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -53,7 +54,7 @@ public abstract class AbstractPseudocodeTest extends KotlinTestWithEnvironmentMa
|
||||
try {
|
||||
doTestWithEnvironment(fileName, createEnvironmentWithMockJdk(ConfigurationKind.NO_KOTLIN_REFLECT));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +62,7 @@ public abstract class AbstractPseudocodeTest extends KotlinTestWithEnvironmentMa
|
||||
try {
|
||||
doTestWithEnvironment(fileName, createEnvironmentWithMockJdk(ConfigurationKind.JDK_ONLY));
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -526,7 +526,7 @@ public abstract class CodegenTestCase extends KotlinBaseTest<KotlinBaseTest.Test
|
||||
try {
|
||||
doMultiFileTest(file, testFiles);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -20,6 +20,7 @@ import com.intellij.openapi.util.io.FileUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.codegen.CodegenTestCase;
|
||||
import org.jetbrains.kotlin.test.ConfigurationKind;
|
||||
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -41,7 +42,7 @@ public abstract class AbstractDefaultArgumentsReflectionTest extends CodegenTest
|
||||
doTestImpl(path);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.test.KotlinTestUtils;
|
||||
import org.jetbrains.kotlin.test.TestCaseWithTmpdir;
|
||||
import org.jetbrains.kotlin.test.WithMutedInDatabaseRunTest;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
||||
import org.jetbrains.kotlin.utils.KotlinPaths;
|
||||
import org.jetbrains.kotlin.utils.PathUtil;
|
||||
|
||||
@@ -63,7 +64,7 @@ public abstract class KotlinIntegrationTestBase extends TestCaseWithTmpdir {
|
||||
try {
|
||||
exitCode = runProcess(commandLine, executionLog);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
|
||||
if (logName == null) {
|
||||
|
||||
+9
-8
@@ -34,6 +34,7 @@ import org.jetbrains.kotlin.test.util.DescriptorValidator;
|
||||
import org.jetbrains.kotlin.test.util.JUnit4Assertions;
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
||||
import org.jetbrains.kotlin.test.util.RecursiveDescriptorComparator.Configuration;
|
||||
import org.jetbrains.kotlin.utils.ExceptionUtilsKt;
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.File;
|
||||
@@ -66,7 +67,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
try {
|
||||
doTestCompiledJava(javaFileName, COMPARATOR_CONFIGURATION);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,7 +131,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
try {
|
||||
doTestCompiledKotlin(ktFileName, ConfigurationKind.ALL, false);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -140,7 +141,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
try {
|
||||
doTestCompiledKotlinImpl(ktFileName, configurationKind, useTypeTableInSerializer);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -223,7 +224,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
doTestJavaAgainstKotlinImpl(expectedFileName);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,7 +257,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
try {
|
||||
doTestKotlinAgainstCompiledJavaWithKotlinImpl(expectedFileName);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,7 +321,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,7 +334,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
try {
|
||||
fileContent = FileUtil.loadFile(new File(javaFileName));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
|
||||
List<File> srcFiles = TestFiles.createTestFiles(
|
||||
@@ -387,7 +388,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
usePsiClassFilesReading(), useJavacWrapper(), withForeignAnnotations(), explicitLanguageVersionSettings,
|
||||
getExtraClasspath(), this::configureEnvironment);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -554,7 +554,7 @@ public class KotlinTestUtils {
|
||||
try {
|
||||
FileUtil.writeToFile(testDataFile, newText);
|
||||
} catch (IOException ioException) {
|
||||
throw new RuntimeException(ioException);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -585,7 +585,7 @@ public class KotlinTestUtils {
|
||||
try {
|
||||
FileUtil.writeToFile(testDataFile, newText);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw ExceptionUtilsKt.rethrow(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user