From f7625343f60755d7dc77972583c10c2416f4753f Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Fri, 18 Mar 2022 07:13:18 -1000 Subject: [PATCH] test: errors: rename tests like check command's checks --- hledger/test/errors/README.md | 53 +++++++++++-------- .../errors/{undeclared-acct.j => accounts.j} | 0 ...iling-balance-assertion.j => assertions.j} | 0 .../errors/{unbalanced-txn.j => balanced.j} | 0 .../{undeclared-commodity.j => commodities.j} | 0 .../{unordered-dates.j => ordereddates.j} | 0 .../{invalid-date.j => parseable-dates.j} | 0 .../{invalid-regex.j => parseable-regexps.j} | 0 .../errors/{parse-error.j => parseable.j} | 0 .../errors/{undeclared-payee.j => payees.j} | 0 ...nunique-leaf-names.j => uniqueleafnames.j} | 0 11 files changed, 30 insertions(+), 23 deletions(-) rename hledger/test/errors/{undeclared-acct.j => accounts.j} (100%) rename hledger/test/errors/{failing-balance-assertion.j => assertions.j} (100%) rename hledger/test/errors/{unbalanced-txn.j => balanced.j} (100%) rename hledger/test/errors/{undeclared-commodity.j => commodities.j} (100%) rename hledger/test/errors/{unordered-dates.j => ordereddates.j} (100%) rename hledger/test/errors/{invalid-date.j => parseable-dates.j} (100%) rename hledger/test/errors/{invalid-regex.j => parseable-regexps.j} (100%) rename hledger/test/errors/{parse-error.j => parseable.j} (100%) rename hledger/test/errors/{undeclared-payee.j => payees.j} (100%) rename hledger/test/errors/{nonunique-leaf-names.j => uniqueleafnames.j} (100%) diff --git a/hledger/test/errors/README.md b/hledger/test/errors/README.md index 6f7c04d58..d49833cca 100644 --- a/hledger/test/errors/README.md +++ b/hledger/test/errors/README.md @@ -1,17 +1,37 @@ -Here are journals for reproducing all of hledger's journal error messages. -Each has an easy command at the top for reproducing in the CLI. -Some have additional declarations to help with reproducing in Emacs with flycheck-hledger. +Here are journals/scripts for reproducing hledger's journal error messages. +They are named similarly to [hledger check][]'s checks. -hledger error messages are still pretty inconsistent. -Tools like https://github.com/DamienCassou/flycheck-hledger parse them and need updating whenever they change. -Related: https://github.com/simonmichael/hledger/issues/1436. +In the CLI, execute them to see the error messages (`./showall`). +In Emacs with [flycheck-hledger][], +customize flycheck-hledger-* to enable all appropriate checks, +and open the files to see how flycheck handles them. +Some files contain extra declarations to ease flycheck testing. + +[hledger-check]: https://hledger.org/hledger.html#check +[flycheck-hledger]: https://github.com/DamienCassou/flycheck-hledger +[#1436]: https://github.com/simonmichael/hledger/issues/1436 + +hledger error messages are currently quite varied in format. +Tools like flycheck-hledger parse them and need updating +whenever they change ([#1436][]). Getting consistent high-quality errors and accurate flycheck region highlighting, not to mention LSP support, for all of our journal -errors is a big project. -But (once we converge on a standard format) it's quite crowd-sourceable, -tackling each error separately, and any progress means immediate practical benefits. -Below is the approximate status of hledger's error messages and related tool support. +errors is a big project, but it's crowd-sourceable and any progress +brings immediate practical benefits. Here is the approximate current status: + +| | consistent | accurate line | accurate column | flycheck detects | flycheck region | +|-------------------|------------|---------------|-----------------|------------------|-----------------| +| parseable | | | | Y | | +| parseable-dates | | | | Y | | +| parseable-regexps | | | | Y | | +| balanced | | | | Y | | +| assertions | | | | Y | | +| accounts | | | | Y | | +| commodities | | | | Y | | +| payees | | | | Y | | +| ordereddates | | | | Y | | +| uniqueleafnames | | | | Y | | Key: - consistent: the error message follows a consistent format @@ -19,16 +39,3 @@ Key: - accurate column - the optimal column(s) is(are) selected - flycheck detects - flycheck recognises the error output, reports the error and doesn't give a "suspicious" warning - flycheck shows region - flycheck highlights the text region containing the error - -| | consistent | accurate line | accurate column | flycheck detects | flycheck region | -|---------------------------|------------|---------------|-----------------|------------------|-----------------| -| failing-balance-assertion | | | | Y | | -| invalid-date | | | | Y | | -| invalid-regex | | | | Y | | -| nonunique-leaf-names | | | | Y | | -| parse-error | | | | Y | | -| unbalanced-txn | | | | Y | | -| undeclared-acct | | | | Y | | -| undeclared-commodity | | | | Y | | -| undeclared-payee | | | | Y | | -| unordered-dates | | | | Y | | diff --git a/hledger/test/errors/undeclared-acct.j b/hledger/test/errors/accounts.j similarity index 100% rename from hledger/test/errors/undeclared-acct.j rename to hledger/test/errors/accounts.j diff --git a/hledger/test/errors/failing-balance-assertion.j b/hledger/test/errors/assertions.j similarity index 100% rename from hledger/test/errors/failing-balance-assertion.j rename to hledger/test/errors/assertions.j diff --git a/hledger/test/errors/unbalanced-txn.j b/hledger/test/errors/balanced.j similarity index 100% rename from hledger/test/errors/unbalanced-txn.j rename to hledger/test/errors/balanced.j diff --git a/hledger/test/errors/undeclared-commodity.j b/hledger/test/errors/commodities.j similarity index 100% rename from hledger/test/errors/undeclared-commodity.j rename to hledger/test/errors/commodities.j diff --git a/hledger/test/errors/unordered-dates.j b/hledger/test/errors/ordereddates.j similarity index 100% rename from hledger/test/errors/unordered-dates.j rename to hledger/test/errors/ordereddates.j diff --git a/hledger/test/errors/invalid-date.j b/hledger/test/errors/parseable-dates.j similarity index 100% rename from hledger/test/errors/invalid-date.j rename to hledger/test/errors/parseable-dates.j diff --git a/hledger/test/errors/invalid-regex.j b/hledger/test/errors/parseable-regexps.j similarity index 100% rename from hledger/test/errors/invalid-regex.j rename to hledger/test/errors/parseable-regexps.j diff --git a/hledger/test/errors/parse-error.j b/hledger/test/errors/parseable.j similarity index 100% rename from hledger/test/errors/parse-error.j rename to hledger/test/errors/parseable.j diff --git a/hledger/test/errors/undeclared-payee.j b/hledger/test/errors/payees.j similarity index 100% rename from hledger/test/errors/undeclared-payee.j rename to hledger/test/errors/payees.j diff --git a/hledger/test/errors/nonunique-leaf-names.j b/hledger/test/errors/uniqueleafnames.j similarity index 100% rename from hledger/test/errors/nonunique-leaf-names.j rename to hledger/test/errors/uniqueleafnames.j