Failed test toutput improved
This commit is contained in:
@@ -26,6 +26,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
import org.jetbrains.jet.cli.common.CLIConfigurationKeys;
|
||||||
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
import org.jetbrains.jet.cli.common.messages.MessageCollector;
|
||||||
|
import org.jetbrains.jet.cli.common.messages.MessageRenderer;
|
||||||
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys;
|
||||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||||
import org.jetbrains.jet.codegen.GeneratedClassLoader;
|
import org.jetbrains.jet.codegen.GeneratedClassLoader;
|
||||||
@@ -104,7 +105,8 @@ public class CompileEnvironmentUtil {
|
|||||||
|
|
||||||
GenerationState generationState = KotlinToJVMBytecodeCompiler.analyzeAndGenerate(scriptEnvironment, false);
|
GenerationState generationState = KotlinToJVMBytecodeCompiler.analyzeAndGenerate(scriptEnvironment, false);
|
||||||
if (generationState == null) {
|
if (generationState == null) {
|
||||||
throw new CompileEnvironmentException("Module script " + moduleScriptFile + " analyze failed");
|
throw new CompileEnvironmentException("Module script " + moduleScriptFile + " analyze failed:\n" +
|
||||||
|
loadModuleScriptText(moduleScriptFile));
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Module> modules = runDefineModules(moduleScriptFile, generationState.getFactory());
|
List<Module> modules = runDefineModules(moduleScriptFile, generationState.getFactory());
|
||||||
@@ -246,4 +248,16 @@ public class CompileEnvironmentUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used for debug output only
|
||||||
|
private static String loadModuleScriptText(String moduleScriptFile) {
|
||||||
|
String moduleScriptText;
|
||||||
|
try {
|
||||||
|
moduleScriptText = FileUtil.loadFile(new File(moduleScriptFile));
|
||||||
|
}
|
||||||
|
catch (IOException e) {
|
||||||
|
moduleScriptText = "Can't load module script text:\n" + MessageRenderer.PLAIN.renderException(e);
|
||||||
|
}
|
||||||
|
return moduleScriptText;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,4 +98,9 @@ public final class Message {
|
|||||||
}
|
}
|
||||||
Assert.assertEquals(other.message, this.message);
|
Assert.assertEquals(other.message, this.message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return category + ": " + message + " at " + line + ":" + column + " in " + url;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,16 @@ public final class MessageChecker {
|
|||||||
|
|
||||||
public void finish() {
|
public void finish() {
|
||||||
if (iterator.hasNext()) {
|
if (iterator.hasNext()) {
|
||||||
fail("More message than expected:\n" + iterator.next().message);
|
StringBuilder builder = messagesToString(iterator);
|
||||||
|
fail("More messages than expected:\n" + builder.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private StringBuilder messagesToString(Iterator<Message> iterator) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
builder.append(iterator.next()).append("\n\n");
|
||||||
|
}
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user