This commit is contained in:
Ryan Desfosses 2014-05-07 19:46:37 -04:00
commit f5d2d9b766
64 changed files with 121 additions and 195 deletions

View File

@ -396,11 +396,23 @@ unittest-interpreted:
# run functional tests, requires shelltestrunner >= 0.9 from hackage # run functional tests, requires shelltestrunner >= 0.9 from hackage
# 16 threads sometimes gives "commitAndReleaseBuffer: resource vanished (Broken pipe)" here but seems harmless # 16 threads sometimes gives "commitAndReleaseBuffer: resource vanished (Broken pipe)" here but seems harmless
functest: bin/hledgerdev functest: bin/hledgerdev tests/addons/hledger-addon
@echo functional tests: @echo functional tests:
@($(SHELLTEST) tests -- --threads=16 --hide-successes \ @($(SHELLTEST) --execdir tests -- --threads=16 --hide-successes \
&& echo $@ PASSED) || echo $@ FAILED && echo $@ PASSED) || echo $@ FAILED
# generate dummy add-ons for testing (hledger-addon the rest)
ADDONEXTS=pl py rb sh hs lhs rkt exe com bat
tests/addons/hledger-addon:
rm -rf tests/addons/hledger-*
printf '#!/bin/sh\necho add-on: $$0\necho args: $$*\n' >tests/ADDONS/hledger-addon
for E in '' $(ADDONEXTS); do \
cp tests/ADDONS/hledger-addon tests/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-*
# run unit and functional tests with a specific GHC version # run unit and functional tests with a specific GHC version
# some functional tests (add, include, read-csv..) have bin/hledgerdev hard coded - might need to symlink it # some functional tests (add, include, read-csv..) have bin/hledgerdev hard coded - might need to symlink it
test-ghc-%: # bin/hledgerdev.ghc-$* test-ghc-%: # bin/hledgerdev.ghc-$*
@ -558,18 +570,6 @@ data/10000x10000x10.journal: tools/generatejournal
data/100000x1000x10.journal: tools/generatejournal data/100000x1000x10.journal: tools/generatejournal
tools/generatejournal 100000 1000 10 >$@ tools/generatejournal 100000 1000 10 >$@
ADDONS=tests/addons
ADDONEXTS=pl py rb sh hs lhs rkt exe com bat
addons:
rm -rf $(ADDONS)/hledger-*
printf '#!/bin/sh\necho $$0\n' >$(ADDONS)/hledger-addon
for E in '' $(ADDONEXTS); do \
cp $(ADDONS)/hledger-addon $(ADDONS)/hledger-addon.$$E; done
for F in addon. addon2 addon2.hs addon3.exe addon3.lhs addon4.exe add reg; do \
cp $(ADDONS)/hledger-addon $(ADDONS)/hledger-$$F; done
mkdir $(ADDONS)/hledger-addondir
chmod +x $(ADDONS)/hledger-*
###################################################################### ######################################################################
# DOCUMENTATION # DOCUMENTATION

26
doc/ANNOUNCE Normal file
View File

