Skip to content
Merged
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
9 changes: 6 additions & 3 deletions src/Prolog/Programming/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,12 @@ instance FromJSON TaskConfig where
parseJSON = withObject "TaskConfig" $ \v -> do
rejectUnknownFields (recordFieldNames @TaskConfig) v

TaskConfig
<$> v .:? "globalTimeout" .!= 10000
<*> v .:? "treeStyle" .!= QueryStyle
globalTO <- v .:? "globalTimeout" .!= 10000

when (globalTO < 0) $ fail "globalTimeout must be non-negative"

TaskConfig globalTO
<$> v .:? "treeStyle" .!= QueryStyle
<*> v .:? "includeTaskDefinitions" .!= Yes
<*> v .:? "includeHiddenDefinitions" .!= Yes
<*> v .:? "allowListPatternMatching" .!= True
Expand Down
6 changes: 6 additions & 0 deletions test/ConfigSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ spec = describe "ExampleConfig" $ do
result `shouldSatisfy` \case
Right () -> False
Left msg -> "Unknown or forbidden fields: globalTiimeout" `isInfixOf` msg -- no-spell-check
it "rejects config with negative globalTimeout" $ do
result <-
evaluateVerify $ "globalTimeout: -10000" ++ withoutConfigPart
result `shouldSatisfy` \case
Right () -> False
Left msg -> "globalTimeout must be non-negative" `isInfixOf` msg
it "rejects code analysis configs with stage set to 'before-tests' and status unlike 'reject'" $ do
result <-
evaluateVerify $
Expand Down
Loading