dev: errors: examples and tests of current CSV errors
This commit is contained in:
parent
d0a7154b4a
commit
f1e5d7aa30
5
hledger/test/errors/csvamountonenonzero.csv
Executable file
5
hledger/test/errors/csvamountonenonzero.csv
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env -S hledger print -f
|
||||||
|
# Non-zero for both amount-in and amount-out.
|
||||||
|
2022-01-01,1,
|
||||||
|
2022-01-02,1,0
|
||||||
|
2022-01-03,1,2
|
||||||
|
4
hledger/test/errors/csvamountonenonzero.csv.rules
Normal file
4
hledger/test/errors/csvamountonenonzero.csv.rules
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
skip 2
|
||||||
|
date %1
|
||||||
|
amount-in %2
|
||||||
|
amount-out %3
|
||||||
10
hledger/test/errors/csvamountonenonzero.test
Normal file
10
hledger/test/errors/csvamountonenonzero.test
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
$$$ hledger print -f csvamountonenonzero.csv
|
||||||
|
>>>2 /hledger: Error: multiple non-zero amounts assigned,
|
||||||
|
please ensure just one. \(https:\/\/hledger.org\/csv.html#amount\)
|
||||||
|
record values: "2022-01-03","1","2"
|
||||||
|
for posting: 1
|
||||||
|
assignment: amount-in %2 => value: 1
|
||||||
|
assignment: amount-out %3 => value: 2
|
||||||
|
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
5
hledger/test/errors/csvamountparse.csv
Executable file
5
hledger/test/errors/csvamountparse.csv
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env -S hledger print -f
|
||||||
|
# Unparseable amount.
|
||||||
|
2022-01-01,1
|
||||||
|
2022-01-02,$1
|
||||||
|
2022-01-03,badamount
|
||||||
|
3
hledger/test/errors/csvamountparse.csv.rules
Normal file
3
hledger/test/errors/csvamountparse.csv.rules
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
skip 2
|
||||||
|
date %1
|
||||||
|
amount %2
|
||||||
15
hledger/test/errors/csvamountparse.test
Normal file
15
hledger/test/errors/csvamountparse.test
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
$$$ hledger print -f csvamountparse.csv
|
||||||
|
>>>2 /hledger: Error: error: could not parse "badamount" as an amount
|
||||||
|
record values: "2022-01-03","badamount"
|
||||||
|
the amount rule is: %2
|
||||||
|
the date rule is: %1
|
||||||
|
|
||||||
|
the parse error is: 1:10:
|
||||||
|
\|
|
||||||
|
1 \| badamount
|
||||||
|
\| \^
|
||||||
|
unexpected end of input
|
||||||
|
expecting '\+', '-', or number
|
||||||
|
|
||||||
|
you may need to change your/
|
||||||
|
>>>= 1
|
||||||
3
hledger/test/errors/csvbalanceparse.csv
Executable file
3
hledger/test/errors/csvbalanceparse.csv
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env -S hledger print -f
|
||||||
|
# Unparseable balance amount.
|
||||||
|
2022-01-03,badbalance
|
||||||
|
3
hledger/test/errors/csvbalanceparse.csv.rules
Normal file
3
hledger/test/errors/csvbalanceparse.csv.rules
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
skip 2
|
||||||
|
date %1
|
||||||
|
balance %2
|
||||||
16
hledger/test/errors/csvbalanceparse.test
Normal file
16
hledger/test/errors/csvbalanceparse.test
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
$$$ hledger print -f csvbalanceparse.csv
|
||||||
|
>>>2 /hledger: Error: error: could not parse "badbalance" as balance1 amount
|
||||||
|
record values: "2022-01-03","badbalance"
|
||||||
|
the balance rule is: %2
|
||||||
|
the date rule is: %1
|
||||||
|
|
||||||
|
the parse error is: 1:11:
|
||||||
|
\|
|
||||||
|
1 \| badbalance
|
||||||
|
\| \^
|
||||||
|
unexpected end of input
|
||||||
|
expecting '\+', '-', or number
|
||||||
|
|
||||||
|
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
4
hledger/test/errors/csvbalancetypeparse.csv
Executable file
4
hledger/test/errors/csvbalancetypeparse.csv
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env -S hledger check -f
|
||||||
|
# See rules.
|
||||||
|
2022-01-01,1
|
||||||
|
|
||||||
|
4
hledger/test/errors/csvbalancetypeparse.csv.rules
Normal file
4
hledger/test/errors/csvbalancetypeparse.csv.rules
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
skip 2
|
||||||
|
date %1
|
||||||
|
balance %2
|
||||||
|
balance-type badtype
|
||||||
9
hledger/test/errors/csvbalancetypeparse.test
Normal file
9
hledger/test/errors/csvbalancetypeparse.test
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
$$$ hledger check -f csvbalancetypeparse.csv
|
||||||
|
>>>2 /hledger: Error: balance-type "badtype" is invalid. Use =, ==, =\* or ==\*.
|
||||||
|
record values: "2022-01-01","1"
|
||||||
|
the balance rule is: %2
|
||||||
|
the date rule is: %1
|
||||||
|
|
||||||
|
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
4
hledger/test/errors/csvdateformat.csv
Executable file
4
hledger/test/errors/csvdateformat.csv
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env -S hledger print -f
|
||||||
|
# See rules (missing/bad date-format rule).
|
||||||
|
# Note check doesn't show this error; print was needed.
|
||||||
|
a,b
|
||||||
|
2
hledger/test/errors/csvdateformat.csv.rules
Normal file
2
hledger/test/errors/csvdateformat.csv.rules
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
skip 3
|
||||||
|
date %1
|
||||||
8
hledger/test/errors/csvdateformat.test
Normal file
8
hledger/test/errors/csvdateformat.test
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
$$$ hledger print -f csvdateformat.csv
|
||||||
|
>>>2 /hledger: Error: error: could not parse "a" as a date using date format "YYYY\/M\/D", "YYYY-M-D" or "YYYY.M.D"
|
||||||
|
record values: "a","b"
|
||||||
|
the date rule is: %1
|
||||||
|
the date-format is: unspecified
|
||||||
|
you may need to change your date rule, add a date-format rule, or change your skip rule
|
||||||
|
for m\/d\/y or d\/m\/y d/
|
||||||
|
>>>= 1
|
||||||
4
hledger/test/errors/csvdateparse.csv
Executable file
4
hledger/test/errors/csvdateparse.csv
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env -S hledger check -f
|
||||||
|
# Date value not parseable by date-format rule.
|
||||||
|
2022-01-01,b
|
||||||
|
baddate,b
|
||||||
|
3
hledger/test/errors/csvdateparse.csv.rules
Normal file
3
hledger/test/errors/csvdateparse.csv.rules
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
skip 2
|
||||||
|
date %1
|
||||||
|
date-format %Y-%m-%d
|
||||||
8
hledger/test/errors/csvdateparse.test
Normal file
8
hledger/test/errors/csvdateparse.test
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
$$$ hledger check -f csvdateparse.csv
|
||||||
|
>>>2 /hledger: Error: error: could not parse "baddate" as a date using date format "%Y-%m-%d"
|
||||||
|
record values: "baddate","b"
|
||||||
|
the date rule is: %1
|
||||||
|
the date-format is: %Y-%m-%d
|
||||||
|
you may need to change your date rule, change your date-format rule, or change your skip rule
|
||||||
|
for m\/d\/y or d\/m\/y dates, use dat/
|
||||||
|
>>>= 1
|
||||||
3
hledger/test/errors/csvdaterule.csv
Executable file
3
hledger/test/errors/csvdaterule.csv
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env -S hledger check -f
|
||||||
|
# Rules have no date rule.
|
||||||
|
a,b
|
||||||
|
1
hledger/test/errors/csvdaterule.csv.rules
Normal file
1
hledger/test/errors/csvdaterule.csv.rules
Normal file
@ -0,0 +1 @@
|
|||||||
|
skip 2
|
||||||
6
hledger/test/errors/csvdaterule.test
Normal file
6
hledger/test/errors/csvdaterule.test
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
$$$ hledger check -f csvdaterule.csv
|
||||||
|
>>>2 /hledger: Error: offset=0:
|
||||||
|
Please specify \(at top level\) the date field. Eg: date %1
|
||||||
|
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
4
hledger/test/errors/csvdecimalmarkparse.csv
Executable file
4
hledger/test/errors/csvdecimalmarkparse.csv
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env -S hledger check -f
|
||||||
|
# See rules.
|
||||||
|
2022-01-01,1.0
|
||||||
|
|
||||||
|
4
hledger/test/errors/csvdecimalmarkparse.csv.rules
Normal file
4
hledger/test/errors/csvdecimalmarkparse.csv.rules
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
skip 2
|
||||||
|
date %1
|
||||||
|
amount %2
|
||||||
|
decimal-mark badmark
|
||||||
4
hledger/test/errors/csvdecimalmarkparse.test
Normal file
4
hledger/test/errors/csvdecimalmarkparse.test
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
$$$ hledger check -f csvdecimalmarkparse.csv
|
||||||
|
>>>2 /hledger: Error: decimal-mark's argument should be "." or "," \(not "badmark"\)
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
3
hledger/test/errors/csvifblocknonempty.csv
Executable file
3
hledger/test/errors/csvifblocknonempty.csv
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env -S hledger check -f
|
||||||
|
# Rules have an empty conditional block.
|
||||||
|
a,b
|
||||||
|
2
hledger/test/errors/csvifblocknonempty.csv.rules
Normal file
2
hledger/test/errors/csvifblocknonempty.csv.rules
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# no (indented) rules following if
|
||||||
|
if foo
|
||||||
10
hledger/test/errors/csvifblocknonempty.test
Normal file
10
hledger/test/errors/csvifblocknonempty.test
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
$$$ hledger check -f csvifblocknonempty.csv
|
||||||
|
>>>2 /hledger: Error: .*csvifblocknonempty.csv.rules:2:1:
|
||||||
|
\|
|
||||||
|
2 \| if foo
|
||||||
|
\| \^
|
||||||
|
start of conditional block found, but no assignment rules afterward
|
||||||
|
\(assignment rules in a conditional block should be indented\)
|
||||||
|
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
3
hledger/test/errors/csviftablefieldnames.csv
Executable file
3
hledger/test/errors/csviftablefieldnames.csv
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env -S hledger check -f
|
||||||
|
# See rules.
|
||||||
|
|
||||||
|
2
hledger/test/errors/csviftablefieldnames.csv.rules
Normal file
2
hledger/test/errors/csviftablefieldnames.csv.rules
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# if table not using valid CSV field names.
|
||||||
|
if,date,nosuchfield,description
|
||||||
8
hledger/test/errors/csviftablefieldnames.test
Normal file
8
hledger/test/errors/csviftablefieldnames.test
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
$$$ hledger check -f csviftablefieldnames.csv
|
||||||
|
>>>2 /hledger: Error: .*csviftablefieldnames.csv.rules:2:9:
|
||||||
|
\|
|
||||||
|
2 \| if,date,nosuchfield,description
|
||||||
|
\| \^\^\^\^\^\^\^\^\^\^\^\^
|
||||||
|
unexpected "nosuchfield,"
|
||||||
|
expecting "account1", "account10", "account11", "account12", "account13", "account14", "account15", "account16", "account17", "account18", "/
|
||||||
|
>>>= 1
|
||||||
3
hledger/test/errors/csviftablenonempty.csv
Executable file
3
hledger/test/errors/csviftablenonempty.csv
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env -S hledger check -f
|
||||||
|
# See rules.
|
||||||
|
|
||||||
|
2
hledger/test/errors/csviftablenonempty.csv.rules
Normal file
2
hledger/test/errors/csviftablenonempty.csv.rules
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
# no (indented) rules following if table
|
||||||
|
if,date,description,comment
|
||||||
9
hledger/test/errors/csviftablenonempty.test
Normal file
9
hledger/test/errors/csviftablenonempty.test
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
$$$ hledger check -f csviftablenonempty.csv
|
||||||
|
>>>2 /hledger: Error: .*csviftablenonempty.csv.rules:2:1:
|
||||||
|
\|
|
||||||
|
2 \| if,date,description,comment
|
||||||
|
\| \^
|
||||||
|
start of conditional table found, but no assignment rules afterward
|
||||||
|
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
3
hledger/test/errors/csviftablevaluecount.csv
Executable file
3
hledger/test/errors/csviftablevaluecount.csv
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env -S hledger check -f
|
||||||
|
# See rules.
|
||||||
|
|
||||||
|
4
hledger/test/errors/csviftablevaluecount.csv.rules
Normal file
4
hledger/test/errors/csviftablevaluecount.csv.rules
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# if table where some records have wrong number of values.
|
||||||
|
if,date,description
|
||||||
|
two,val1,val2
|
||||||
|
one,val1
|
||||||
9
hledger/test/errors/csviftablevaluecount.test
Normal file
9
hledger/test/errors/csviftablevaluecount.test
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
$$$ hledger check -f csviftablevaluecount.csv
|
||||||
|
>>>2 /hledger: Error: .*csviftablevaluecount.csv.rules:4:1:
|
||||||
|
\|
|
||||||
|
4 \| one,val1
|
||||||
|
\| \^
|
||||||
|
line of conditional table should have 2 values, but this one has only 1
|
||||||
|
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
0
hledger/test/errors/csvnoinclude.csv
Normal file
0
hledger/test/errors/csvnoinclude.csv
Normal file
|
|
6
hledger/test/errors/csvnoinclude.j
Executable file
6
hledger/test/errors/csvnoinclude.j
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env -S hledger check -f
|
||||||
|
# Trying to include a CSV file.
|
||||||
|
|
||||||
|
include csvinclude.csv
|
||||||
|
|
||||||
|
|
||||||
9
hledger/test/errors/csvnoinclude.test
Normal file
9
hledger/test/errors/csvnoinclude.test
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
$$$ hledger check -f csvnoinclude.j
|
||||||
|
>>>2 /hledger: Error: .*csvnoinclude.j:4:23:
|
||||||
|
\|
|
||||||
|
4 \| include csvinclude.csv
|
||||||
|
\| \^
|
||||||
|
No existing files match pattern: csvinclude.csv
|
||||||
|
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
2
hledger/test/errors/csvskipvalue.csv
Executable file
2
hledger/test/errors/csvskipvalue.csv
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
#!/usr/bin/env -S hledger check -f
|
||||||
|
# See rules.
|
||||||
|
2
hledger/test/errors/csvskipvalue.csv.rules
Normal file
2
hledger/test/errors/csvskipvalue.csv.rules
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
date %1
|
||||||
|
skip badval
|
||||||
4
hledger/test/errors/csvskipvalue.test
Normal file
4
hledger/test/errors/csvskipvalue.test
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
$$$ hledger check -f csvskipvalue.csv
|
||||||
|
>>>2 /hledger: Error: could not parse skip value: "badval"
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
6
hledger/test/errors/csvstatusparse.csv
Executable file
6
hledger/test/errors/csvstatusparse.csv
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/usr/bin/env -S hledger print -f
|
||||||
|
# Status value not parseable.
|
||||||
|
2022-01-01,*
|
||||||
|
2022-01-02,!
|
||||||
|
2022-01-03,
|
||||||
|
2022-01-04,badstatus
|
||||||
|
3
hledger/test/errors/csvstatusparse.csv.rules
Normal file
3
hledger/test/errors/csvstatusparse.csv.rules
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
skip 2
|
||||||
|
date %1
|
||||||
|
status %2
|
||||||
12
hledger/test/errors/csvstatusparse.test
Normal file
12
hledger/test/errors/csvstatusparse.test
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
$$$ hledger print -f csvstatusparse.csv
|
||||||
|
>>>2 /hledger: Error: error: could not parse "badstatus" as a cleared status \(should be \*, ! or empty\)
|
||||||
|
the parse error is: 1:1:
|
||||||
|
\|
|
||||||
|
1 \| badstatus
|
||||||
|
\| \^
|
||||||
|
unexpected 'b'
|
||||||
|
expecting '!', '\*', or end of input
|
||||||
|
|
||||||
|
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
4
hledger/test/errors/csvstdinrules.sh
Executable file
4
hledger/test/errors/csvstdinrules.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#!/usr/bin/env -S sh
|
||||||
|
# Second space above is significant, prevents shelltest's "-w hledger" substitution.
|
||||||
|
# Try to read CSV from stdin without specifying a rules file.
|
||||||
|
echo | hledger -fcsv:- check
|
||||||
4
hledger/test/errors/csvstdinrules.test
Normal file
4
hledger/test/errors/csvstdinrules.test
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
$$$ sh csvstdinrules.sh
|
||||||
|
>>>2 /hledger: Error: please use --rules-file when reading CSV from stdin
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
5
hledger/test/errors/csvtwofields.csv
Executable file
5
hledger/test/errors/csvtwofields.csv
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
#!/usr/bin/env -S hledger check -f
|
||||||
|
# Record(s) have less than two fields.
|
||||||
|
a,a
|
||||||
|
b
|
||||||
|
c,c
|
||||||
|
2
hledger/test/errors/csvtwofields.csv.rules
Normal file
2
hledger/test/errors/csvtwofields.csv.rules
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
skip 2
|
||||||
|
date %1
|
||||||
4
hledger/test/errors/csvtwofields.test
Normal file
4
hledger/test/errors/csvtwofields.test
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
$$$ hledger check -f csvtwofields.csv
|
||||||
|
>>>2 /hledger: Error: CSV record \["b"\] has less than two fields
|
||||||
|
/
|
||||||
|
>>>= 1
|
||||||
Loading…
Reference in New Issue
Block a user