@@ -77,7 +77,10 @@ testWith :: HasCallStack => FilePath -> GHC -> [String] -> String -> Maybe Annot
7777testWith name requiredVersion extraArgs (unindent -> code) annotation solutions = it name do
7878 unless (T. null code) do
7979 ensureFile src $ T. encodeUtf8 code
80+
8081 err <- translate <$> ghc [" -fno-diagnostics-show-caret" ]
82+ errNoContext <- translate <$> ghc [" -fno-diagnostics-show-caret" , " -fno-show-error-context" ]
83+
8184 json <- pretty <$> ghc [" -fdiagnostics-as-json" , " --interactive" , " -ignore-dot-ghci" ]
8285 ensureFile (dir </> " err.out" ) (encodeUtf8 err)
8386 ensureFile (dir </> " err.yaml" ) (encodeUtf8 $ normalizeGhcVersion json)
@@ -86,7 +89,9 @@ testWith name requiredVersion extraArgs (unindent -> code) annotation solutions
8689 expectationFailure $ " Parsing JSON failed:\n\n " <> json
8790 Just annotated -> addAnnotation (separator <> err <> separator) do
8891 whenGhc requiredVersion do
89- format annotated. diagnostic `shouldBe` err
92+ format ShowErrorContext annotated. diagnostic `shouldBe` err
93+ format NoShowErrorContext annotated. diagnostic `shouldBe` errNoContext
94+
9095 annotated. annotation `shouldBe` annotation
9196 annotated. solutions `shouldBe` solutions
9297 where
@@ -467,7 +472,7 @@ spec = do
467472
468473 it " formats an annotated diagnostic message" do
469474 Just annotated <- B. readFile " test/fixtures/not-in-scope/err.yaml" >>= parseAnnotated getAvailableImports
470- stripAnsi . unpack <$> formatAnnotated 1 annotated `shouldBe` (2 , unlines [
475+ stripAnsi . unpack <$> formatAnnotated NoShowErrorContext 1 annotated `shouldBe` (2 , unlines [
471476 " test/fixtures/not-in-scope/Foo.hs:2:7: error: [GHC-88464]"
472477 , " Variable not in scope: catMaybes"
473478 , " "
@@ -477,7 +482,7 @@ spec = do
477482
478483 it " formats an annotated diagnostic message" do
479484 Just annotated <- B. readFile " test/fixtures/not-in-scope-operator/err.yaml" >>= parseAnnotated getAvailableImports
480- stripAnsi . unpack <$> formatAnnotated 1 annotated `shouldBe` (5 , unlines [
485+ stripAnsi . unpack <$> formatAnnotated NoShowErrorContext 1 annotated `shouldBe` (5 , unlines [
481486 " test/fixtures/not-in-scope-operator/Foo.hs:2:7: error: [GHC-88464]"
482487 , " Variable not in scope: <&>"
483488 , " Suggested fix:"
0 commit comments