@ -0,0 +1,26 @@
I'm pleased to announce hledger and hledger-web 0.23!
This release includes command-line fixes and polish, a new accounts
command, and a number of changes to the balance command relating
to --depth, --flat, and multicolumn mode, which I find has made it much
more useful. Release notes:
http://hledger.org/release-notes#hledger-023-201451 .
Contributors to this release: Peter Simons and Marko Kocić.
hledger (http://hledger.org) is a command-line tool and haskell library
for tracking financial transactions, which are stored in a human-readable
plain text format. It can also read CSV or timelog files. It provides useful
reports, and can also help you record new transactions interactively.
Add-on commands include hledger-web (a web interface),
hledger-irr (for calculating internal rate of return) and hledger-interest
(for generating interest transactions). hledger is inspired by and largely
compatible with Ledger.
Installation:
cabal update; cabal install hledger [hledger-web]
(see http://hledger.org/installing for help)
or sponsor a binary at http://hledger.org/download
Best!
-Simon

View File

@ -1,28 +0,0 @@
I have released hledger and hledger-web 0.22.
hledger is a command-line tool and haskell library for tracking
financial transactions, which are stored in a human-readable plain
text format. In addition to reporting, it can also help you record new
transactions, or convert CSV data from your bank. Add-on packages
include hledger-web (providing a web interface), hledger-irr and
hledger-interest. hledger is inspired by and largely compatible with
Ledger. For more, see http://hledger.org .
Install it:
cabal update; cabal install hledger [hledger-web]
For more installation help, see http://hledger.org/MANUAL.html#installing .
Or, sponsor a ready-to-run binary for your platform: http://hledger.org/download
Release notes (http://hledger.org/release-notes#hledger-0.XX):
PREAMBLE
...
**Release contributors:**
...
POSTAMBLE

View File

@ -81,9 +81,10 @@ posting = nullposting
post :: AccountName -> Amount -> Posting post :: AccountName -> Amount -> Posting
post acct amt = posting {paccount=acct, pamount=mixed amt} post acct amt = posting {paccount=acct, pamount=mixed amt}
-- XXX once rendered user output, but just for debugging now; clean up
showPosting :: Posting -> String showPosting :: Posting -> String
showPosting p@Posting{paccount=a,pamount=amt,ptype=t} = showPosting p@Posting{paccount=a,pamount=amt,ptype=t} =
unlines $ [concatTopPadded [showaccountname a ++ " ", showamount amt, showComment (pcomment p)]] unlines $ [concatTopPadded [show (postingDate p) ++ " ", showaccountname a ++ " ", showamount amt, showComment (pcomment p)]]
where where
ledger3ishlayout = False ledger3ishlayout = False
acctnamewidth = if ledger3ishlayout then 25 else 22 acctnamewidth = if ledger3ishlayout then 25 else 22

View File

@ -122,7 +122,7 @@ tests_showTransactionUnelided = [
] ]
] ]
-- XXX overlaps showPosting -- cf showPosting
showTransaction' :: Bool -> Transaction -> String showTransaction' :: Bool -> Transaction -> String
showTransaction' elide t = showTransaction' elide t =
unlines $ [descriptionline] unlines $ [descriptionline]

View File

@ -66,7 +66,7 @@ postingsReport opts q j = (totallabel, items)
dbg "ps3" $ (if related_ opts then concatMap relatedPostings else id) $ -- with -r, replace each with its sibling postings dbg "ps3" $ (if related_ opts then concatMap relatedPostings else id) $ -- with -r, replace each with its sibling postings
dbg "ps2" $ filter (reportq `matchesPosting`) $ -- filter postings by the query, including before the report start date, ignoring depth dbg "ps2" $ filter (reportq `matchesPosting`) $ -- filter postings by the query, including before the report start date, ignoring depth
dbg "ps1" $ journalPostings $ journalSelectingAmountFromOpts opts j dbg "ps1" $ journalPostings $ journalSelectingAmountFromOpts opts j
(precedingps, reportps) = dbg "precedingps, reportps" $ span (beforestartq `matchesPosting`) pstoend (precedingps, reportps) = dbg "precedingps, reportps" $ partition (beforestartq `matchesPosting`) pstoend
empty = queryEmpty q empty = queryEmpty q
-- displayexpr = display_ opts -- XXX -- displayexpr = display_ opts -- XXX

View File

@ -86,22 +86,7 @@ b
>>> /a +\$1000\.00/ >>> /a +\$1000\.00/
>>>=0 >>>=0
# 8. no commodity entered, the (most recent) default commodity should be applied # 8. default amounts should not fail to balance due to precision
# (and a non-ascii commodity symbol should work)
printf 'D $1000.0\nD £1,000.00\n' >t$$.j; hledgerdev -f t$$.j add; cat t$$.j; rm -f t$$.j
<<<
2010/1/1
a
1000
b
.
>>> /a +£1,000.00/
>>>=0
# 9. default amounts should not fail to balance due to precision
rm -f nosuch.journal; hledgerdev -f nosuch.journal add; rm -f nosuch.journal rm -f nosuch.journal; hledgerdev -f nosuch.journal add; rm -f nosuch.journal
<<< <<<
2010/1/1 2010/1/1
@ -114,7 +99,7 @@ c
>>> /Amount 3 \[-0.75\]:/ >>> /Amount 3 \[-0.75\]:/
>>>=0 >>>=0
## 10. shouldn't add decimals if there aren't any ## 9. shouldn't add decimals if there aren't any
## printf '\n\na\n1\nb\n' | hledgerdev -f /dev/null add ## printf '\n\na\n1\nb\n' | hledgerdev -f /dev/null add
# hledgerdev -f /dev/null add # hledgerdev -f /dev/null add
# <<< # <<<

