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 users to pass files on the CLI #3

Merged
merged 2 commits into from
Sep 8, 2019

Conversation

Avaq
Copy link
Contributor

@Avaq Avaq commented Sep 8, 2019

Motivation

I'm in the process of migrating from one test runner to Oletus, and I want to do it gradually. In order to do so, I want Oletus to run on a subset of all the files I have in ./test. This PR adds a feature where users can supply their own list of test files to the Oletus CLI, like: oletus test/file1.mjs test/file2.mjs. If no files are specified, we fall back to crawling the ./test/ directory.

This feature is not only useful for my specific case though. It'll also help users who have their tests in other places, eg: oletus src/**/*.test.mjs, and users who have their tests in nested directories.

Changes

  • The first commit is a pure refactor which moves the directory crawling logic outside of the test running logic.
  • The second commit builds on this to make the directory crawling part optional in the CLI, adding the provided list of files as a second option.

@bearror bearror self-requested a review September 8, 2019 12:25
@bearror
Copy link
Owner

bearror commented Sep 8, 2019

I must say that I'm positively surprised that there's a need to migrate to Oletus.

The implementation looks solid. A couple of things to mention, though.

  • Run npx standard --fix to ensure crawler.mjs is consistent from a style perspective. (Sorry for the undocumented linting.)
  • example.mjs needs to be updated as well, since it relies on the fixtures. Something like the following should be fine.
const fixtures = crawl('./test/fixtures/')

fixtures
  .then(async fixtures => {
    await run(fixtures, concise)

    return fixtures
  })
  .then(fixtures => {
    run(fixtures, verbose)
  })

Great work once again! Happy to get this merged.

@Avaq
Copy link
Contributor Author

Avaq commented Sep 8, 2019

I must say that I'm positively surprised that there's a need to migrate to Oletus.

I have yet to find another test runner that supports native modules:

That said, I also appreciate the simplicity and speed of Oletus.

A couple of things

Will do

Copy link
Owner

@bearror bearror left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution. I'll bump the minor version

@bearror bearror merged commit 5419692 into bearror:master Sep 8, 2019
@Avaq Avaq deleted the avaq/files-list branch September 8, 2019 14:07
@Avaq
Copy link
Contributor Author

Avaq commented Sep 8, 2019

Great! :)

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

Successfully merging this pull request may close these issues.

2 participants