Skip to content

Commit

Permalink
dev: make func tests compatible with ghc 9.10
Browse files Browse the repository at this point in the history
Work around ghc 9.10's extra newline, https://gitlab.haskell.org/ghc/ghc/-/issues/25116
  • Loading branch information
simonmichael committed Oct 1, 2024
1 parent 7b1ef10 commit 8a76c4f
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 59 deletions.
3 changes: 3 additions & 0 deletions hledger/test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ and a test number (`1. `), useful for running individual tests.

A few tests invoke unix commands; these won't run in a Windows CMD shell.

2024-09-30 Note: tests of error output must use regexps for now to work
around ghc 9.10's extra newline in error output: https://gitlab.haskell.org/ghc/ghc/-/issues/25116

[Developer docs > TESTS]: https://hledger.org/TESTS.html
[component]: https://hledger.org/CONTRIBUTING.html#components
[shelltestrunner]: https://github.com/simonmichael/shelltestrunner#readme
Expand Down
48 changes: 26 additions & 22 deletions hledger/test/csv.test
Original file line number Diff line number Diff line change
Expand Up @@ -774,14 +774,15 @@ if|account2|comment
%amount 150|acct2
%description Flubber|acct|
$ ./csvtest.sh
>2
hledger: Error: input.rules:6:1:
|
6 | %amount 150|acct2
| ^
>2 /hledger: Error: input.rules:6:1:
\|
6 \| %amount 150\|acct2
\| \^
line of conditional table should have 2 values, but this one has only 1

/
>=1
# XXX regex needed for error tests with ghc 9.10, https://gitlab.haskell.org/ghc/ghc/-/issues/25116

# ** 40. unindented condition block error
<
Expand All @@ -796,15 +797,16 @@ if Flubber
account2 acct
comment cmt
$ ./csvtest.sh
>2
hledger: Error: input.rules:5:1:
|
5 | if Flubber
| ^
>2 /hledger: Error: input.rules:5:1:
\|
5 \| if Flubber
\| \^
start of conditional block found, but no assignment rules afterward
(assignment rules in a conditional block should be indented)
\(assignment rules in a conditional block should be indented\)

/
>=1
# XXX

# ** 41. Assignment to custom field (#1264) + spaces after the if (#1120)
<
Expand All @@ -822,15 +824,16 @@ if Flubber

account2 %myaccount2
$ ./csvtest.sh
>2
hledger: Error: input.rules:6:3:
|
6 | myaccount2 acct
| ^^^^^^^^^^^^
>2 /hledger: Error: input.rules:6:3:
\|
6 \| myaccount2 acct
\| \^\^\^\^\^\^\^\^\^\^\^\^
unexpected "myaccount2 a"
expecting conditional block

/
>=1
# XXX

# ** 42. Rules override each other in the order listed in the file
<
Expand Down Expand Up @@ -870,15 +873,16 @@ if account2 comment
%amount 150 acct2
%description Flubber acct
$ ./csvtest.sh
>2
hledger: Error: input.rules:5:1:
|
5 | if account2 comment
| ^
>2 /hledger: Error: input.rules:5:1:
\|
5 \| if account2 comment
\| \^
start of conditional block found, but no assignment rules afterward
(assignment rules in a conditional block should be indented)
\(assignment rules in a conditional block should be indented\)

/
>=1
# XXX

# ** 44. handle conditions with & operator
<
Expand Down
13 changes: 7 additions & 6 deletions hledger/test/forecast.test
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,16 @@ Balance changes in 2016-10-01..2017-01-31:
# ** 9. Parse error in malformed forecast period expression
$ hledger bal -M -b 2016-10 -e 2017-02 -f - --forecast=20160801-foobar
>
>2
hledger: Error: could not parse forecast period : 1:10:
|
1 | 20160801-foobar
| ^
>2 /hledger: Error: could not parse forecast period : 1:10:
\|
1 \| 20160801-foobar
\| \^
unexpected 'f'
expecting end of input
(use -h to see usage)
\(use -h to see usage\)
/
>=1
# XXX regex needed for error tests with ghc 9.10, https://gitlab.haskell.org/ghc/ghc/-/issues/25116

