mirror of
https://github.com/github/semantic.git
synced 2024-12-26 00:12:29 +03:00
Return the actual exception when parsing/assignment fails.
This commit is contained in:
parent
bc80f6dc20
commit
5a35598213
@ -1,5 +1,6 @@
|
||||
module Integration.Spec (spec) where
|
||||
|
||||
import Control.Exception (throw)
|
||||
import Data.Foldable (find, traverse_, for_)
|
||||
import Data.List (union, concat, transpose)
|
||||
import qualified Data.ByteString as B
|
||||
@ -83,7 +84,10 @@ normalizeName path = dropExtension $ dropExtension path
|
||||
|
||||
testParse :: TaskSession -> FilePath -> FilePath -> Expectation
|
||||
testParse session path expectedOutput = do
|
||||
actual <- verbatim <$> parseFilePath session path
|
||||
actual <- fmap verbatim <$> parseFilePath session path
|
||||
case actual of
|
||||
Left err -> throw err
|
||||
Right actual -> do
|
||||
expected <- verbatim <$> B.readFile expectedOutput
|
||||
actual `shouldBe` expected
|
||||
|
||||
|
@ -97,8 +97,11 @@ diffFilePaths :: TaskSession -> Both FilePath -> IO ByteString
|
||||
diffFilePaths session paths = readFilePathPair paths >>= runTask session . parseDiffBuilder @[] DiffSExpression . pure >>= either (die . displayException) (pure . runBuilder)
|
||||
|
||||
-- | Returns an s-expression parse tree for the specified FilePath.
|
||||
parseFilePath :: TaskSession -> FilePath -> IO ByteString
|
||||
parseFilePath session path = (fromJust <$> readBlobFromFile (fileForPath path)) >>= runTask session . parseTermBuilder @[] TermSExpression . pure >>= either (die . displayException) (pure . runBuilder)
|
||||
parseFilePath :: TaskSession -> FilePath -> IO (Either SomeException ByteString)
|
||||
parseFilePath session path = do
|
||||
blob <- readBlobFromFile (fileForPath path)
|
||||
res <- runTask session $ parseTermBuilder TermSExpression (toList blob)
|
||||
pure (runBuilder <$> res)
|
||||
|
||||
-- | Read two files to a BlobPair.
|
||||
readFilePathPair :: Both FilePath -> IO BlobPair
|
||||
|
Loading…
Reference in New Issue
Block a user