diff --git a/ReadMe.md b/ReadMe.md index 08d1c6d58a0..6bc7e7d5305 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -127,6 +127,11 @@ Also the [JavaScript translation](https://github.com/JetBrains/kotlin/blob/maste Some of the code in the standard library is created by generating code from templates. See the [README](libraries/stdlib/ReadMe.md) in the stdlib section for how run the code generator. The existing templates can be used as examples for creating new ones. +### Running specific generated tests + +If you need to debug a specific generated test, ensure that you have the `Working directory` in your IntelliJ run configuration set +to the root directory of this project. If you don't, every test you try to run will fail with a `No such file or directory` exception. + ## Submitting patches The best way to submit a patch is to [fork the project on github](https://help.github.com/articles/fork-a-repo/) then send us a diff --git a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java index 00164f1d785..324f4a42ad5 100644 --- a/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java +++ b/compiler/tests-common/org/jetbrains/kotlin/test/KotlinTestUtils.java @@ -90,6 +90,7 @@ import org.junit.Assert; import javax.tools.*; import java.io.File; +import java.io.FileNotFoundException; import java.io.IOException; import java.io.StringWriter; import java.lang.reflect.Method; @@ -438,7 +439,21 @@ public class KotlinTestUtils { } public static String doLoadFile(@NotNull File file) throws IOException { - return FileUtil.loadFile(file, CharsetToolkit.UTF8, true); + try { + return FileUtil.loadFile(file, CharsetToolkit.UTF8, true); + } + catch (FileNotFoundException fileNotFoundException) { + /* + * Unfortunately, the FileNotFoundException will only show the relative path in it's exception message. + * This clarifies the exception by showing the full path. + */ + String messageWithFullPath = file.getAbsolutePath() + " (No such file or directory)"; + throw new IOException( + "Ensure you have your 'Working Directory' configured correctly as the root " + + "Kotlin project directory in your test configuration\n\t" + + messageWithFullPath, + fileNotFoundException); + } } public static String getFilePath(File file) {