View File

@ -1 +0,0 @@
Add-on scripts to test add-on detection (when this directory is added to PATH).

17
tests/addons/addons.test Normal file
View File

@ -0,0 +1,17 @@
# "make test" sets up the dummy add-on scripts required for these tests
# 14. flags after an add-command are handled by the add-on
PATH=$PATH:. hledgerdev addon --help
>>> /hledger-addon/
>>>=0
# 15. add-on flags which are not also defined in the main executable are a problem
PATH=$PATH:. hledgerdev addon --addonflag
>>>2 /Unknown flag: --addonflag/
>>>=1
# 16. hledger main executable ignores anything after -- (and hides the -- from the add-on)
PATH=$PATH:. hledgerdev addon --help -- --addonflag
>>> /hledger-addon/
>>>=0

View File

@ -1,5 +1,5 @@
# 1. # 1.
hledgerdev -f data/sample.journal balance hledgerdev -f sample.journal balance
>>> >>>
$-1 assets $-1 assets
$1 bank:saving $1 bank:saving
@ -16,7 +16,7 @@ hledgerdev -f data/sample.journal balance
>>>=0 >>>=0
# 2. # 2.
hledgerdev -f data/sample.journal balance o hledgerdev -f sample.journal balance o
>>> >>>
$1 expenses:food $1 expenses:food
$-2 income $-2 income

View File

@ -1,5 +1,5 @@
# 1 # 1
hledgerdev -f data/sample.journal balance --no-total --depth 1 hledgerdev -f sample.journal balance --no-total --depth 1
>>> >>>
$-1 assets $-1 assets
$2 expenses $2 expenses

View File

@ -1,4 +1,4 @@
hledgerdev -f data/sample.journal balance --format="%30(account) %-.20(total)" hledgerdev -f sample.journal balance --format="%30(account) %-.20(total)"
>>> >>>
assets $-1 assets $-1
bank:saving $1 bank:saving $1

View File

