summaryrefslogtreecommitdiff
path: root/Utility/SubTasty.hs
blob: 5164f9d1b2a13f5ab8a003217c74eecd2953c63b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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"