fix: journal: parse include directives with trailing whitespace
[https://github.com/adept/full-fledged-hledger/issues/29]
This commit is contained in:
parent
89de1ae764
commit
490a46fcd2
@ -291,7 +291,7 @@ includedirectivep :: MonadIO m => ErroringJournalParser m ()
|
||||
includedirectivep = do
|
||||
string "include"
|
||||
lift skipNonNewlineSpaces1
|
||||
prefixedglob <- T.unpack <$> takeWhileP Nothing (/= '\n') -- don't consume newline yet
|
||||
prefixedglob <- rstrip . T.unpack <$> takeWhileP Nothing (/= '\n') -- don't consume newline yet
|
||||
parentoff <- getOffset
|
||||
parentpos <- getSourcePos
|
||||
let (mprefix,glb) = splitReaderPrefix prefixedglob
|
||||
|
||||
@ -54,14 +54,19 @@ $ hledger -f - print
|
||||
>2 //
|
||||
>= 1
|
||||
|
||||
# ** 5. include nonexsitant file
|
||||
# ** 5. include nonexistent file
|
||||
<
|
||||
include doesnotexist.journal
|
||||
$ hledger -f - print
|
||||
>2 //
|
||||
>= 1
|
||||
|
||||
# ** 6. include relative to home
|
||||
# ** 6. trailing whitespace after the filename does not make a file nonexistent
|
||||
<
|
||||
include a.timeclock
|
||||
$ hledger -f - check
|
||||
|
||||
# ** 7. 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
|
||||
@ -73,17 +78,17 @@ $ printf '2018/01/01\n (A) 1\n' >included.journal; HOME="$PWD" hledger -f - pr
|
||||
# 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
|
||||
# ** 8. test that order of include files is maintained
|
||||
$ printf 'include _b\n' >_a; touch _b; hledger -f _a stats -v | grep _ | sed -e 's%.*/%%'; rm -rf _a _b
|
||||
_a
|
||||
_b
|
||||
|
||||
# ** 8. and with --auto code path
|
||||
# ** 9. and with --auto code path
|
||||
$ printf 'include _d\n=\n' >_c; touch _d; hledger -f _c stats -v --auto | grep _ | sed -e 's%.*/%%'; rm -rf _c _d
|
||||
_c
|
||||
_d
|
||||
|
||||
# ** 9. include using old !include directive
|
||||
# ** 10. 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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user