@ -1,7 +1,7 @@
# multi-column balance reports # multi-column balance reports
# 1. Here are the postings used in most tests below: # 1. Here are the postings used in most tests below:
hledgerdev -f data/balance-multicol.journal register hledgerdev -f balance-multicol.journal register
>>> >>>
2012/12/31 (assets:checking) 10 10 2012/12/31 (assets:checking) 10 10
2013/01/01 (assets:checking) 1 11 2013/01/01 (assets:checking) 1 11
@ -12,7 +12,7 @@ hledgerdev -f data/balance-multicol.journal register
>>>=0 >>>=0
# 2. A period balance (flow) report. --no-total also works but isn't pretty. # 2. A period balance (flow) report. --no-total also works but isn't pretty.
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --no-total hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --no-total
>>> >>>
Change of balance (flow): Change of balance (flow):
@ -27,7 +27,7 @@ Change of balance (flow):
>>>=0 >>>=0
# 3. With --empty, includes leading/trailing empty periods # 3. With --empty, includes leading/trailing empty periods
#hledgerdev -f data/balance-multicol.journal balance -p 'quarterly in 2013' --empty #hledgerdev -f balance-multicol.journal balance -p 'quarterly in 2013' --empty
hledgerdev -f - balance -p 'quarterly in 2013' --empty hledgerdev -f - balance -p 'quarterly in 2013' --empty
<<< <<<
2012/12/31 2012/12/31
@ -49,7 +49,7 @@ Change of balance (flow):
# 4. A cumulative ending balance report. Column totals are the sum of # 4. A cumulative ending balance report. Column totals are the sum of
# the highest-level displayed accounts (here, assets). # the highest-level displayed accounts (here, assets).
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --cumulative hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --cumulative
>>> >>>
Ending balance (cumulative): Ending balance (cumulative):
@ -66,7 +66,7 @@ Ending balance (cumulative):
# 5. With the assets:cash account excluded. As with a single-column # 5. With the assets:cash account excluded. As with a single-column
# balance --flat report, or ledger's balance --flat, assets' balance # balance --flat report, or ledger's balance --flat, assets' balance
# includes the displayed subaccount and not the excluded one. # includes the displayed subaccount and not the excluded one.
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --cumulative not:cash hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --cumulative not:cash
>>> >>>
Ending balance (cumulative): Ending balance (cumulative):
@ -80,7 +80,7 @@ Ending balance (cumulative):
>>>=0 >>>=0
# 6. A historical ending balance report. # 6. A historical ending balance report.
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --historical hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --historical
>>> >>>
Ending balance (historical): Ending balance (historical):
@ -96,7 +96,7 @@ Ending balance (historical):
# 7. With top-level accounts excluded. As always, column totals are the sum of # 7. With top-level accounts excluded. As always, column totals are the sum of
# the highest-level displayed accounts, now assets:cash and assets:checking. # the highest-level displayed accounts, now assets:cash and assets:checking.
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' not:assets$ hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' not:assets$
>>> >>>
Change of balance (flow): Change of balance (flow):
@ -110,7 +110,7 @@ Change of balance (flow):
>>>=0 >>>=0
# 8. cumulative: # 8. cumulative:
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' not:assets$ --cumulative hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' not:assets$ --cumulative
>>> >>>
Ending balance (cumulative): Ending balance (cumulative):
@ -124,7 +124,7 @@ Ending balance (cumulative):
>>>=0 >>>=0
# 9. historical # 9. historical
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --historical hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --historical
>>> >>>
Ending balance (historical): Ending balance (historical):
@ -141,7 +141,7 @@ Ending balance (historical):
# --depth # --depth
# 10. A flow report with depth limiting. The depth limit aggregates the three accounts as "assets". # 10. A flow report with depth limiting. The depth limit aggregates the three accounts as "assets".
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --depth 1 hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --depth 1
>>> >>>
Change of balance (flow): Change of balance (flow):
@ -154,7 +154,7 @@ Change of balance (flow):
>>>=0 >>>=0
# 11. As above, but postings in the top-level assets account have been excluded. # 11. As above, but postings in the top-level assets account have been excluded.
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --depth 1 assets: hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --depth 1 assets:
>>> >>>
Change of balance (flow): Change of balance (flow):
@ -167,7 +167,7 @@ Change of balance (flow):
>>>=0 >>>=0
# 12. A cumulative balance report with depth limiting. # 12. A cumulative balance report with depth limiting.
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --depth 1 --cumulative hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --depth 1 --cumulative
>>> >>>
Ending balance (cumulative): Ending balance (cumulative):
@ -180,7 +180,7 @@ Ending balance (cumulative):
>>>=0 >>>=0
# 13. A historical balance report with depth limiting. # 13. A historical balance report with depth limiting.
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --depth 1 --historical hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --depth 1 --historical
>>> >>>
Ending balance (historical): Ending balance (historical):
@ -193,7 +193,7 @@ Ending balance (historical):
>>>=0 >>>=0
# 14. The three multicol balance report types again, this time with --tree # 14. The three multicol balance report types again, this time with --tree
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --tree hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --tree
>>> >>>
Change of balance (flow): Change of balance (flow):
@ -208,7 +208,7 @@ Change of balance (flow):
>>>=0 >>>=0
# 15. # 15.
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --cumulative --tree hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --cumulative --tree
>>> >>>
Ending balance (cumulative): Ending balance (cumulative):
@ -223,7 +223,7 @@ Ending balance (cumulative):
>>>=0 >>>=0
# 16. # 16.
hledgerdev -f data/balance-multicol.journal balance -p 'monthly in 2013' --historical --tree hledgerdev -f balance-multicol.journal balance -p 'monthly in 2013' --historical --tree
>>> >>>
Ending balance (historical): Ending balance (historical):

View File

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

View File

@ -131,20 +131,3 @@ hledgerdev register -f/dev/null --alias=somealiases --rules-file -? -h --help --
>>> /^register \[OPTIONS\]/ >>> /^register \[OPTIONS\]/
>>>=0 >>>=0
# do "make addons" to set up for these:
# 14. flags after an add-command are handled by the add-on
PATH=$PATH:tests/addons hledgerdev addon --help
>>> /hledger-addon/
>>>=0
# 15. add-on flags which are not also defined in the main executable are a problem
PATH=$PATH:tests/addons hledgerdev addon --addonflag
>>>2 /Unknown flag: --addonflag/
>>>=1
# 16. hledger main executable ignores anything after -- (and hides the -- from the add-on)
PATH=$PATH:tests/addons hledgerdev addon --help -- --addonflag
>>> /hledger-addon/
>>>=0

