Closed goto-engineering closed 3 years ago
@goto-engineering Sorry it's taken so long to get to this and thanks for submitting the PR!
@subsetpark This looks good to me but do you have thoughts? The alternative would be to allow tests to be redefined. I'm not sure why I was so concerned that this might happen when I originally coded this up but arguably changing it now would be a breaking change (although in a somewhat technical sense since it'd be weird to have code that 'relied' on this behaviour).
I’d personally feel comfortable with simply warning on test redefinition, rather than disallowing it entirely.
it slightly off - maybe a little too low-level, or “out of band” - to control this behavior with a flag.
and I understand why redefining tests would be a behavior to watch out for; pretty much every time in my career that I’ve redefined a test, it’s been because i copy and pasted the form and forgot to change the name.
That said, I think printing a warning to the console “you are redefining test foo-bar on line baz; are you sure you want to do that?” Would totally accomplish the intention of alerting to this possibility, while still allowing someone in a repl context to perform the action.
Now that you say it, I remember that it was because of copying and pasting. I did that and it bit me so I decided to throw an error if it happened.
What do you think of changing the behaviour to output a warning rather than an error, @goto-engineering? After thinking it over, I feel similarly to @subsetpark that it's a little clunky to have a flag that you have to know to use if you're programming at the REPL.
@pyrmont I'm ok with the warning; but note there are some other changes for REPL-mode.
Is there any reason for (2) not to obtain in all cases? In CLI mode, if the suite runs only once, it wouldn’t hurt to, for instance, ensure they’re reset at the beginning of the run.
I don't know. I guess in regular mode it never needed to reset because the process would end after each run. @pyrmont ?
@goto-engineering Sorry it's taken a bit of time to get to this. Let me know what you think.
@subsetpark I updated register-test
so that if you use a test name for multiple tests, it prints a warning to :err
rather than throws an error. After thinking over the other changes, those all seem necessary for a good REPL experience so I've left them as they were. Do you have any thoughts?
@pyrmont Looks good to me! :)
@goto-engineering Sorry this has been outstanding for so long >_<
You'll see I made a few tidying up changes, most notably changing the name of the dynamic variable to :testament-repl?
. If you're happy with these, I'll merge into master.
@goto-engineering Thank you for contributing to Testament :) Sorry again for how long this took!
Thanks for making Testament :)
This allows me to re-evaluate test files in the REPL without running into the same-name constraint.