From 3d8b86040d762d66ac34faf91c97ff346f7e5852 Mon Sep 17 00:00:00 2001 From: Evgeny Gerashchenko Date: Thu, 29 Nov 2012 17:48:39 +0400 Subject: [PATCH] Better output in failed test. --- .../jetbrains/jet/lang/diagnostics/DiagnosticHolder.java | 2 +- .../jetbrains/jet/jvm/compiler/LoadDescriptorUtil.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder.java index 23132b58a23..18e5f6bd736 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder.java @@ -39,7 +39,7 @@ public interface DiagnosticHolder { PsiFile psiFile = diagnostic.getPsiFile(); List 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))); } } }; diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadDescriptorUtil.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadDescriptorUtil.java index 518e3abc889..b032728698d 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadDescriptorUtil.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadDescriptorUtil.java @@ -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.emptyList()); return new JetFileAndExhaust(jetFile, exhaust);