Skip to content

Commit

Permalink
Change PGT.run{Tests,Updates} to expect a post processor argument
Browse files Browse the repository at this point in the history
  • Loading branch information
snusnu authored and epicallan committed Oct 5, 2023
1 parent 04d8dd0 commit 8dd18c8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
15 changes: 7 additions & 8 deletions pgt/src/PGT.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import qualified Data.Text.IO as Text
import qualified Data.Vector as Vector
import qualified PGT.Output as PGT
import qualified System.Environment as System
import qualified System.Exit as System
import qualified System.Path as Path
Expand Down Expand Up @@ -81,13 +80,13 @@ runExamples tests = do
traverse_ (runTestSession setupDatabaseName Process.runProcess_) tests
pure System.ExitSuccess

runTasty :: Tasty.OptionSet -> Tests -> MIO Environment System.ExitCode
runTasty tastyOptions tests = do
runTasty :: PostProcess -> Tasty.OptionSet -> Tests -> MIO Environment System.ExitCode
runTasty postProcess tastyOptions tests = do
withSetupDatabase $ \setupDatabaseName -> do
liftIO Tasty.Runners.installSignalHandlers
maybe (liftIO failIngredients) (liftIO . run)
. Tasty.Runners.tryIngredients Tasty.defaultIngredients tastyOptions
=<< testTree setupDatabaseName PGT.impureParse tests
=<< testTree setupDatabaseName postProcess tests
where
failIngredients :: IO a
failIngredients = fail "Internal failure running ingredients"
Expand All @@ -99,11 +98,11 @@ runTasty tastyOptions tests = do
then System.ExitSuccess
else System.ExitFailure 1

runTests :: Tests -> MIO Environment System.ExitCode
runTests = runTasty mempty
runTests :: PostProcess -> Tests -> MIO Environment System.ExitCode
runTests postProcess = runTasty postProcess mempty

runUpdates :: Tests -> MIO Environment System.ExitCode
runUpdates = runTasty (Tasty.singleOption Tasty.MGolden.UpdateExpected)
runUpdates :: PostProcess -> Tests -> MIO Environment System.ExitCode
runUpdates postProcess = runTasty postProcess (Tasty.singleOption Tasty.MGolden.UpdateExpected)

testTree :: DBT.DatabaseName -> PostProcess -> Tests -> MIO Environment Tasty.TestTree
testTree setupDatabaseName postProcess tests = Tasty.testGroup "pgt" <$> traverse mkGolden (Vector.toList tests)
Expand Down
5 changes: 3 additions & 2 deletions pgt/src/PGT/CLI.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import PGT.Selector

import qualified Data.Vector as Vector
import qualified Options.Applicative as CLI
import qualified PGT.Output as PGT
import qualified System.Exit as System
import qualified System.IO as IO
import qualified System.Path as Path
Expand Down Expand Up @@ -44,8 +45,8 @@ parserInfoCommand = wrapHelper subcommands
CLI.subparser
$ mkCommand "list" runList
<> mkCommand "run" runExamples
<> mkCommand "test" runTests
<> mkCommand "update" runUpdates
<> mkCommand "test" (runTests PGT.impureParse)
<> mkCommand "update" (runUpdates PGT.impureParse)

mkCommand
:: String
Expand Down

0 comments on commit 8dd18c8

Please sign in to comment.