From 8a76c4f7d8193efb6257dde8cc158a828c09faa3 Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Mon, 30 Sep 2024 14:17:55 -1000 Subject: [PATCH] dev: make func tests compatible with ghc 9.10 Work around ghc 9.10's extra newline, https://gitlab.haskell.org/ghc/ghc/-/issues/25116 --- hledger/test/README.md | 3 ++ hledger/test/csv.test | 48 +++++++++++---------- hledger/test/forecast.test | 13 +++--- hledger/test/journal/directive-account.test | 26 +++++------ hledger/test/journal/parse-errors.test | 24 +++++------ hledger/test/query-expr.test | 7 +-- hledger/test/roi.test | 5 +-- 7 files changed, 67 insertions(+), 59 deletions(-) diff --git a/hledger/test/README.md b/hledger/test/README.md index 8eb47cfae7f..0f0cf1b013d 100644 --- a/hledger/test/README.md +++ b/hledger/test/README.md @@ -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 diff --git a/hledger/test/csv.test b/hledger/test/csv.test index 1734d5312cf..9581fd7e65c 100644 --- a/hledger/test/csv.test +++ b/hledger/test/csv.test @@ -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 < @@ -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) < @@ -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 < @@ -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 < diff --git a/hledger/test/forecast.test b/hledger/test/forecast.test index d2ee29f29bc..e1baf2c6e3f 100644 --- a/hledger/test/forecast.test +++ b/hledger/test/forecast.test @@ -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 diff --git a/hledger/test/journal/directive-account.test b/hledger/test/journal/directive-account.test index 1dd76fe1e7a..43b40be8aba 100644 --- a/hledger/test/journal/directive-account.test +++ b/hledger/test/journal/directive-account.test @@ -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 diff --git a/hledger/test/journal/parse-errors.test b/hledger/test/journal/parse-errors.test index a44ce942ffc..f9eb88f3e52 100644 --- a/hledger/test/journal/parse-errors.test +++ b/hledger/test/journal/parse-errors.test @@ -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. < @@ -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. < diff --git a/hledger/test/query-expr.test b/hledger/test/query-expr.test index 7445035f2e0..3d9a2a5d013 100644 --- a/hledger/test/query-expr.test +++ b/hledger/test/query-expr.test @@ -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)" diff --git a/hledger/test/roi.test b/hledger/test/roi.test index 37b2a8f6eb3..697da36d152 100644 --- a/hledger/test/roi.test +++ b/hledger/test/roi.test @@ -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, --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