From 8dd18c80d28ec67b0449fd9bcf068342be3b251d Mon Sep 17 00:00:00 2001 From: snusnu Date: Fri, 21 Jul 2023 15:38:23 +0200 Subject: [PATCH] Change PGT.run{Tests,Updates} to expect a post processor argument --- pgt/src/PGT.hs | 15 +++++++-------- pgt/src/PGT/CLI.hs | 5 +++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pgt/src/PGT.hs b/pgt/src/PGT.hs index 6b97fe58..23febe7c 100644 --- a/pgt/src/PGT.hs +++ b/pgt/src/PGT.hs @@ -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 @@ -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" @@ -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) diff --git a/pgt/src/PGT/CLI.hs b/pgt/src/PGT/CLI.hs index cc657fb9..fb8c7b23 100644 --- a/pgt/src/PGT/CLI.hs +++ b/pgt/src/PGT/CLI.hs @@ -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 @@ -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