Skip to content

Support .only for all files #556

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

Merged
merged 1 commit into from
Mar 2, 2016

Conversation

naptowncode
Copy link
Contributor

My suggested solution for #549. Needs unit tests, of course.

@mention-bot
Copy link

By analyzing the blame information on this pull request, we identified @novemberborn, @ariporad and @sotojuan to be potential reviewers

@naptowncode naptowncode force-pushed the support_.only_for_all_files branch from 111dab7 to 8377081 Compare February 22, 2016 21:02
@naptowncode naptowncode changed the title [WIP] Support .only for all files Support .only for all files Feb 22, 2016
@naptowncode
Copy link
Contributor Author

@sindresorhus @vdemedes @jamestalmage Added unit test. Should be ready to go.

@BarryThePenguin
Copy link
Contributor

Is there a test for multiple exclusive tests in multiple files?

@naptowncode
Copy link
Contributor Author

The test uses three files: One file that has only an exclusive test, one file that has an exclusive test and a non-exclusive test, one file that has two non-exclusive test. Total of five tests across three files with two exclusive tests in different files.

@novemberborn
Copy link
Member

I'm wondering how this should work with --watch mode. Let's say we have two test files: foo.js and bar.js. The latter contains a .only.

Initially all test files are run and because bar.js contains a .only, only that test is actually executed.

Subsequently foo.js is changed. The watcher will run just foo.js which does not contain a .only. Now all tests in foo.js are executed.

Later a non-test file is changed and all test files are rerun. Only the .only test from bar.js is executed.

This isn't necessarily bad but it may be surprising to some. I wonder if .only should be sticky so that when changes are detected the watcher still only executes .only tests. But then if you remove the .only it starts executing all tests again. Similarly adding a .only switches back into the sticky mode.

This is a little tricky to implement though #544 requires similar per-test-file housekeeping.

Anyway not meant as a blocker to this PR landing. We can discuss in a separate issue if people think .only should stick across watcher runs.

@@ -108,6 +109,15 @@ Api.prototype._handleExceptions = function (data) {
};

Api.prototype._handleStats = function (stats) {
if (this.hasExclusive && !stats.hasExclusive) {
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a comment as to why the function is returning here? It's because if we're running exclusive tests, but the test file does not include exclusive tests, then we don't want those tests to be counted, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct, although I'm not super keen on just dropping this info on the floor. I just went for consistency with how non-exclusive tests are dropped within test-collection. I'll add a comment to that effect.

That said, I would favor changing the reporting completely as suggested by #471.

@novemberborn
Copy link
Member

Solution makes sense to me. Great job given the amount of (necessary) indirection involved in coordinating test runs 👍

@naptowncode
Copy link
Contributor Author

I'm not actually sure how it works with --watch. At the very least I should add some documentation for that.

@novemberborn
Copy link
Member

I'm not actually sure how it works with --watch. At the very least I should add some documentation for that.

Watch itself isn't documented yet so don't worry about it. We can get this in and then discuss repercussions in a new issue.

@naptowncode naptowncode force-pushed the support_.only_for_all_files branch 2 times, most recently from f3ea64f to d3d1652 Compare February 29, 2016 18:04
@naptowncode
Copy link
Contributor Author

@novemberborn I've incorporated those tweaks. If everything looks good, merging this would make it easier to work on #471. Thanks!

@sindresorhus
Copy link
Member

LGTM. @vdemedes @jamestalmage ?

@vadimdemedes
Copy link
Contributor

LGTM from me! @naptowncode could you please resolve the merge conflict? Big thanks for your work, this is an important change!


Runner.prototype.run = function (options) {
options = options || {};
this._reset();
Copy link
Member

Choose a reason for hiding this comment

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

You no longer need the _reset() method now that run is always called.

@naptowncode naptowncode force-pushed the support_.only_for_all_files branch from d3d1652 to 6b1617a Compare March 1, 2016 20:01
@naptowncode
Copy link
Contributor Author

@novemberborn @vdemedes @sindresorhus Updated and rebased. Also added a unit test that should have been there earlier for the .runOnlyExclusive option to Runner.run().

@sindresorhus
Copy link
Member

@naptowncode Tests are failing on Travis it seems: https://travis-ci.org/sindresorhus/ava/builds/112949149

@novemberborn
Copy link
Member

@sindresorhus that's just one test in Node 0.10 though.

@novemberborn
Copy link
Member

@naptowncode LGTM!

@vadimdemedes
Copy link
Contributor

Thank you so much, @naptowncode!

vadimdemedes pushed a commit that referenced this pull request Mar 2, 2016
@vadimdemedes vadimdemedes merged commit 4a1bd79 into avajs:master Mar 2, 2016
@novemberborn
Copy link
Member

Please see #593 for how .only should interact in watch mode.

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.

6 participants