mirror of
https://github.com/simonmichael/hledger.git
synced 2024-12-29 13:22:27 +03:00
test: don't try to read the journal
This commit is contained in:
parent
40d70ad10b
commit
3e0147b7e9
@ -230,8 +230,12 @@ testmode = (defCommandMode ["test"]) {
|
||||
}
|
||||
|
||||
-- | Run some or all hledger-lib and hledger unit tests, and exit with success or failure.
|
||||
--
|
||||
-- Unlike other hledger commands, this one does not operate on the user's Journal.
|
||||
-- For ease of implementation the Journal parameter remains in the type signature,
|
||||
-- but it will not be valid and should not be used.
|
||||
testcmd :: CliOpts -> Journal -> IO ()
|
||||
testcmd opts _ = do
|
||||
testcmd opts _donotuse = do
|
||||
let ts =
|
||||
(if tree_ $ reportopts_ opts then matchedTestsTree else matchedTestsFlat)
|
||||
opts tests_Hledger_Cli_Commands
|
||||
|
@ -169,14 +169,17 @@ main = do
|
||||
| isBadCommand = badCommandError
|
||||
|
||||
-- builtin commands
|
||||
| Just (cmdmode, cmdaction) <- findCommand cmd = do
|
||||
if cmd=="add" -- add command does extra work before reading journal
|
||||
then (do
|
||||
journalFilePathFromOpts opts >>= (ensureJournalFileExists . head)
|
||||
withJournalDo opts cmdaction)
|
||||
`orShowHelp` cmdmode
|
||||
else
|
||||
withJournalDo opts cmdaction `orShowHelp` cmdmode
|
||||
| Just (cmdmode, cmdaction) <- findCommand cmd =
|
||||
(case cmd of
|
||||
"test" -> -- should not read the journal
|
||||
cmdaction opts (error "journal-less command tried to use the journal")
|
||||
"add" -> -- should create the journal if missing
|
||||
(ensureJournalFileExists =<< (head <$> journalFilePathFromOpts opts)) >>
|
||||
withJournalDo opts cmdaction
|
||||
_ -> -- all other commands: read the journal or fail if missing
|
||||
withJournalDo opts cmdaction
|
||||
)
|
||||
`orShowHelp` cmdmode
|
||||
|
||||
-- addon commands
|
||||
| isExternalCommand = do
|
||||
|
Loading…
Reference in New Issue
Block a user