Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adapt pact output #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/Pact/LSP/PactTrace.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ parseEntry = do
_relatedInformation = Nothing
_message = T.pack msg
pure (fp, Diagnostic{..})

where
pcolon = void (char ':')
string' str = try (string str)
Expand All @@ -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")
emilypi marked this conversation as resolved.
Show resolved Hide resolved
pcolon
ln <- read <$> many1 digit
pcolon
Expand Down
20 changes: 17 additions & 3 deletions tests/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ toDiagnostic beg@Position{..} s msg = Diagnostic
, _message = msg
, _severity = Just s
}


main :: IO ()
main = do
Expand All @@ -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"
Expand Down Expand Up @@ -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
Expand Down