From ca4fade4afcdedb4ccb5fbca4b2cf7d1e209d5e3 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Thu, 28 Nov 2019 14:45:10 -0800 Subject: [PATCH] ;tests: re-add hledger-lib's tests to the cabal file, as unittests --- Makefile | 4 +- hledger-lib/hledger-lib.cabal | 58 ++++++++++++++++++- hledger-lib/package.yaml | 15 +++-- .../test/{easytests.hs => unittests.hs} | 6 +- 4 files changed, 70 insertions(+), 13 deletions(-) rename hledger-lib/test/{easytests.hs => unittests.hs} (56%) diff --git a/Makefile b/Makefile index 95456f9de..afc6830ec 100644 --- a/Makefile +++ b/Makefile @@ -419,8 +419,8 @@ pkgtest: $(call def-help,pkgtest, run the test suites in each package ) doctest: $(call def-help,doctest, run the doctests in hledger-lib module/function docs ) @($(STACKTEST) hledger-lib:test:doctests && echo $@ PASSED) || (echo $@ FAILED; false) -easytest: $(call def-help,easytest, run the easytest unit tests in hledger-lib ) - @($(STACKTEST) hledger-lib:test:easytests && echo $@ PASSED) || (echo $@ FAILED; false) +unittest: $(call def-help,unittest, run the unit tests in hledger-lib ) + @($(STACKTEST) hledger-lib:test:unittests && echo $@ PASSED) || (echo $@ FAILED; false) # assumes an up to date hledger executable is built. # I think we don't do it automatically to minimise unnecessary rebuilding. diff --git a/hledger-lib/hledger-lib.cabal b/hledger-lib/hledger-lib.cabal index 5027c2b72..03b5e2f58 100644 --- a/hledger-lib/hledger-lib.cabal +++ b/hledger-lib/hledger-lib.cabal @@ -4,7 +4,7 @@ cabal-version: 1.12 -- -- see: https://github.com/sol/hpack -- --- hash: f8ee8c9fd0412cc0a8cd5c6286b7ef4f9a33ae2a30989dfc0b99c3f79bd55622 +-- hash: d44cc48a2f9dc087afe19992824ce4e95ddf82662880f81963eb6389a5ef4a83 name: hledger-lib version: 1.15.99 @@ -206,3 +206,59 @@ test-suite doctests if (impl(ghc < 8.2)) buildable: False default-language: Haskell2010 + +test-suite unittests + type: exitcode-stdio-1.0 + main-is: unittests.hs + hs-source-dirs: + ./. + test + ghc-options: -Wall -fno-warn-unused-do-bind -fno-warn-name-shadowing -fno-warn-missing-signatures -fno-warn-type-defaults -fno-warn-orphans + build-depends: + Decimal + , Glob >=0.9 + , ansi-terminal >=0.6.2.3 + , array + , base >=4.9 && <4.14 + , base-compat-batteries >=0.10.1 && <0.12 + , blaze-markup >=0.5.1 + , bytestring + , call-stack + , cassava + , cassava-megaparsec + , cmdargs >=0.10 + , containers + , data-default >=0.5 + , deepseq + , directory + , extra >=1.6.3 + , fgl >=5.5.4.0 + , file-embed >=0.0.10 + , filepath + , hashtables >=1.2.3.1 + , hledger-lib + , megaparsec >=7.0.0 && <8 + , mtl + , mtl-compat + , old-time + , parsec >=3 + , parser-combinators >=0.4.0 + , pretty-show >=1.6.4 + , regex-tdfa + , safe >=0.2 + , split >=0.1 + , tabular >=0.2 + , tasty >=1.2.3 + , tasty-hunit >=0.10.0.2 + , template-haskell + , text >=1.2 + , time >=1.5 + , timeit + , transformers >=0.2 + , uglymemo + , utf8-string >=0.3.5 + buildable: True + if (!impl(ghc >= 8.0)) + build-depends: + semigroups ==0.18.* + default-language: Haskell2010 diff --git a/hledger-lib/package.yaml b/hledger-lib/package.yaml index 5a3385443..fcd193660 100644 --- a/hledger-lib/package.yaml +++ b/hledger-lib/package.yaml @@ -186,11 +186,10 @@ tests: - condition: (impl(ghc < 8.2)) buildable: false - - # easytests: - # buildable: true - # source-dirs: test - # main: easytests.hs - # other-modules: [] # prevent double compilation, https://github.com/sol/hpack/issues/188 - # dependencies: - # - hledger-lib + unittests: + buildable: true + source-dirs: test + main: unittests.hs + other-modules: [] # prevent double compilation, https://github.com/sol/hpack/issues/188 + dependencies: + - hledger-lib diff --git a/hledger-lib/test/easytests.hs b/hledger-lib/test/unittests.hs similarity index 56% rename from hledger-lib/test/easytests.hs rename to hledger-lib/test/unittests.hs index 4f6680935..42d4f586b 100644 --- a/hledger-lib/test/easytests.hs +++ b/hledger-lib/test/unittests.hs @@ -1,8 +1,10 @@ {-# LANGUAGE PackageImports #-} {- -Run hledger-lib's easytest tests using the easytest runner. +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. -} import "hledger-lib" Hledger -main = run tests_Hledger +import Test.Tasty (defaultMain) + +main = defaultMain tests_Hledger