diff --git a/src/Pact/LSP/PactTrace.hs b/src/Pact/LSP/PactTrace.hs index 3702492..97cee41 100644 --- a/src/Pact/LSP/PactTrace.hs +++ b/src/Pact/LSP/PactTrace.hs @@ -34,7 +34,7 @@ parseEntry = do _relatedInformation = Nothing _message = T.pack msg pure (fp, Diagnostic{..}) - + where pcolon = void (char ':') string' str = try (string str) @@ -43,12 +43,11 @@ parseEntry = do , string' "OutputFailure" $> DsError , string' "Trace" $> DsInfo , string' "Error" $> DsError - , string' " error" $> DsError ] toRange ln col = let ln' = ln-1 in Range (Position ln' col) (Position ln' (col+3)) pInfo = do - fp <- many1 (noneOf ":\n") + fp <- many1 (noneOf " :\n") pcolon ln <- read <$> many1 digit pcolon diff --git a/tests/Main.hs b/tests/Main.hs index 304fcc1..bd011c3 100644 --- a/tests/Main.hs +++ b/tests/Main.hs @@ -48,7 +48,7 @@ toDiagnostic beg@Position{..} s msg = Diagnostic , _message = msg , _severity = Just s } - + main :: IO () main = do @@ -59,7 +59,7 @@ main = do _ <- openDoc "test.pact" "pact" diags <- waitForDiagnostics liftIO $ diags `shouldBe` [] - + it "should send error diagnostic" $ \(hin, hout) -> runSessionWithHandles hin hout defaultConfig fullCaps "tests/data/" $ do _ <- openDoc "test-fail.repl" "pact" @@ -95,7 +95,21 @@ main = do [ "Verification of n_bd7f56c0bc111ea42026912c37ff5da89149d9dc.offchain failed" , ":OutputFailure: pact/offchain.pact:58:17: could not parse (!= public-key \"\"): couldn't find property variable public-key"]))] - + let + ex3 = unlines + ["showcase.repl:1:0:Trace: Loading showcase.pact..." + ,"showcase.pact:1:0:Error: 1error" + ," at showcase.pact:1:0: (enforce false \"error\")" + ,"Load failed" + ] + + parseDiagnostics ex3 `shouldBe` + Right [("showcase.repl", toDiagnostic (Position 0 0) DsInfo "Loading showcase.pact...") + ,("showcase.pact", toDiagnostic (Position 0 0) DsError (T.unlines + ["1error" + ," at showcase.pact:1:0: (enforce false \"error\")"]))] + + parseDiagnostics "Load successful" `shouldSatisfy` isRight hspec $ parallel $ do