fix:test: fix and improve pass-through of arguments to tasty [#2386]
This commit is contained in:
parent
8f6a7c8a66
commit
f7aa1fadd1
@ -474,9 +474,9 @@ testmode = hledgerCommandMode
|
|||||||
[]
|
[]
|
||||||
([], Just $ argsFlag "[-- TASTYOPTS]")
|
([], Just $ argsFlag "[-- TASTYOPTS]")
|
||||||
|
|
||||||
-- | The test command, which runs the hledger and hledger-lib
|
-- | The test command, which runs the hledger and hledger-lib packages' unit tests.
|
||||||
-- packages' unit tests. This command also accepts tasty test runner
|
-- Arguments following a -- argument will be passed to the tasty test runner,
|
||||||
-- options, written after a -- (double hyphen).
|
-- and any arguments before -- will be passed as test-selecting -p patterns.
|
||||||
--
|
--
|
||||||
-- Unlike most hledger commands, this one does not read the user's journal.
|
-- Unlike most hledger commands, this one does not read the user's journal.
|
||||||
-- A 'Journal' argument remains in the type signature, but it should
|
-- A 'Journal' argument remains in the type signature, but it should
|
||||||
@ -484,7 +484,11 @@ testmode = hledgerCommandMode
|
|||||||
--
|
--
|
||||||
testcmd :: CliOpts -> Journal -> IO ()
|
testcmd :: CliOpts -> Journal -> IO ()
|
||||||
testcmd opts _undefined = do
|
testcmd opts _undefined = do
|
||||||
withArgs (listofstringopt "args" $ rawopts_ opts) $
|
let
|
||||||
|
args = listofstringopt "args" $ rawopts_ opts
|
||||||
|
(hledgerargs, tastyargs0) = break (== "--") args
|
||||||
|
tastyargs = dbg1 "tastyargs" $ ["-p " <> a | a <- hledgerargs] ++ drop 1 tastyargs0
|
||||||
|
withArgs tastyargs $
|
||||||
Test.Tasty.defaultMain $ testGroup "hledger" [
|
Test.Tasty.defaultMain $ testGroup "hledger" [
|
||||||
tests_Hledger
|
tests_Hledger
|
||||||
,tests_Hledger_Cli
|
,tests_Hledger_Cli
|
||||||
|
|||||||
@ -16,11 +16,12 @@ sanity-check the installed hledger executable on your platform. All
|
|||||||
tests are expected to pass - if you ever see a failure, please report
|
tests are expected to pass - if you ever see a failure, please report
|
||||||
as a bug!
|
as a bug!
|
||||||
|
|
||||||
This command also accepts tasty test runner options, written after a
|
Any arguments before a `--` argument will be passed to the `tasty` test runner as test-selecting -p patterns,
|
||||||
-- (double hyphen). Eg to run only the tests in Hledger.Data.Amount,
|
and any arguments after `--` will be passed to tasty unchanged.
|
||||||
with ANSI colour codes disabled:
|
|
||||||
```cli
|
Examples:
|
||||||
$ hledger test -- -pData.Amount --color=never
|
```
|
||||||
|
$ hledger test # run all unit tests
|
||||||
|
$ hledger test balance # run tests with "balance" in their name
|
||||||
|
$ hledger test -- -h # show tasty's options
|
||||||
```
|
```
|
||||||
For help on these, see https://github.com/feuerbach/tasty#options
|
|
||||||
(`-- --help` currently doesn't show them).
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user