1
1
mirror of https://github.com/github/semantic.git synced 2024-12-24 23:42:31 +03:00

Merge pull request #492 from github/respect-this-failure

Ensure that the failParsingForTesting flag is always respected.
This commit is contained in:
Patrick Thomson 2020-02-19 08:34:11 -05:00 committed by GitHub
commit 59be0e0025
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -62,14 +62,12 @@ runParser blob@Blob{..} parser = case parser of
ASTParser language ->
time "parse.tree_sitter_ast_parse" languageTag $ do
config <- asks config
parseToAST (configTreeSitterParseTimeout config) language blob
>>= either (\e -> trace (displayException e) *> throwError (SomeException e)) pure
executeParserAction (parseToAST (configTreeSitterParseTimeout config) language blob)
UnmarshalParser language ->
time "parse.tree_sitter_precise_ast_parse" languageTag $ do
config <- asks config
parseToPreciseAST (configTreeSitterParseTimeout config) (configTreeSitterUnmarshalTimeout config) language blob
>>= either (\e -> trace (displayException e) *> throwError (SomeException e)) pure
executeParserAction (parseToPreciseAST (configTreeSitterParseTimeout config) (configTreeSitterUnmarshalTimeout config) language blob)
AssignmentParser parser assignment -> runAssignment Assignment.assign parser blob assignment
@ -77,7 +75,13 @@ runParser blob@Blob{..} parser = case parser of
time "parse.cmark_parse" languageTag $
let term = cmarkParser blobSource
in length term `seq` pure term
where languageTag = [("language" :: String, show (blobLanguage blob))]
where
languageTag = [("language" :: String, show (blobLanguage blob))]
executeParserAction act = do
-- Test harnesses can specify that parsing must fail, for testing purposes.
shouldFailFlag <- asks (Flag.toBool FailTestParsing . configFailParsingForTesting . config)
when shouldFailFlag (throwError (SomeException AssignmentTimedOut))
act >>= either (\e -> trace (displayException e) *> throwError (SomeException e)) pure
data ParserCancelled = ParserTimedOut | AssignmentTimedOut
deriving (Show)