<
commodity 1,000.00 USD
Expand Down
26 changes: 14 additions & 12 deletions hledger/test/journal/directive-account.test
Original file line number Diff line number Diff line change
Expand Up @@ -73,30 +73,32 @@ Expenses:Food
account (a)

$ hledger -f- accounts
>2
hledger: Error: -:1:9:
|
1 | account (a)
| ^
unexpected '('
>2 /hledger: Error: -:1:9:
\|
1 \| account \(a\)
\| \^
unexpected '\('
expecting account name without brackets

/
>=1
# XXX regex needed for error tests with ghc 9.10, https://gitlab.haskell.org/ghc/ghc/-/issues/25116

# ** 6. It does not allow brackets in names.
<
account [a]

$ hledger -f- accounts
>2
hledger: Error: -:1:9:
|
1 | account [a]
| ^
unexpected '['
>2 /hledger: Error: -:1:9:
\|
1 \| account \[a\]
\| \^
unexpected '\['
expecting account name without brackets

/
>=1
# XXX regex needed for error tests with ghc 9.10, https://gitlab.haskell.org/ghc/ghc/-/issues/25116

# TODO
# a trailing : should give a clear error
Expand Down
24 changes: 12 additions & 12 deletions hledger/test/journal/parse-errors.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@
2018

$ hledger -f - print
>2
hledger: Error: -:1:5:
|
1 | 2018
| ^
>2 /hledger: Error: -:1:5:
\|
1 \| 2018
\| \^
unexpected newline
expecting date separator or digit

/
>=1
# XXX regex needed for error tests with ghc 9.10, https://gitlab.haskell.org/ghc/ghc/-/issues/25116

# A journal with an unbalanced transaction.
<
Expand Down Expand Up @@ -122,18 +123,17 @@ $ hledger -f- print
b 1B

$ hledger -f- print
>2
hledger: Error: -:1-3:
1 | 2020-01-01
| a 1A
| b 1B
>2 /hledger: Error: -:1-3:
1 \| 2020-01-01
\| a 1A
\| b 1B

This multi-commodity transaction is unbalanced.
The real postings all have the same sign. Consider negating some of them.
Consider adjusting this entry's amounts, adding missing postings,
or recording conversion price(s) with @, @@ or equity postings.
/
>=1
#'
# XXX regex needed for error tests with ghc 9.10, https://gitlab.haskell.org/ghc/ghc/-/issues/25116

# ** 12. Typical "hledger equity --close" transaction does not trigger sign error.
<
Expand Down
7 changes: 4 additions & 3 deletions hledger/test/query-expr.test
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,11 @@ $ hledger -f - print expr:"not tag:transactiontag=B"

# ** 9. Having parentheses directly follow 'not' sees 'not' as part of a query.
$ hledger -f - print expr:"not(tag:transactiontag=B)"
>2
hledger: Error: This regular expression is invalid or unsupported, please correct it:
not(tag:transactiontag=B
>2 /hledger: Error: This regular expression is invalid or unsupported, please correct it:
not\(tag:transactiontag=B
/
>=1
# XXX regex needed for error tests with ghc 9.10, https://gitlab.haskell.org/ghc/ghc/-/issues/25116

# ** 10. ... whereas parentheses with a space between 'not' and '(' is fine.
$ hledger -f - print expr:"not (tag:transactiontag=B)"
Expand Down
5 changes: 1 addition & 4 deletions hledger/test/roi.test
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ $ hledger -f- roi -p 2019-11
Assets:Checking 101 A
Unrealized PnL
$ hledger -f- roi -p 2019-11 --inv Investment --pnl PnL
>2
hledger: Error: Amounts could not be converted to a single commodity: ["10 B","-9 B @@ 100 A","100 C"]
Consider using --value to force all costs to be in a single commodity.
For example, "--value=end,<commodity> --infer-market-prices", where commodity is the one that was used for investment valuations.
>2 /hledger: Error: Amounts could not be converted to a single commodity: \["10 B","-9 B @@ 100 A","100 C"\]/
>= 1

# ** 10. Forcing valuation via --value
Expand Down

0 comments on commit 8a76c4f

Please sign in to comment.