Skip to content

Commit

Permalink
GHC.DiagnosticSpec: Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sol committed Oct 23, 2024
1 parent 5852876 commit 4a6261e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 1 deletion.
4 changes: 3 additions & 1 deletion test/GHC/DiagnosticSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ test name = it name $ do
bin <- lookupGhc <$> getEnvironment
let
process :: CreateProcess
process = proc bin (args ++ [dir </> "Foo.hs"])
process = proc bin ("-fno-code" : args ++ [dir </> "Foo.hs"])
(_, _, err) <- readCreateProcessWithExitCode process ""
return err

Expand All @@ -51,3 +51,5 @@ spec = do
test "variable-not-in-scope-perhaps-use"
test "use-BlockArguments"
test "non-existing"
test "parse-error"
test "lex-error"
3 changes: 3 additions & 0 deletions test/assets/lex-error/Foo.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Foo where

foo = "bar
1 change: 1 addition & 0 deletions test/assets/lex-error/err.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"1.0","ghcVersion":"ghc-9.10.1","span":{"file":"test/assets/lex-error/Foo.hs","start":{"line":3,"column":11},"end":{"line":3,"column":11}},"severity":"Error","code":21231,"message":["lexical error in string/character literal at character '\\n'"],"hints":[]}
3 changes: 3 additions & 0 deletions test/assets/lex-error/err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test/assets/lex-error/Foo.hs:3:11: error: [GHC-21231]
lexical error in string/character literal at character '\n'

3 changes: 3 additions & 0 deletions test/assets/parse-error/Foo.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module Foo where

data foo
1 change: 1 addition & 0 deletions test/assets/parse-error/err.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"version":"1.0","ghcVersion":"ghc-9.10.1","span":{"file":"test/assets/parse-error/Foo.hs","start":{"line":3,"column":6},"end":{"line":3,"column":9}},"severity":"Error","code":47568,"message":["Malformed head of type or class declaration: foo"],"hints":[]}
3 changes: 3 additions & 0 deletions test/assets/parse-error/err.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
test/assets/parse-error/Foo.hs:3:6: error: [GHC-47568]
Malformed head of type or class declaration: foo

0 comments on commit 4a6261e

Please sign in to comment.