cli, lib: move functional tests into hledger/test/

This commit is contained in:
Simon Michael 2020-11-16 08:47:41 -08:00
parent 1c9d704e2f
commit ec2a774b18
134 changed files with 58 additions and 51 deletions

2
.ctags
View File

@ -18,4 +18,4 @@
--exclude=old --exclude=old
--exclude=site/doc --exclude=site/doc
--exclude=site/files --exclude=site/files
--exclude=tests/addons/hledger-* --exclude=hledger/test/addons/hledger-*

View File

@ -27,7 +27,7 @@ on:
- 'hledger/**' - 'hledger/**'
- 'hledger-ui/**' - 'hledger-ui/**'
- 'hledger-web/**' - 'hledger-web/**'
- 'tests/**' - 'hledger/test/**'
- '!**.md' - '!**.md'
- '!**.1' - '!**.1'
- '!**.5' - '!**.5'
@ -43,7 +43,7 @@ on:
- 'hledger/**' - 'hledger/**'
- 'hledger-ui/**' - 'hledger-ui/**'
- 'hledger-web/**' - 'hledger-web/**'
- 'tests/**' - 'hledger/test/**'
- '!**.md' - '!**.md'
- '!**.1' - '!**.1'
- '!**.5' - '!**.5'

View File

@ -19,7 +19,7 @@ on:
- 'hledger/**' - 'hledger/**'
- 'hledger-ui/**' - 'hledger-ui/**'
- 'hledger-web/**' - 'hledger-web/**'
- 'tests/**' - 'hledger/test/**'
- '!**.md' - '!**.md'
- '!**.1' - '!**.1'
- '!**.5' - '!**.5'

View File

@ -15,7 +15,7 @@ on:
- 'hledger/**' - 'hledger/**'
- 'hledger-ui/**' - 'hledger-ui/**'
- 'hledger-web/**' - 'hledger-web/**'
- 'tests/**' - 'hledger/test/**'
- '!**.md' - '!**.md'
- '!**.1' - '!**.1'
- '!**.5' - '!**.5'

View File

@ -19,7 +19,7 @@ on:
- 'hledger/**' - 'hledger/**'
- 'hledger-ui/**' - 'hledger-ui/**'
- 'hledger-web/**' - 'hledger-web/**'
# - 'tests/**' # - 'hledger/test/**'
- '!**.md' - '!**.md'
- '!**.1' - '!**.1'
- '!**.5' - '!**.5'

2
.gitignore vendored
View File

