Skip to content

Commit 978038e

Browse files
emarzionttuegel
andauthored
Include result.kore with --bug-report (#2324)
Fixes #2018 Co-authored-by: emarzion <[email protected]> Co-authored-by: Thomas Tuegel <[email protected]> Co-authored-by: Thomas Tuegel <[email protected]>
1 parent f3b6373 commit 978038e

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

kore/app/exec/Main.hs

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -553,30 +553,32 @@ main = do
553553
parserInfoModifiers
554554
for_ (localOptions options) mainWithOptions
555555

556+
{- | Use the parsed 'KoreExecOptions' to set up output and logging, then
557+
dispatch the requested command.
558+
-}
556559
mainWithOptions :: KoreExecOptions -> IO ()
557560
mainWithOptions execOptions = do
558-
let KoreExecOptions
559-
{ koreLogOptions
560-
, koreSolverOptions
561-
, bugReportOption
562-
}
563-
= execOptions
561+
let KoreExecOptions { koreSolverOptions, bugReportOption, outputFileName } = execOptions
564562
ensureSmtPreludeExists koreSolverOptions
565563
exitCode <-
566564
withBugReport Main.exeName bugReportOption $ \tmpDir -> do
567-
writeOptionsAndKoreFiles tmpDir execOptions
568-
go <* warnIfLowProductivity
565+
let execOptions' = execOptions {
566+
outputFileName = Just (tmpDir </> "result.kore") }
567+
writeOptionsAndKoreFiles tmpDir execOptions'
568+
e <- mainDispatch execOptions' <* warnIfLowProductivity
569569
& handle handleWithConfiguration
570570
& handle handleSomeException
571571
& runKoreLog tmpDir koreLogOptions
572+
case outputFileName of
573+
Nothing -> readFile (tmpDir </> "result.kore") >>= putStr
574+
Just fileName -> copyFile (tmpDir </> "result.kore") fileName
575+
return e
572576
let KoreExecOptions { rtsStatistics } = execOptions
573577
for_ rtsStatistics $ \filePath ->
574578
writeStats filePath =<< getStats
575579
exitWith exitCode
576580
where
577-
KoreExecOptions { koreProveOptions } = execOptions
578-
KoreExecOptions { koreSearchOptions } = execOptions
579-
KoreExecOptions { koreMergeOptions } = execOptions
581+
KoreExecOptions { koreLogOptions } = execOptions
580582

581583
handleSomeException :: SomeException -> Main ExitCode
582584
handleSomeException someException = do
@@ -594,21 +596,27 @@ mainWithOptions execOptions = do
594596
("// Last configuration:\n" <> unparse lastConfiguration)
595597
throwM someException
596598

597-
go :: Main ExitCode
598-
go
599-
| Just proveOptions@KoreProveOptions{bmc} <- koreProveOptions =
600-
if bmc
601-
then koreBmc execOptions proveOptions
602-
else koreProve execOptions proveOptions
599+
{- | Dispatch the requested command, for example 'koreProve' or 'koreRun'.
600+
-}
601+
mainDispatch :: KoreExecOptions -> Main ExitCode
602+
mainDispatch execOptions
603+
| Just proveOptions@KoreProveOptions{bmc} <- koreProveOptions =
604+
if bmc
605+
then koreBmc execOptions proveOptions
606+
else koreProve execOptions proveOptions
603607

604-
| Just searchOptions <- koreSearchOptions =
605-
koreSearch execOptions searchOptions
608+
| Just searchOptions <- koreSearchOptions =
609+
koreSearch execOptions searchOptions
606610

607-
| Just mergeOptions <- koreMergeOptions =
608-
koreMerge execOptions mergeOptions
611+
| Just mergeOptions <- koreMergeOptions =
612+
koreMerge execOptions mergeOptions
609613

610-
| otherwise =
611-
koreRun execOptions
614+
| otherwise =
615+
koreRun execOptions
616+
where
617+
KoreExecOptions { koreProveOptions } = execOptions
618+
KoreExecOptions { koreSearchOptions } = execOptions
619+
KoreExecOptions { koreMergeOptions } = execOptions
612620

613621
koreSearch :: KoreExecOptions -> KoreSearchOptions -> Main ExitCode
614622
koreSearch execOptions searchOptions = do

0 commit comments

Comments
 (0)