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

Only print fail-fast when there are remaining tests #1179

Merged

Conversation

jarlehansen
Copy link
Contributor

This PR tries to fix #1171 by calculating the remaningCount in run-status.js
And then check the value in the reporters, if there are no remaining test it will not print:

--fail-fast is on. Any number of tests may have been skipped

Copy link
Member

@novemberborn novemberborn 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 taking this on @jarlehansen! Reviewing the PR made me realize we're always printing the message, even if no tests failed, so this is definitely a welcome improvement.

@avajs/core any preference towards showing a "at least 5 tests have been skipped" kind of message, or perhaps "some tests have been skipped"?

@@ -139,6 +140,7 @@ class RunStatus extends EventEmitter {
this.skipCount = sum(this.stats, 'skipCount');
this.todoCount = sum(this.stats, 'todoCount');
this.failCount = sum(this.stats, 'failCount');
this.remainingCount = (this.testCount - (this.passCount + this.failCount));
Copy link
Member

Choose a reason for hiding this comment

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

this.testCount - this.passCount - this.failCount is clearer.

You need to include other test states in this count, see the highlighted lines in https://github.com/avajs/ava/blob/033d4dcdcbdadbf665c740ff450c2a775a8373dc/lib/run-status.js#L41:L45.

The computation should be tested. That's probably best in test/run-status.js, though most of its behavior ends up being tested elsewhere.

test('results without fail-fast if no skipped tests', function (t) {
var reporter = miniReporter();
var runStatus = {
remainingCount: 0,
Copy link
Member

Choose a reason for hiding this comment

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

I think this needs failCount: 1, like with the verbose test?

@jarlehansen
Copy link
Contributor Author

Thanks for the comments, I will wait on #1177 to be merged and then update this PR.

@jarlehansen jarlehansen force-pushed the print-failfast-on-skipped-tests branch 2 times, most recently from 550574b to 2eaadf2 Compare January 15, 2017 19:17
@jarlehansen
Copy link
Contributor Author

I have updated this PR with the changes done by @ThomasBem

@sindresorhus sindresorhus changed the title [WIP] Only print fail-fast when there are remaning tests Only print fail-fast when there are remaining tests Jan 16, 2017
Copy link
Member

@novemberborn novemberborn left a comment

Choose a reason for hiding this comment

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

Thanks @jarlehansen.

@@ -215,7 +215,7 @@ MiniReporter.prototype.finish = function (runStatus) {
});
}

if (runStatus.failFastEnabled === true) {
if (runStatus.failFastEnabled === true && runStatus.remainingCount > 0) {
Copy link
Member

Choose a reason for hiding this comment

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

This should check if there were any failures. Otherwise the warning is also printed when .only() is used and --fail-fast is on:

$ "$(npm bin)"/ava --fail-fast

  1 passed

  `--fail-fast` is on. Any number of tests may have been skipped

  The .only() modifier is used in some tests. 135 tests were not run.

@jarlehansen jarlehansen force-pushed the print-failfast-on-skipped-tests branch from 2eaadf2 to 3f5e68f Compare January 18, 2017 15:41
@jarlehansen
Copy link
Contributor Author

I have included checking runStatus.failCount, also added/updated the tests.

@sindresorhus sindresorhus merged commit 5a3b792 into avajs:master Jan 19, 2017
@sindresorhus
Copy link
Member

Thank you @jarlehansen. This is excellent 👌😄

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.

Don't print --fail-fast reminder if no tests were actually skipped
3 participants