@ -71,7 +71,7 @@ old
!/bin/*.md !/bin/*.md
/.latest.* /.latest.*
test.hs test.hs
tests/addons/hledger-* hledger/test/addons/hledger-*
tools/generatejournal tools/generatejournal
tools/simplebench tools/simplebench
/examples/10*.journal /examples/10*.journal

View File

@ -762,8 +762,8 @@ About testing in the hledger project, as of 201809.
functionality in the hledger and hledger-lib packages. We do this functionality in the hledger and hledger-lib packages. We do this
with with
[shelltestrunner](http://hackage.haskell.org/package/shelltestrunner). [shelltestrunner](http://hackage.haskell.org/package/shelltestrunner).
Tests are defined in files under Tests are defined in files named `*.test` under
[tests/](https://github.com/simonmichael/hledger/tree/master/tests), [hledger/test/](https://github.com/simonmichael/hledger/tree/master/hledger/test),
grouped by *component* (command or topic name). grouped by *component* (command or topic name).
For more about these, see the README there. For more about these, see the README there.
@ -1418,9 +1418,8 @@ Times the end-user commands in `bench.sh` using quickbench.
### Run functional tests ### Run functional tests
Runs the shelltestrunner tests defined in tests/, which test the hledger CLI. Runs the shelltestrunner tests defined in hledger/test/, which test the hledger CLI.
stack build hledger
make functest make functest
### Run haddock tests ### Run haddock tests
@ -1559,4 +1558,4 @@ If you find that adding --fast makes this any faster, please update this.
#### Rerun a single functional test as you change it: #### Rerun a single functional test as you change it:
ls tests/budget/budget.test | entr bash -c 'clear; COLUMNS=80 stack exec -- shelltest --execdir tests/budget/budget.test -i12' ls hledger/test/budget/budget.test | entr bash -c 'clear; COLUMNS=80 stack exec -- shelltest --execdir hledger/test/budget/budget.test -i12'

View File

@ -483,32 +483,32 @@ unittest: $(call def-help,unittest, run the unit tests in hledger-lib )
builtintest: $(call def-help,builtintest, run hledgers built in test command) builtintest: $(call def-help,builtintest, run hledgers built in test command)
@($(STACK) exec hledger test && echo $@ PASSED) || (echo $@ FAILED; false) @($(STACK) exec hledger test && echo $@ PASSED) || (echo $@ FAILED; false)
#functest: addons tests/addons/hledger-addon #functest: addons hledger/test/addons/hledger-addon
functest: tests/addons/hledger-addon \ functest: hledger/test/addons/hledger-addon \
$(call def-help,functest, build hledger quickly and run the functional tests (and some unit tests) ) $(call def-help,functest, build hledger quickly and run the functional tests (and some unit tests) )
@$(STACK) build --fast hledger @$(STACK) build --fast hledger
@($(SHELLTESTSTK) -w `$(STACK) exec -- which hledger` tests \ @($(SHELLTESTSTK) -w `$(STACK) exec -- which hledger` hledger/test/ \
&& echo $@ PASSED) || (echo $@ FAILED; false) && echo $@ PASSED) || (echo $@ FAILED; false)
functest-%: tests/addons/hledger-addon \ functest-%: hledger/test/addons/hledger-addon \
$(call def-help,functest-PAT, build hledger quickly and run just the functional tests matching PAT ) $(call def-help,functest-PAT, build hledger quickly and run just the functional tests matching PAT )
@stack build --fast hledger @stack build --fast hledger
@($(SHELLTESTSTK) -w `stack exec -- which hledger` tests -i "$*" \ @($(SHELLTESTSTK) -w `stack exec -- which hledger` hledger/test/ -i "$*" \
&& echo $@ PASSED) || (echo $@ FAILED; false) && echo $@ PASSED) || (echo $@ FAILED; false)
ADDONEXTS=pl py rb sh hs lhs rkt exe com bat ADDONEXTS=pl py rb sh hs lhs rkt exe com bat
tests/addons/hledger-addon: \ hledger/test/addons/hledger-addon: \
$(call def-help,tests/addons/hledger-addon,\ $(call def-help,hledger/test/addons/hledger-addon,\
generate dummy add-ons for testing (hledger-addon the rest)\ generate dummy add-ons for testing (hledger-addon the rest)\
) )
rm -rf tests/addons/hledger-* rm -rf hledger/test/addons/hledger-*
printf '#!/bin/sh\necho add-on: $$0\necho args: $$*\n' >tests/addons/hledger-addon printf '#!/bin/sh\necho add-on: $$0\necho args: $$*\n' >hledger/test/addons/hledger-addon
for E in '' $(ADDONEXTS); do \ for E in '' $(ADDONEXTS); do \
cp tests/addons/hledger-addon tests/addons/hledger-addon.$$E; done cp hledger/test/addons/hledger-addon hledger/test/addons/hledger-addon.$$E; done
for F in addon. addon2 addon2.hs addon3.exe addon3.lhs addon4.exe add reg; do \ for F in addon. addon2 addon2.hs addon3.exe addon3.lhs addon4.exe add reg; do \
cp tests/addons/hledger-addon tests/addons/hledger-$$F; done cp hledger/test/addons/hledger-addon hledger/test/addons/hledger-$$F; done
mkdir tests/addons/hledger-addondir mkdir hledger/test/addons/hledger-addondir
chmod +x tests/addons/hledger-* chmod +x hledger/test/addons/hledger-*
# hlinttest hlint: $(call def-help,hlinttest (or hlint),generate a hlint report) # hlinttest hlint: $(call def-help,hlinttest (or hlint),generate a hlint report)
# hlint --hint=hlint --report=hlint.html $(SOURCEFILES) # hlint --hint=hlint --report=hlint.html $(SOURCEFILES)

View File

@ -1,4 +1,4 @@
; A sample journal for testing multi-column balance report. See tests/balance-multicol.test. ; A sample journal for testing multi-column balance report. See hledger/test/r/test/balance-multicol.test.
2012/12/31 2012/12/31
(assets:checking) 10 (assets:checking) 10

View File

@ -980,7 +980,7 @@ getAmount :: CsvRules -> CsvRecord -> String -> Bool -> Int -> Maybe MixedAmount
getAmount rules record currency p1IsVirtual n = getAmount rules record currency p1IsVirtual n =
-- Warning, many tricky corner cases here. -- Warning, many tricky corner cases here.
-- docs: hledger_csv.m4.md #### amount -- docs: hledger_csv.m4.md #### amount
-- tests: tests/csv.test ~ 13, 31-34 -- tests: hledger/test/csv.test ~ 13, 31-34
let let
unnumberedfieldnames = ["amount","amount-in","amount-out"] unnumberedfieldnames = ["amount","amount-in","amount-out"]

View File

@ -6,7 +6,7 @@
# capture its output. # capture its output.
# * Or, all output from inputs hard-coded below. # * Or, all output from inputs hard-coded below.
# #
# Here's some sample output for "tests/hledgeruicapture -f examples/sample.journal" # Here's some sample output for "test/hledgeruicapture -f examples/sample.journal"
# showing the initial output (accounts screen) then the outputs from four inputs: # showing the initial output (accounts screen) then the outputs from four inputs:
# RIGHT (draws register screen) # RIGHT (draws register screen)
# UP (moves selection up one row; only the heading and old/new rows are redrawn) # UP (moves selection up one row; only the heading and old/new rows are redrawn)

View File

@ -46,7 +46,7 @@ closemode = hledgerCommandMode
([], Just $ argsFlag "[QUERY]") ([], Just $ argsFlag "[QUERY]")
-- debugger, beware: close is incredibly devious. simple rules combine to make a horrid maze. -- debugger, beware: close is incredibly devious. simple rules combine to make a horrid maze.
-- tests are in tests/close.test. -- tests are in hledger/test/close.test.
close CliOpts{rawopts_=rawopts, reportspec_=rspec} j = do close CliOpts{rawopts_=rawopts, reportspec_=rspec} j = do
today <- getCurrentDay today <- getCurrentDay
let let

View File

@ -1,11 +1,19 @@
hledger's functional tests. hledger test-related files. See also [Contributor Guide: Tests].
See also [Contributor Guide: Tests].
These mainly test the hledger CLI and (indirectly) hledger-lib. unittest.hs - main file for a cabal test suite in the hledger package
(run by "cabal test" or "stack test"). Runs the unit tests built in to
all hledger modules. Not used much, we usually run them via hledger's
builtin "test" command instead.
doctest.hs - main file for another cabal test suite. Runs the doctests
embedded in haddock comments in some hledger modules.
The rest of the files here are functional tests, run with [shelltestrunner].
These test the hledger CLI and (indirectly) the hledger-lib package.
They are organised roughly by [component]. They are organised roughly by [component].
Running these requires [shelltestrunner]. Older test files are in shelltestrunner's [format 1];
Older test files are in [format 1]; newer ones use [format 3] (preferred). newer ones use [format 3] (preferred).
Some tests invoke unix commands so will not run in a Windows CMD shell. Some tests invoke unix commands so will not run in a Windows CMD shell.
[Contributor Guide: Tests]: https://hledger.org/CONTRIBUTING.html#tests [Contributor Guide: Tests]: https://hledger.org/CONTRIBUTING.html#tests
@ -36,7 +44,7 @@ These are the most important:
Run only the tests matching a regular expression: Run only the tests matching a regular expression:
$ COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` tests -i balance-assertions.*19 $ COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` tests -i balance-assertions.*19
:tests/journal/balance-assertions.test:19: [OK] :hledger/test/journal/balance-assertions.test:19: [OK]
Test Cases Total Test Cases Total
Passed 1 1 Passed 1 1
@ -45,10 +53,10 @@ Run only the tests matching a regular expression:
Run only the tests in one file: Run only the tests in one file:
$ COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` tests/cli/query-args.test $ COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` hledger/test/cli/query-args.test
:tests/cli/query-args.test:1: [OK] :hledger/test/cli/query-args.test:1: [OK]
:tests/cli/query-args.test:2: [OK] :hledger/test/cli/query-args.test:2: [OK]
:tests/cli/query-args.test:3: [OK] :hledger/test/cli/query-args.test:3: [OK]
Test Cases Total Test Cases Total
Passed 3 3 Passed 3 3
@ -57,14 +65,14 @@ Run only the tests in one file:
Run a test [repeatedly](http://eradman.com/entrproject/) as its file is changed: Run a test [repeatedly](http://eradman.com/entrproject/) as its file is changed:
$ ls tests/cli/query-args.test | entr bash -c "COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` tests/cli/query-args.test -i1" $ ls hledger/test/cli/query-args.test | entr bash -c "COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` hledger/test/cli/query-args.test -i1"
:tests/cli/query-args.test:1: [OK] :hledger/test/cli/query-args.test:1: [OK]
Test Cases Total Test Cases Total
Passed 1 1 Passed 1 1
Failed 0 0 Failed 0 0
Total 1 1 Total 1 1
:tests/cli/query-args.test:1: [OK] :hledger/test/cli/query-args.test:1: [OK]
Test Cases Total Test Cases Total
Passed 1 1 Passed 1 1

View File

@ -0,0 +1 @@
../../../examples/balance-multicol.journal

View File

@ -0,0 +1 @@
../../../examples/bcexample.hledger

View File

@ -0,0 +1 @@
../../../examples/sample.journal

View File

@ -0,0 +1 @@
../../../examples/alias.journal

View File

@ -0,0 +1 @@
../../../examples/business.journal

View File

@ -0,0 +1 @@
../../../examples/personal.journal

View File

@ -0,0 +1 @@
../../../examples/chinese.journal

View File

@ -0,0 +1 @@
../../../examples/status.journal

Some files were not shown because too many files have changed in this diff Show More