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
2 changes: 1 addition & 1 deletion src/Prolog/Programming/ExampleConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ exampleConfig =
# uses the last provided values if fields are provided multiple times

# timeout per test in ms (defaults to 10000)
globalTimeout: 1000
mainTestTimeout: 1000

# style of derivation tree rendering can be either 'query' or 'resolution' (defaults to 'query')
# treeStyle: resolution
Expand Down
6 changes: 3 additions & 3 deletions src/Prolog/Programming/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,11 @@ instance FromJSON TaskConfig where
parseJSON = withObject "TaskConfig" $ \v -> do
rejectUnknownFields (recordFieldNames @TaskConfig) v

globalTO <- v .:? "globalTimeout" .!= 10000
mainTestTO <- v .:? "mainTestTimeout" .!= 10000

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

TaskConfig globalTO
TaskConfig mainTestTO
<$> v .:? "treeStyle" .!= QueryStyle
<*> v .:? "includeTaskDefinitions" .!= Yes
<*> v .:? "includeHiddenDefinitions" .!= Yes
Expand Down
4 changes: 2 additions & 2 deletions src/Prolog/Programming/Task.hs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ checkTask reject inform drawPicture TaskInstance {taskConfig = TaskConfig {..},
testResult <-
liftIO $
testRunner
globalTimeout
mainTestTimeout
(TimeoutDivisor 1)
errorOnFirstTimeout
factProg
Expand Down Expand Up @@ -318,7 +318,7 @@ checkTask reject inform drawPicture TaskInstance {taskConfig = TaskConfig {..},
RedundantCodeConfig (Just (WithSeverity severity timeoutDivisor, AfterTests)) -> do
let checker p =
allTestResultsAreOkay . fst
<$> testRunner globalTimeout timeoutDivisor True factProg p specifications newDefs
<$> testRunner mainTestTimeout timeoutDivisor True factProg p specifications newDefs
redundantCodeProblem <- liftIO $ checkForRedundantCode checker inProg

case redundantCodeProblem of
Expand Down
2 changes: 1 addition & 1 deletion src/Prolog/Programming/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ type AllowListMatching = Bool
type ShowSWISHButton = Bool

data TaskConfig = TaskConfig {
globalTimeout :: TimeoutDuration
mainTestTimeout :: TimeoutDuration
, treeStyle :: TreeStyle
, includeTaskDefinitions :: IncludeTask
, includeHiddenDefinitions :: IncludeHidden
Expand Down
10 changes: 5 additions & 5 deletions test/ConfigSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,16 @@ spec = describe "ExampleConfig" $ do
evaluateVerify exampleConfig `shouldReturn` Right ()
it "rejects config with unknown fields" $ do
result <-
evaluateVerify $ "globalTiimeout: 10000" ++ withoutConfigPart -- no-spell-check
evaluateVerify $ "mainTesTimeout: 10000" ++ withoutConfigPart -- no-spell-check
result `shouldSatisfy` \case
Right () -> False
Left msg -> "Unknown or forbidden fields: globalTiimeout" `isInfixOf` msg -- no-spell-check
it "rejects config with negative globalTimeout" $ do
Left msg -> "Unknown or forbidden fields: mainTesTimeout" `isInfixOf` msg -- no-spell-check
it "rejects config with negative mainTestTimeout" $ do
result <-
evaluateVerify $ "globalTimeout: -10000" ++ withoutConfigPart
evaluateVerify $ "mainTestTimeout: -10000" ++ withoutConfigPart
result `shouldSatisfy` \case
Right () -> False
Left msg -> "globalTimeout must be non-negative" `isInfixOf` msg
Left msg -> "mainTestTimeout 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