;lib, cli: test suite cleanups, don't run hledger-lib tests twice

This commit is contained in:
Simon Michael 2019-11-29 06:06:36 -08:00
parent 2b2a0b3cf8
commit c7574b8005
5 changed files with 39 additions and 38 deletions

View File

@ -152,6 +152,14 @@ library:
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:
buildable: true
source-dirs: test
@ -173,18 +181,8 @@ tests:
# - condition: os(darwin) && impl(ghc >= 8.4)
# 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:
# 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:
- condition: (impl(ghc < 8.2))
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

View File

@ -1,10 +1,11 @@
{-# LANGUAGE PackageImports #-}
{-
Run hledger-lib's unit tests using tasty's test runner.
Note that we use package-qualified import to overcome
Cabal heuristic missing-home-modules.
Run the hledger-lib package's unit tests using the tasty test runner.
-}
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)
main = defaultMain tests_Hledger

View File

@ -16,7 +16,6 @@ module Hledger.Cli (
module Hledger.Cli.Utils,
module Hledger.Cli.Version,
module Hledger,
tests_Cli,
module System.Console.CmdArgs.Explicit
)
where
@ -29,8 +28,4 @@ import Hledger.Cli.DocFiles
import Hledger.Cli.Utils
import Hledger.Cli.Version
-- unit tests for code under Hledger.Cli (hledger-lib tests not included)
tests_Cli = tests "Hledger.Cli" [
tests_Cli_Utils
,tests_Commands
]
-- unit tests (tests_Hledger_Cli) are defined in Hledger.Cli.Commands

View File

@ -16,7 +16,7 @@ module Hledger.Cli.Commands (
,builtinCommands
,builtinCommandNames
,printCommandsList
,tests_Commands
,tests_Hledger_Cli
,module Hledger.Cli.Commands.Accounts
,module Hledger.Cli.Commands.Activity
,module Hledger.Cli.Commands.Add
@ -261,25 +261,28 @@ testmode = hledgerCommandMode
[]
([], 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.
-- A 'Journal' argument remains in the type signature, but it should
-- 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 opts _undefined = do
withArgs (words' $ query_ $ reportopts_ opts) $
Test.Tasty.defaultMain $ tests "hledger" [
tests_Hledger
,tests "Hledger.Cli" [
,tests_Hledger_Cli
]
-- 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_Balance
@ -349,7 +352,6 @@ tests_Commands = tests "Commands" [
]
-- test data
-- date1 = parsedate "2008/11/26"

View File

@ -1,8 +1,13 @@
{-
Run hledger's (and hledger-lib's) unit tests as a cabal test suite,
by running the test command with no options.
Run the hledger package's unit tests using the tasty test runner
(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