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.
 | 
					-- | 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 :: CliOpts -> Journal -> IO ()
 | 
				
			||||||
testcmd opts _ = do
 | 
					testcmd opts _donotuse = do
 | 
				
			||||||
  let ts = 
 | 
					  let ts = 
 | 
				
			||||||
        (if tree_ $ reportopts_ opts then matchedTestsTree else matchedTestsFlat) 
 | 
					        (if tree_ $ reportopts_ opts then matchedTestsTree else matchedTestsFlat) 
 | 
				
			||||||
          opts tests_Hledger_Cli_Commands
 | 
					          opts tests_Hledger_Cli_Commands
 | 
				
			||||||
 | 
				
			|||||||
@ -169,14 +169,17 @@ main = do
 | 
				
			|||||||
      | isBadCommand             = badCommandError
 | 
					      | isBadCommand             = badCommandError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      -- builtin commands
 | 
					      -- builtin commands
 | 
				
			||||||
      | Just (cmdmode, cmdaction) <- findCommand cmd = do 
 | 
					      | Just (cmdmode, cmdaction) <- findCommand cmd =
 | 
				
			||||||
        if cmd=="add" -- add command does extra work before reading journal
 | 
					        (case cmd of
 | 
				
			||||||
        then (do
 | 
					          "test" -> -- should not read the journal
 | 
				
			||||||
          journalFilePathFromOpts opts >>= (ensureJournalFileExists . head) 
 | 
					            cmdaction opts (error "journal-less command tried to use the journal")
 | 
				
			||||||
          withJournalDo opts cmdaction)
 | 
					          "add" ->  -- should create the journal if missing
 | 
				
			||||||
          `orShowHelp` cmdmode
 | 
					            (ensureJournalFileExists =<< (head <$> journalFilePathFromOpts opts)) >>
 | 
				
			||||||
        else
 | 
					            withJournalDo opts cmdaction
 | 
				
			||||||
          withJournalDo opts cmdaction `orShowHelp` cmdmode
 | 
					          _ ->      -- all other commands: read the journal or fail if missing
 | 
				
			||||||
 | 
					            withJournalDo opts cmdaction
 | 
				
			||||||
 | 
					        )
 | 
				
			||||||
 | 
					        `orShowHelp` cmdmode
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      -- addon commands
 | 
					      -- addon commands
 | 
				
			||||||
      | isExternalCommand = do
 | 
					      | isExternalCommand = do
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user