-
-
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
-n option and fix for .only on dup test names #302
Conversation
…ly test X. Works manually, but can't get tests to run.
- Must load the tape module differently when testing the tape module itself - Fixed a few mistakes in the driver for -n tests
tape = require(resolveModule("tape", { basedir: cwd })); | ||
} | ||
catch(err) { | ||
tape = require("../"); // assume testing tape module itself |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you elaborate on this code block? adding production code just for tests seems very subpar.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By way of explanation, the -n
option must inform the tape module of the number of the test to run. The above resolveModule()
call requires that a module named tape
have been installed. No module named tape
has been installed when we run the test suite for tape
itself. In order to be able to test the -n
option within the tape
module itself, it's necessary to load the module in the way that is required by the test suite. You'll find all the tests loading the tape
module this way as well (not just mine). Without this line, the tape
module would not be able to include tests of the -n
option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like we could resolve that by adding a devDep of "tape": "./"
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. That's trick NPM stuff. That might allow you to replace the mysterious var tape = require('../');
line found in each test file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That line isn't mysterious - that's how every npm package tests itself.
Oops, forgot to check for consistency with existing style. Also, my colleague found a bug whereby indicating a test number greater than the number of tests results in all tests running. I'm thinking that I should run no tests in this case and do one of the following:
|
I think that should error out without running any tests, yes. What if I run a number that's explicitly skipped? I assume it would still be skipped. |
I agree, it should still be skipped. I'll make some more unit tests. Thank you! |
Another to-do item for me: Make sure the bracketed numbers are compatible with the TAP standard. |
When I've got this done, should I close this PR and make a new one? (I'm new to git/github.) |
@jtlapp no, please do not. Rebase and force push and the PR will be updated. |
Okay, I'll try to make sense of that. Out of curiosity, why a trailing newline? |
Thanks. That explains why I have a habit of ending all my text/data files in a newline, but I guess it's been a while since I've catted or munged code via command line tools. |
Presently, if you use
Which is this:
The numbering shows that a test is being skipped -- numbers are skipped. I like that. It's informative. I'm getting my |
I'm closing this. I found an easy way to extend the |
This PR provides the
-n
option described in #301 and the fix for #299 on which it depends.