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=site/doc
--exclude=site/files
--exclude=tests/addons/hledger-*
--exclude=hledger/test/addons/hledger-*

View File

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

View File

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

View File

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

View File

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

2
.gitignore vendored
View File

@ -71,7 +71,7 @@ old
!/bin/*.md
/.latest.*
test.hs
tests/addons/hledger-*
hledger/test/addons/hledger-*
tools/generatejournal
tools/simplebench
/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
with
[shelltestrunner](http://hackage.haskell.org/package/shelltestrunner).
Tests are defined in files under
[tests/](https://github.com/simonmichael/hledger/tree/master/tests),
Tests are defined in files named `*.test` under
[hledger/test/](https://github.com/simonmichael/hledger/tree/master/hledger/test),
grouped by *component* (command or topic name).
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
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
### 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:
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)
@($(STACK) exec hledger test && echo $@ PASSED) || (echo $@ FAILED; false)
#functest: addons tests/addons/hledger-addon
functest: tests/addons/hledger-addon \
#functest: addons hledger/test/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) )
@$(STACK) build --fast hledger
@($(SHELLTESTSTK) -w `$(STACK) exec -- which hledger` tests \
@($(SHELLTESTSTK) -w `$(STACK) exec -- which hledger` hledger/test/ \
&& 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 )
@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)
ADDONEXTS=pl py rb sh hs lhs rkt exe com bat
tests/addons/hledger-addon: \
$(call def-help,tests/addons/hledger-addon,\
hledger/test/addons/hledger-addon: \
$(call def-help,hledger/test/addons/hledger-addon,\
generate dummy add-ons for testing (hledger-addon the rest)\
)
rm -rf tests/addons/hledger-*
printf '#!/bin/sh\necho add-on: $$0\necho args: $$*\n' >tests/addons/hledger-addon
rm -rf hledger/test/addons/hledger-*
printf '#!/bin/sh\necho add-on: $$0\necho args: $$*\n' >hledger/test/addons/hledger-addon
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 \
cp tests/addons/hledger-addon tests/addons/hledger-$$F; done
mkdir tests/addons/hledger-addondir
chmod +x tests/addons/hledger-*
cp hledger/test/addons/hledger-addon hledger/test/addons/hledger-$$F; done
mkdir hledger/test/addons/hledger-addondir
chmod +x hledger/test/addons/hledger-*
# hlinttest hlint: $(call def-help,hlinttest (or hlint),generate a hlint report)
# 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
(assets:checking) 10

View File

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

View File

@ -6,7 +6,7 @@
# capture its output.
# * 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:
# RIGHT (draws register screen)
# 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]")
-- 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
today <- getCurrentDay
let

View File

@ -1,11 +1,19 @@
hledger's functional tests.
See also [Contributor Guide: Tests].
hledger test-related files. 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].
Running these requires [shelltestrunner].
Older test files are in [format 1]; newer ones use [format 3] (preferred).
Older test files are in shelltestrunner's [format 1];
newer ones use [format 3] (preferred).
Some tests invoke unix commands so will not run in a Windows CMD shell.
[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:
$ 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
Passed 1 1
@ -45,10 +53,10 @@ Run only the tests matching a regular expression:
Run only the tests in one file:
$ COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` tests/cli/query-args.test
:tests/cli/query-args.test:1: [OK]
:tests/cli/query-args.test:2: [OK]
:tests/cli/query-args.test:3: [OK]
$ COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` hledger/test/cli/query-args.test
:hledger/test/cli/query-args.test:1: [OK]
:hledger/test/cli/query-args.test:2: [OK]
:hledger/test/cli/query-args.test:3: [OK]
Test Cases Total
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:
$ ls tests/cli/query-args.test | entr bash -c "COLUMNS=80 shelltest --execdir -w `stack exec -- which hledger` tests/cli/query-args.test -i1"
:tests/cli/query-args.test:1: [OK]
$ 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"
:hledger/test/cli/query-args.test:1: [OK]
Test Cases Total
Passed 1 1
Failed 0 0
Total 1 1
:tests/cli/query-args.test:1: [OK]
:hledger/test/cli/query-args.test:1: [OK]
Test Cases Total
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