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:
commit
59be0e0025
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user