hledger/hledger/test/journal/include.test
Simon Michael e9cd1df048 dev: tests: convert remaining format 1 tests to format 3 (or 2)
Mostly done with an unreleased version of shelltestrunner, plus a few manual fixups.
2023-02-16 11:55:15 -10:00

92 lines
2.0 KiB
Plaintext

# 1. nested includes in subdirectories
$ mkdir -p b/c/d ; printf '2010/1/1\n (D) 1\n' >b/c/d/d.journal ; printf '2010/1/1\n (C) 1\ninclude d/d.journal\n' >b/c/c.journal ; printf '2010/1/1\n (B) 1\ninclude c/c.journal\n' >b/b.journal ; printf '2010/1/1\n (A) 1\ninclude b/b.journal\n' >a.journal ; hledger -f a.journal print; rm -rf a.journal bG
2010-01-01
(A) 1
2010-01-01
(B) 1
2010-01-01
(C) 1
2010-01-01
(D) 1
>= 0
# 2. including other formats
<
2016/1/1
(x) 1
include a.timeclock
include b.timedot
$ hledger -f - print
2016-01-01
(x) 1.00
2016-01-01 * 12:00-16:00
(a:aa) 4.00h
2016-01-01 *
(b.bb) 1.00
>=
# 3. include glob patterns
<
include *b.journal
$ printf '2018/01/01\n (A) 1\n' >ab.journal; printf '2018/01/01\n (B) 1' >bb.journal; hledger -f - print; rm -f ab.journal bb.journal
2018-01-01
(A) 1
2018-01-01
(B) 1
>=
# 4. include invalid glob patterns
<
include [.journal
$ hledger -f - print
>2 //
>= 1
# 5. include nonexsitant file
<
include doesnotexist.journal
$ hledger -f - print
>2 //
>= 1
# 6. include relative to home
<
include ~/included.journal
$ printf '2018/01/01\n (A) 1\n' >included.journal; HOME="$PWD" hledger -f - print; rm -rf included.journal
2018-01-01
(A) 1
>= 0
# The next tests require hard coded file names, so are not concurrent-safe.
# They use different file names so a single concurrent shelltest invocation will be fine.
# 7. test that order of include files is maintained
$ printf 'include _b\n' >_a; touch _b; hledger -f _a stats | grep _ | sed -e 's%.*/%%'; rm -rf _a _b
_a
_b
# 8. and with --auto code path
$ printf 'include _d\n=\n' >_c; touch _d; hledger -f _c stats --auto | grep _ | sed -e 's%.*/%%'; rm -rf _c _d
_c
_d
# 9. include using old !include directive
<
!include f.journal
$ printf '2018/01/01\n (A) 1\n' >f.journal; hledger -f - print; rm -f f.journal
2018-01-01
(A) 1
>=