-
Notifications
You must be signed in to change notification settings - Fork 14
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
Allow Multiple Glob/Path Arguments from CLI #47
Conversation
TODO: Check with Justin to see what LTSrelease he wants to suggest for developing teenytest.
This allows `criteria()` to accept either a single string or an array of test locator globs. It also accepts a second `userOptions` argument which is used to provide `userOptions.example` as a globally applied `name` filter. The return value is an array of objects, each with a `.file` property and, possibly, a `.name` and `.lineNumber` property, each of which is an array of filters that should be applied to that file.
Oops, looks like CI is saying |
I avoid committing developer tool dotfiles to libraries, because they typically support multiple versions of Node at a time (package.json engines being a more appropriate place to lock version ranges)
Made two small commits after cursory review. Basically tests pass and the tests seem to say what you want teenytest to do! I didn't have time to scrutinize the additions to /me ducks out and lets you look at the CLI |
Thanks for the commits. I worked on some CLI tests a bit today. I'm going to finish those up and then plan to go back and refactor the config a bit. Would like (🤞🏼) to have it at least working and pretty solid by the end of the week. |
We should probably combine the two bats "suites". Before this PR, we have a single bats test living under safe/example.bats (which is just a bats variant of the old example tests). Strictly speaking, we could keep the bats tests under safe/ since it only runs I'm somewhat tempted to just drop all the bats tests under safe/ since that's what they are. And we could rewrite the existing safe JS tests into bats, since they're already asserting on the CLI and TAP output. |
@jasonkarns you're closer to both bats and this project than I've been for a while so I am glad to defer to you. Consolidation sounds like a good word to me |
My initial thought (like @jasonkarns) was that the existing safe tests could be switched over to bats tests exercising the CLI and everything could be consolidated. While working on this PR, however, it seemed practical to just keep them separated as a mental "here's a bucket for the stuff I'm working with" and then consolidate afterward when I have a better grasp of what's being consolidated. While working on this I wanted to leave the existing JS SAFE tests in place as a check to be sure noting changed (or at least, if it did that it was appropriately handled). Also, just as a minor status update: As I'm writing the CLI tests, the behavior of dealing with multiple per-file filters isn't turning out to be correct out of the box. The config is being set up the way we want but the tests look like they are being run with the named filters combined as "matches all of" instead of "matches any of" so the end result is that something like |
738ce22
to
4cdd902
Compare
4cdd902
to
8c39471
Compare
- Remove unnecessary helper file - Clean up and rename test_helper.bash - Rename Bats CLI test file to teenytest.bats
Moves ./bats tests and fixtures into ./safe Changes test:bats to test:safe:bats Removes test:example (now run as part of test:safe:bats)
I've got teenytest working now with multiple glob/path args and have combined the |
Are you tackling that or are you suggesting someone else do? |
@searls Sorry, that wasn’t very clear. Yes, I intend to do both of those. I wanted to leave an update on the PR that the multi-glob feature was working but that I still had some cleanup work to do. |
ddabd97
to
fa8f1ca
Compare
This allows `criteria()` to accept either a single string or an array of test locator globs. It also accepts a second `userOptions` argument which is used to provide `userOptions.example` as a globally applied `name` filter. The return value is an array of objects, each with a `.file` property and, possibly, a `.name` and `.lineNumber` property, each of which is an array of filters that should be applied to that file.
I avoid committing developer tool dotfiles to libraries, because they typically support multiple versions of Node at a time (package.json engines being a more appropriate place to lock version ranges)
- Remove unnecessary helper file - Clean up and rename test_helper.bash - Rename Bats CLI test file to teenytest.bats
Moves ./bats tests and fixtures into ./safe Changes test:bats to test:safe:bats Removes test:example (now run as part of test:safe:bats)
0e0f502
to
3d227cf
Compare
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.
Looking good, didn't read all the criteria changes very closely. I'm cool merging if we can rename the --example
flag ❤️
README.md
Outdated
The above will run tests named `red` and `blue` in the file `test/foo-test.js` | ||
and tests on lines 14 and 28 in the file `test/bar-test.js`. | ||
|
||
#### Locating with the `--example` 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.
I had to re-read the PR a couple times to understand what was meant by --example
, assuming this is a BDD/rspecism that leaked from the code. Would --name
be more predictable and consistent with other tools like minitest?
If you agree, I'd ask you to change the name of this option to --name
or similar before we merge
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.
@searls This has been changed to --name
lib/configure/criteria.js
Outdated
|
||
// Consolidate criteria with duplicate file paths into a single criterion | ||
// file paths with arrays of collected line / name filter values | ||
testCriteria = consolidatedPathCriteria(testCriteria) |
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.
Would you be open to refactoring this so we're not re-assigning the same var over and over in the same function? Seems like the sort of thing that'd best(be(several(calls()))))
to named functions, hopefully obviating the comments
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.
@searls I've refactored https://github.com/testdouble/teenytest/blob/92ce2b86d66845e4c0dbd5df59127b548cff2809/lib/configure/criteria.js. If anything still seems like it should be changed (or just rubs you the wrong way) let me know.
@searls If I recall, the I also don't disagree with the refactor to use nested functions. The variable reassignment was a decision of personal preference that I thought might not mesh well with the rest of the codebase. I personally still find |
…into multiple-glob-args
58eb467
to
62b3336
Compare
62b3336
to
92ce2b8
Compare
@searls Sorry for the delay on the changes. Time has been a scarce resource lately. I added a few commits to address your change requests. If there’s anything else you’d like to see let me know. |
Nice, looks fantastic! Good README, left the code better-factored and better-tested than you found it. I know it took a lot of calendar time to see to completion but I think this is a really great feature that sets teenytest apart from a lot of other runners, big and small. Thanks, Cliff! |
Landed in 5.3.0 👏 |
Addresses:
I this is a PR to allow Multiple glob pattern arguments from the CLI. This will allow either multiple globs to be passed or will allow the shell to perform the expansion and pass multiple file path arguments. Each glob argument can have it's own
#
or:
filter which is applied to any files matched by the glob. The same glob can be supplied multiple times with different filters. There is also an--example
option which can be provided multiple times to specify global name filters which apply to all matched files.Internally, the glob expansion step has been moved into the process of configuration criteria which happens very early on in the execution of the test runner (basically it's the first thing that happens). Instead of a single glob pattern, the configuration now holds an array of objects. Each object represents one unique file path (after glob expansion) along with any filters that have been provided for that path.
Criteria is now processed so that:
example
(name) filter can also be provided as a string or array which will apply to all files (I'm open to changing the name of this property/flag)As an example, given the arguments:
config.criteria.testFiles
would be built as:Unit tests have been added for
configure
but they only cover the test criteria, not other aspects of the config.Changes outside of
configure
have been made so that the existing SAFE tests are passing with these changes. (i.e. thecriteria
change doesn't break the world).Bats tests have been added for the new CLI behavior. Bats tests are located in
/safe
along with other tests.Readme has been updated with some additional information on multiple globs, name/line filters, and the global
--example
option.CC: @searls @jasonkarns