View File

@ -1,10 +0,0 @@
# b amount with no decimal places, in middle, causes balance failure (0.6.1)
hledgerdev -f - print
<<<
2009/1/1 x
a $1.25
b $-1
c $-0.25
>>>2
>>>=0

View File

@ -1,9 +0,0 @@
hledgerdev -f- print
<<<
2009/1/1 x
aaaaaaaaaaaaaaaaaaaa:aaaaaaaaaaaaaaaaaaaa:aaaaaaaaaaaaaaaaaaaa €1
b
>>>
2009/01/01 x
aa:aaaaaaaaaa:aaaaaaaaaaaaaaaaaaaa
b

View File

@ -1,7 +0,0 @@
hledgerdev -f- register
<<<
2009/1/1 x aaaaaaaaaaaaaaaaaaaa:aaaaaaaaaaaaaaaaaaaa:aaaaaaaaaaaaaaaaaaaa €1
b
>>>
2009/01/01 x aa:aa:aaaaaaaaaaaaaaaa €1 €1
b €-1 0

View File

@ -46,7 +46,21 @@ hledgerdev -f - balance
0 0
>>>=0 >>>=0
# 4. mixed amounts with prices # 4. a zero amount is always displayed as just "0", regardless of any commodity/decimal places/price (like ledger)
#
hledgerdev -f- print --empty
<<<
2010/3/1 x
a $0.00 @ 3EUR
b
>>>
2010/03/01 x
a 0
b 0
>>>=0
# 5. mixed amounts with prices
# XXX # XXX
# hledgerdev -f - print # hledgerdev -f - print
# <<< # <<<

View File

@ -1,7 +0,0 @@
# hledgerdev -f - balance -E
# <<<
# 2009/1/1 x
# a: 13
# b
# >>>2 /accountname seems ill-formed: a:/
# >>>= 1

View File

@ -1,13 +0,0 @@
# should give an accurate parse error location
# hledgerdev -f- stat
# <<<
# 2010/1/1 x
# a 1
# b
# 2010/1/1 y
# c: 1
# d
# >>>2 /line 6, column 5/
# >>>= 1

View File

@ -1,13 +0,0 @@
# this gave a stack space overflow error with 0.8-0.9 due to infinite
# recursion in Posting and Transaction's equality tests:
hledgerdev -f - balance
<<<
i 2010/1/1 09:00:00 a:b
o 2010/1/1 09:03:00
>>>=0
# incidentally this didn't trigger it.. go figure
#hledgerdev -f - balance
#<<<
#i 2010/1/1 09:00:00 a:b
#o 2010/1/1 09:02:00
#>>>=0

View File

@ -0,0 +1,22 @@
# timezone-related tests
# 1. as in ledger, historical prices may contain a time and timezone.
# hledger ignores them and uses 00:00 local time instead.
# XXX needs --value not --cost
hledgerdev -f - balance --no-total --cost
<<<
P 2011/01/01 00:00:00 A $1
P 2011/01/01 15:00:00-0100 A $2
2010/12/31
(20101231) 1 A
2011/1/1
(20110101) 1 A
2011/1/2
(20110102) 1 A
>>>
1 A 20101231
$2 20110101
$2 20110102
>>>=0

View File

@ -1,22 +0,0 @@
# timezone-related tests
# 1. as in ledger, historical prices may contain a time and timezone.
# hledger ignores them and uses 00:00 local time instead.
# XXX needs --value not --cost
# hledgerdev -f - balance --no-total --cost
# <<<
# P 2011/01/01 00:00:00 A $1
# P 2011/01/01 15:00:00-0100 A $2
# 2010/12/31
# (20101231) 1 A
# 2011/1/1
# (20110101) 1 A
# 2011/1/2
# (20110102) 1 A
# >>>
# 1 A 20101231
# $2 20110101
# $2 20110102
# >>>=0

View File

@ -1,13 +0,0 @@
# a zero amount is always displayed as just "0", regardless of any commodity/decimal places/price (like ledger)
#
hledgerdev -f- print --empty
<<<
2010/3/1 x
a $0.00 @ 3EUR
b
>>>
2010/03/01 x
a 0
b 0
>>>=0