Skip to content
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 patterns (globs & exclude patterns) #32

Open
searls opened this issue Oct 6, 2017 · 9 comments
Open

Allow multiple patterns (globs & exclude patterns) #32

searls opened this issue Oct 6, 2017 · 9 comments

Comments

@searls
Copy link
Member

searls commented Oct 6, 2017

Right now teenytest only accepts one glob of tests, it should be able to take an array of them (whitespace separated on the CLI, an array in package.json & api config).

@rosston
Copy link
Member

rosston commented Oct 6, 2017

Would this break the functionality outlined here? https://github.com/testdouble/teenytest#as-an-npm-script

If you want to run a single test, you can just tack an additional path or glob at the end without looking at how teenytest is configured in the package.json:

$ npm test path/to/my.test.js

The above will ignore the glob embedded in the npm script and only run path/to/my.test.js.

@searls
Copy link
Member Author

searls commented Oct 9, 2017

Yeah, I suppose it would change that behavior, but since it's a dev productivity/ergonomic issue that can be remedied with a second task, I wouldn't feel too bad about breaking it

@jasonkarns
Copy link
Member

Just dropping in to comment that I would fully expect the unix-ism -- to be used as the separator between options and all the space-separated globs.

@jasonkarns
Copy link
Member

A related use-case that I had hoped would work:

teenytest #foo

Our test suite is set up conventionally, so we don't pass a glob to teenytest. However, when wanting to filter tests, the glob seems to be required. Passing just the filter pattern alone doesn't work.

@searls
Copy link
Member Author

searls commented Oct 27, 2017

how about teenytest --filter="#foo"

And while I like the -- separator, most unix tools that use it aren't super consistent and often accept globs without an --. Additionally, developers I've paired with who are not you very rarely are aware of the -- meme at all, so I don't see much value in pushing it on folks

@jasonkarns
Copy link
Member

agree on --, i wouldn't want to require, just as long as we accept it and handle it properly

@cpruitt
Copy link
Contributor

cpruitt commented Sep 5, 2019

👋🏼 I wanted to leave a quick update on this since it took a little while for me to get my bearings and I had a false start or two:

I have a WIP branch that changes how criteria is built from it's input.
https://github.com/testdouble/teenytest/tree/multiple-glob-args
(Definately needs cleanup/refactoring)

I had a chat with @jasonkarns about expected behaviors and based on that I've updated criteria so that:

  • A single string or an array can be provided
  • Array elements are always expanded as globs by JavaScript, even if the shell already expanded them (See CLI should take multiple paths and not a glob pattern #44 (comment))
  • A Line number or function name filter suffix can be supplied as part of any glob in the array and it will only apply to files matching that glob pattern.
  • A global 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)
  • After glob expansion duplicate files are removed with filters consolidated. Duplicate filters of the same type (line/name) are removed.
  • If a test name and a line number filter both resolve to the same test, that duplicate is not currently handled

The existing SAFE tests are passing with these changes. (i.e. the criteria change doesn't break the world).

My next step is to update the cli so that the options are parsed and passed down as intended and make sure package defaults are appropriate. I'll be adding bats tests for this.

Although there's still a little work to do, I'm open to any early feedback or change suggestions. 🙂

@searls
Copy link
Member Author

searls commented Sep 10, 2019

Awesome Cliff!

Please open a WIP PR so it's easier to follow along with the progress at a distance. In general if Jason says it's good I'm inclined to follow him blindly in all matters regarding CLI behavior

@cpruitt
Copy link
Contributor

cpruitt commented Sep 17, 2019

Sorry Justin, I was away on vacation and am catching up. 🙂 You got it. Here's the PR: #47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants