-
-
Notifications
You must be signed in to change notification settings - Fork 306
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Command line option -n to run a test by number #301
Comments
I've written it already, and you can play with it. However, the test suite |
Okay, I found the problem. I load the |
The test suite is now working. You can see the proposal at https://github.com/jtlapp/tape/tree/only-by-number. Let me know if you'd like me to do a PR. |
Okay, I think I now have the readme updated and prettied for this proposal. |
For the record, my |
Here is how to modify faucet to support -n. https://github.com/jtlapp/faucet/tree/tape-options-support |
(That is, another person wouldn't have to go find a particular file and test name. I could just give the number assigned from faucet. For confirmation, I could also give the test name, but they'd only need to look for that test name if running that test number didn't produce this name.) (I guess this is also an argument for using |
I will be creating a publicly available module and would like the test suite based on tape. However, I'd also like the benefit of the |
Your point here is the most compelling one to me - although I still think there's a concern that people will rely on test numbers that can easily change. @jtlapp how would @substack @Raynos, what do you think about |
Thanks @ljharb. I don't think we could support |
perhaps an environment variable that |
I think that would work. Is something compelling you to want support outside of the Developers might think, "Hey, I want to run by number, so I'll use Also, before committing my PR, be sure to look at my way of avoiding use of node globals. See lines 32 and 35 in https://github.com/jtlapp/tape/blob/only-by-number/bin/tape |
I prefer only using |
Examining the TAP spec now, I'm seeing that we have to be careful with language we use to describe the The The Except for one inconsistency. In any case, I think we're best off being consistent with the TAP spec. That suggests:
The one remaining problem with this is that |
Alternatively, we call each "test" of TAP an "assertion" within I think the addition of |
I think I misread your original post. Yes, numbers are already printed out, and I assumed you were asking to identify those numbers. Definitely we do not want to output any different or additional numbers - if we use any numbers, it should be the numbering that the TAP output already has. |
Except that it is not possible to run only one TAP test. It is only possible to run a I'm also pointing out that the |
yeah, that's a good point. I'd think it would be OK to do |
Clever. I wonder if that wouldn't invite confusion or frustration, as the programmer repeatedly attempts to run just |
Groups could also be given letter sequences, instead of numbers. A-Z, then AA-ZZ, etc. |
There's another problem with running the containing group. Once you run just that containing group, the test points get renumbered. Test point numbers don't have the appearance of being unique identifiers. I can see that even confusing me on occasion. |
Still another option: generate a hash for each test group, based on the test name. If we tracked hashes, we could even guarantee their uniqueness. Main drawback is that they are longer, so to run a particular test, we'll find ourselves copying and pasting, rather than just reciting a number. |
The purpose of
I think things could be made still less confusing by always including the test group number in the output (bracketed), so that the user isn't only periodically becoming aware of the second numbering scheme. There's another argument for always showing the group number. If after running a test sequence I decide to rerun just one test, I don't have to rerun all the tests first with Maybe this feature is better off in a fork after all. |
Okay, I'll get you the reference-based fix for |
@jtlapp if it's possible to provide event hooks in |
I don't see how it is possible to create a second module that people would load to change the behavior of an executable script. We could add a second executable script. The A second executable script has the advantage of giving everyone who is currently using |
I'm going to look at doing something along these lines:
This would be ideal. The executable |
I found a way to implement Here is a approximately what var nextTestNumber = 0; // TBD: temporary
Results.prototype.onPreTest = function (title, unscheduled) {
if (onlyTestNumber !== false && nextTestNumber === 0) { // first run only
if (onlyTestNumber === 0 || onlyTestNumber > this.tests.length) {
exitWithError("test "+ onlyTestNumber +" not found");
}
}
++ nextTestNumber;
if (numbered) {
title = '['+ nextTestNumber +'] '+ title;
if (onlyTestNumber) {
if (nextTestNumber !== onlyTestNumber)
title = null;
else if (unscheduled)
exitWithError("test "+ onlyTestNumber +" not scheduled to run");
}
}
return title;
}; There were two main consequences to getting this hook to work:
You can see the new approach in my dash-n-hook branch. The most significant changes are to those two blocks. In particular, I inserted an arbitrator for cancelling and/or renaming tests. |
Woo! I was able to shorten the scheduling arbitrator by quite a bit by allowing skipped tests to run if they were skipped by argument flag. The |
I've written this and having it working but can't seem to get a test suite running. UPDATE: It's now working at the link below. Just waiting for decision on PR.
I absolutely love the simplicity of
tape
, but it asks me to do something that I find anathema: modify code to run a particular test and remember to remove my modifications when I'm done. If I forgot to remove the.only
constraint, I may check it in. That's easy to fix. The worst scenario is unwittingly changing something in the test while it's in the editor. This happens.So while I respect that some people are really comfortable with the
.only
feature, I suspect I'm not the only one who is really uncomfortable with it. Fortunately, there's an easy fix.All we need is a
-n
command line option. If you leave the option off, everything runs as it has. If you include a simple-n
, all the tests run as usual, except that a test number is prefixed to the title of each test.To run a particular test, just place
-nN
on the command line, whereN
is the test number shown in the title.This approach allows
tape
to satisfy die-hards like me who prefer not to make edits that shouldn't be checked in.The text was updated successfully, but these errors were encountered: