Skip to content

Commit

Permalink
Merge pull request #257 from mbj/add/pgt-cli
Browse files Browse the repository at this point in the history
Add pgt {test,update}-no-lint commands to skip output post processing
  • Loading branch information
epicallan authored Oct 5, 2023
2 parents 04d8dd0 + 1ffd0f3 commit 5883320
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 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
11 changes: 7 additions & 4 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 @@ -42,10 +43,12 @@ parserInfoCommand = wrapHelper subcommands

subcommands =
CLI.subparser
$ mkCommand "list" runList
<> mkCommand "run" runExamples
<> mkCommand "test" runTests
<> mkCommand "update" runUpdates
$ mkCommand "list" runList
<> mkCommand "run" runExamples
<> mkCommand "test" (runTests PGT.impureParse)
<> mkCommand "test-no-lint" (runTests identity)
<> mkCommand "update" (runUpdates PGT.impureParse)
<> mkCommand "update-no-lint" (runUpdates identity)

mkCommand
:: String
Expand Down

0 comments on commit 5883320

Please sign in to comment.