Better output in failed test.

This commit is contained in:
Evgeny Gerashchenko
2012-11-29 17:48:39 +04:00
parent a4a7e5818c
commit 3d8b86040d
2 changed files with 6 additions and 4 deletions
@@ -39,7 +39,7 @@ public interface DiagnosticHolder {
PsiFile psiFile = diagnostic.getPsiFile();
List<TextRange> textRanges = diagnostic.getTextRanges();
String diagnosticText = DefaultErrorMessages.RENDERER.render(diagnostic);
throw new IllegalStateException(diagnostic.getFactory().getName() + ": " + diagnosticText + " " + psiFile.getName() + " " + DiagnosticUtils.atLocation(psiFile, textRanges.get(0)));
throw new IllegalStateException(diagnostic.getFactory().getName() + ": " + diagnosticText + " " + DiagnosticUtils.atLocation(psiFile, textRanges.get(0)));
}
}
};
@@ -132,8 +132,10 @@ public final class LoadDescriptorUtil {
@NotNull
public static NamespaceDescriptor analyzeKotlinAndLoadTestNamespace(@NotNull File ktFile, @NotNull Disposable disposable, @NotNull ConfigurationKind configurationKind) throws Exception {
JetFileAndExhaust fileAndExhaust = JetFileAndExhaust.createJetFileAndAnalyze(ktFile, disposable, configurationKind);
//noinspection ConstantConditions
return fileAndExhaust.getExhaust().getBindingContext().get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, TEST_PACKAGE_FQNAME);
NamespaceDescriptor namespace =
fileAndExhaust.getExhaust().getBindingContext().get(BindingContext.FQNAME_TO_NAMESPACE_DESCRIPTOR, TEST_PACKAGE_FQNAME);
assert namespace != null: TEST_PACKAGE_FQNAME + " package not found in " + ktFile.getName();
return namespace;
}
private static class JetFileAndExhaust {
@@ -142,7 +144,7 @@ public final class LoadDescriptorUtil {
public static JetFileAndExhaust createJetFileAndAnalyze(@NotNull File kotlinFile, @NotNull Disposable disposable, @NotNull ConfigurationKind configurationKind)
throws IOException {
JetCoreEnvironment jetCoreEnvironment = createEnvironmentWithMockJdkAndIdeaAnnotations(disposable, configurationKind);
JetFile jetFile = createFile(jetCoreEnvironment.getProject(), FileUtil.loadFile(kotlinFile, true));
JetFile jetFile = createFile(jetCoreEnvironment.getProject(), kotlinFile.getName(), FileUtil.loadFile(kotlinFile, true));
AnalyzeExhaust exhaust = AnalyzerFacadeForJVM.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
jetFile, Collections.<AnalyzerScriptParameter>emptyList());
return new JetFileAndExhaust(jetFile, exhaust);