;lib, cli: test suite cleanups, don't run hledger-lib tests twice
This commit is contained in:
parent
2b2a0b3cf8
commit
c7574b8005
@ -152,6 +152,14 @@ library:
|
|||||||
|
|
||||||
tests:
|
tests:
|
||||||
|
|
||||||
|
unittests:
|
||||||
|
buildable: true
|
||||||
|
source-dirs: test
|
||||||
|
main: unittests.hs
|
||||||
|
other-modules: [] # prevent double compilation, https://github.com/sol/hpack/issues/188
|
||||||
|
dependencies:
|
||||||
|
- hledger-lib
|
||||||
|
|
||||||
doctests:
|
doctests:
|
||||||
buildable: true
|
buildable: true
|
||||||
source-dirs: test
|
source-dirs: test
|
||||||
@ -173,18 +181,8 @@ tests:
|
|||||||
# - condition: os(darwin) && impl(ghc >= 8.4)
|
# - condition: os(darwin) && impl(ghc >= 8.4)
|
||||||
# buildable: false
|
# buildable: false
|
||||||
|
|
||||||
# ghc 7.10 on linux:
|
|
||||||
# doctests: <command line>: Can't parse package flag: package-db /home/simon/.stack/snapshots/i386-linux/026d718ac4d5f70d983bbeebb712f79d402a8e7003bbfe787f9e853573ed7ed6/7.10.3/pkgdb
|
|
||||||
# ghc 8.0 on linux:
|
# ghc 8.0 on linux:
|
||||||
# Hledger/Read/JournalReader.hs:126: failure in expression `rejp (journalp <* eof) "2015/1/1\n a 0\n"' ... Variable not in scope: rejp :: f0 a0 -> [Char] -> t
|
# Hledger/Read/JournalReader.hs:126: failure in expression `rejp (journalp <* eof) "2015/1/1\n a 0\n"' ... Variable not in scope: rejp :: f0 a0 -> [Char] -> t
|
||||||
when:
|
when:
|
||||||
- condition: (impl(ghc < 8.2))
|
- condition: (impl(ghc < 8.2))
|
||||||
buildable: false
|
buildable: false
|
||||||
|
|
||||||
unittests:
|
|
||||||
buildable: true
|
|
||||||
source-dirs: test
|
|
||||||
main: unittests.hs
|
|
||||||
other-modules: [] # prevent double compilation, https://github.com/sol/hpack/issues/188
|
|
||||||
dependencies:
|
|
||||||
- hledger-lib
|
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
{-# LANGUAGE PackageImports #-}
|
|
||||||
{-
|
{-
|
||||||
Run hledger-lib's unit tests using tasty's test runner.
|
Run the hledger-lib package's unit tests using the tasty test runner.
|
||||||
Note that we use package-qualified import to overcome
|
|
||||||
Cabal heuristic missing-home-modules.
|
|
||||||
-}
|
-}
|
||||||
import "hledger-lib" Hledger
|
|
||||||
|
-- package-qualified import to avoid cabal missing-home-modules warning (and double-building ?)
|
||||||
|
{-# LANGUAGE PackageImports #-}
|
||||||
|
import "hledger-lib" Hledger (tests_Hledger)
|
||||||
|
|
||||||
import Test.Tasty (defaultMain)
|
import Test.Tasty (defaultMain)
|
||||||
|
|
||||||
main = defaultMain tests_Hledger
|
main = defaultMain tests_Hledger
|
||||||
|
|||||||
@ -16,7 +16,6 @@ module Hledger.Cli (
|
|||||||
module Hledger.Cli.Utils,
|
module Hledger.Cli.Utils,
|
||||||
module Hledger.Cli.Version,
|
module Hledger.Cli.Version,
|
||||||
module Hledger,
|
module Hledger,
|
||||||
tests_Cli,
|
|
||||||
module System.Console.CmdArgs.Explicit
|
module System.Console.CmdArgs.Explicit
|
||||||
)
|
)
|
||||||
where
|
where
|
||||||
@ -29,8 +28,4 @@ import Hledger.Cli.DocFiles
|
|||||||
import Hledger.Cli.Utils
|
import Hledger.Cli.Utils
|
||||||
import Hledger.Cli.Version
|
import Hledger.Cli.Version
|
||||||
|
|
||||||
-- unit tests for code under Hledger.Cli (hledger-lib tests not included)
|
-- unit tests (tests_Hledger_Cli) are defined in Hledger.Cli.Commands
|
||||||
tests_Cli = tests "Hledger.Cli" [
|
|
||||||
tests_Cli_Utils
|
|
||||||
,tests_Commands
|
|
||||||
]
|
|
||||||
|
|||||||
@ -16,7 +16,7 @@ module Hledger.Cli.Commands (
|
|||||||
,builtinCommands
|
,builtinCommands
|
||||||
,builtinCommandNames
|
,builtinCommandNames
|
||||||
,printCommandsList
|
,printCommandsList
|
||||||
,tests_Commands
|
,tests_Hledger_Cli
|
||||||
,module Hledger.Cli.Commands.Accounts
|
,module Hledger.Cli.Commands.Accounts
|
||||||
,module Hledger.Cli.Commands.Activity
|
,module Hledger.Cli.Commands.Activity
|
||||||
,module Hledger.Cli.Commands.Add
|
,module Hledger.Cli.Commands.Add
|
||||||
@ -261,32 +261,35 @@ testmode = hledgerCommandMode
|
|||||||
[]
|
[]
|
||||||
([], Just $ argsFlag "[-- TASTYOPTS]")
|
([], Just $ argsFlag "[-- TASTYOPTS]")
|
||||||
|
|
||||||
-- | The test command.
|
-- | The test command, which runs the hledger and hledger-lib
|
||||||
|
-- packages' unit tests. This command also accepts tasty test runner
|
||||||
|
-- options, written after a -- (double hyphen).
|
||||||
|
--
|
||||||
-- 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
|
||||||
-- not be used (and would raise an error).
|
-- not be used (and would raise an error).
|
||||||
--
|
--
|
||||||
-- This command also accepts tasty test runner options,
|
|
||||||
-- written after a -- (double hyphen).
|
|
||||||
--
|
|
||||||
testcmd :: CliOpts -> Journal -> IO ()
|
testcmd :: CliOpts -> Journal -> IO ()
|
||||||
testcmd opts _undefined = do
|
testcmd opts _undefined = do
|
||||||
withArgs (words' $ query_ $ reportopts_ opts) $
|
withArgs (words' $ query_ $ reportopts_ opts) $
|
||||||
Test.Tasty.defaultMain $ tests "hledger" [
|
Test.Tasty.defaultMain $ tests "hledger" [
|
||||||
tests_Hledger
|
tests_Hledger
|
||||||
,tests "Hledger.Cli" [
|
,tests_Hledger_Cli
|
||||||
tests_Cli_Utils
|
|
||||||
,tests_Commands
|
|
||||||
]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
-- All unit tests for Hledger.Cli, defined here rather than
|
||||||
|
-- Hledger.Cli so testcmd can use them.
|
||||||
|
tests_Hledger_Cli = tests "Hledger.Cli" [
|
||||||
|
tests_Cli_Utils
|
||||||
|
,tests_Commands
|
||||||
|
]
|
||||||
|
|
||||||
tests_Commands = tests "Commands" [
|
tests_Commands = tests "Commands" [
|
||||||
tests_Balance
|
tests_Balance
|
||||||
,tests_Register
|
,tests_Register
|
||||||
|
|
||||||
-- some more tests easiest to define here:
|
-- some more tests easiest to define here:
|
||||||
|
|
||||||
,tests "apply account directive" [
|
,tests "apply account directive" [
|
||||||
test "works" $ do
|
test "works" $ do
|
||||||
let
|
let
|
||||||
@ -315,7 +318,7 @@ tests_Commands = tests "Commands" [
|
|||||||
paccount p @?= "test:from"
|
paccount p @?= "test:from"
|
||||||
ptype p @?= VirtualPosting
|
ptype p @?= VirtualPosting
|
||||||
]
|
]
|
||||||
|
|
||||||
,test "alias directive" $ do
|
,test "alias directive" $ do
|
||||||
j <- readJournal def Nothing "!alias expenses = equity:draw:personal\n1/1\n (expenses:food) 1\n" >>= either error' return
|
j <- readJournal def Nothing "!alias expenses = equity:draw:personal\n1/1\n (expenses:food) 1\n" >>= either error' return
|
||||||
let p = head $ tpostings $ head $ jtxns j
|
let p = head $ tpostings $ head $ jtxns j
|
||||||
@ -347,8 +350,7 @@ tests_Commands = tests "Commands" [
|
|||||||
|
|
||||||
,test "show hours" $ showAmount (hrs 1) @?= "1.00h"
|
,test "show hours" $ showAmount (hrs 1) @?= "1.00h"
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
-- test data
|
-- test data
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,13 @@
|
|||||||
{-
|
{-
|
||||||
Run hledger's (and hledger-lib's) unit tests as a cabal test suite,
|
Run the hledger package's unit tests using the tasty test runner
|
||||||
by running the test command with no options.
|
(by running the test command limited to Hledger.Cli tests).
|
||||||
-}
|
-}
|
||||||
|
|
||||||
import Hledger.Cli
|
-- cabal missing-home-modules workaround from hledger-lib, seems not needed here
|
||||||
|
-- {-# LANGUAGE PackageImports #-}
|
||||||
|
-- import "hledger" Hledger.Cli (tests_Hledger_Cli)
|
||||||
|
import Hledger.Cli (tests_Hledger_Cli)
|
||||||
|
|
||||||
main = testcmd defcliopts (error "journal-less command tried to use the journal")
|
import Test.Tasty (defaultMain)
|
||||||
|
|
||||||
|
main = defaultMain tests_Hledger_Cli
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user