summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
authorGravatar Joey Hess <joeyh@joeyh.name>2015-07-08 00:38:27 -0400
committerGravatar Joey Hess <joeyh@joeyh.name>2015-07-08 00:39:19 -0400
commit8ce422d8ab390e105d70f049c30d81c14d3b64b4 (patch)
treea747cefa503c067f49988ef6412eb58f459bd7b6 /Utility
parent37a34b3dbcfb38f815edc141a57721d9f94440b4 (diff)
better method for running tasty's optparse as a subcommand
Diffstat (limited to 'Utility')
-rw-r--r--Utility/SubTasty.hs25
1 files changed, 25 insertions, 0 deletions
diff --git a/Utility/SubTasty.hs b/Utility/SubTasty.hs
new file mode 100644
index 000000000..5164f9d1b
--- /dev/null
+++ b/Utility/SubTasty.hs
@@ -0,0 +1,25 @@
+{- Running tasty as a subcommand.
+ -
+ - Copyright 2015 Joey Hess <id@joeyh.name>
+ -
+ - License: BSD-2-clause
+ -}
+
+module Utility.SubTasty where
+
+import Test.Tasty
+import Test.Tasty.Options
+import Test.Tasty.Runners
+import Options.Applicative
+
+-- Uses tasty's option parser, modified to expect a subcommand.
+parseOpts :: String -> [Ingredient] -> TestTree -> [String] -> IO OptionSet
+parseOpts subcommand is ts =
+ handleParseResult . execParserPure (prefs idm) pinfo
+ where
+ pinfo = info (helper <*> subpinfo) (fullDesc <> header desc)
+ subpinfo = subparser $ command subcommand $
+ suiteOptionParser is ts
+ `info`
+ progDesc desc
+ desc = "Builtin test suite"