Replies: 1 comment 3 replies
-
hab25 ***@***.***> writes:
With consult.el having ~5.2k lines, I expect that tests will very quickly overvalue
their costs.
I expect that consult has much better things to test, but a trivial example of
where tests can help is when validating custom standard values against custom
types, which, if done in e.g. a git pre-push hook, could prevent the need for e.g.
8f22fbc .
In (very unlikely, I expect) case that you're not familiar with them @minad, see in
this section that they're very simple to write...
I am familiar with ERT. I use it heavily in Compat, see
https://github.com/emacs-compat/compat/blob/main/compat-tests.el. There
it is absolutely crucial to deliver the required robustness of such a
base library, and the tests there are also reasonably easy to write,
because we test small, isolated and often pure functions.
Multiple reasons why we don't have tests for Consult so far:
1. Interactive UI code is difficult to test. Most of the complexity of
Consult comes in fact from interactive and asynchronous code. Trivial
tests like one catching 8f22fbc would not help with the actual
difficulties. This means we mostly rely on manual testing for now,
also for testing integrations with Vertico, Embark, etc.
2. Consult is not a library, but a user-facing package with less
precisely specified API contracts.
3. Writing tests is time intensive and so far I've prioritized writing
features. I think one reasonable start would be to add regression
tests. Another possibility would be to add some kind of play back
tests which test commands on a high level, as a black box. This would
probably provide the greatest value right now.
4. When refactoring code, I usually try to do it in small steps,
applying equivalence transformations which are guaranteed to not
break. Of course it would be better to have tests, which would allow
for a more relaxed approach to refactoring. But even in the presence
of tests I would likely stick with my current refactoring approach.
5. Consult is widely rolled out. If I'd introduce a breakage in some
heavily used featured it will get noticed in hours or a day. This is
not a justification for not having tests, but an observation. ;)
But by all means, if there is interest in adding tests here, this is a
welcome addition.
|
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
minad
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
With
consult.el
having ~5.2k lines, I expect that tests will very quickly overvalue their costs.I expect that
consult
has much better things to test, but a trivial example of where tests can help is when validating custom standard values against custom types, which, if done in e.g. agit
pre-push hook, could prevent the need for e.g. 8f22fbc .In (very unlikely, I expect) case that you're not familiar with them @minad, see in this section that they're very simple to write
Then, in e.g. a
git
pre-push hook:emacs -batch -l ert -l my-tests.el -f ert-run-tests-batch-and-exit
Beta Was this translation helpful? Give feedback.
All reactions