Skip to content

Improve watch logging #737

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 8 commits into from
Apr 13, 2016
Merged

Improve watch logging #737

merged 8 commits into from
Apr 13, 2016

Conversation

novemberborn
Copy link
Member

Fixes #670.

  • When the mini and verbose reporters finish, add a timestamp after the first passed/failed/etc status line
  • Ensure the watcher doesn't break the mini reporter's spinner on the first run
  • Ensure the watcher restarts the mini reporter's spinner on subsequent runs
  • Clear the mini reporter on subsequent runs, unless failures occurred or r\n was entered on stdin (because that inserts a line which can't be cleared)

Also includes some test improvements.

@mention-bot
Copy link

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

@novemberborn novemberborn changed the title Improve watch logs Improve watch logging Apr 7, 2016
var tapReporter = tap();
var logger = new Logger(tapReporter);
tapReporter.clear = undefined;
logger.write = t.fail;
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we certain t.fail has it's this value bound in node-tap?

Copy link
Member Author

Choose a reason for hiding this comment

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

@jamestalmage
Copy link
Contributor

Needs a rebase, but LGTM

@novemberborn
Copy link
Member Author

Rebased.

@sindresorhus
Copy link
Member

I like it a lot!

One thing that might make it clearer is to add one more newline between persisted results.
This looks a bit cramped:

screen shot 2016-04-11 at 22 52 17

@novemberborn
Copy link
Member Author

One thing that might make it clearer is to add one more newline between persisted results.
This looks a bit cramped:

@sindresorhus I'm not sure newlines will help. Just pushed a commit that inserts a horizontal sectioning line. No tests yet. Could you have play with that?

@sindresorhus
Copy link
Member

@novemberborn Perfect. Much clearer separation now.

@@ -3,6 +3,7 @@ var prettyMs = require('pretty-ms');
var figures = require('figures');
var chalk = require('chalk');
var plur = require('plur');
var repeatString = require('repeat-string');
Copy link
Member

Choose a reason for hiding this comment

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

Can you use https://github.com/sindresorhus/repeating? We already depend on modules using it, so it would mean no extra dependency.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ha! I knew you'd written one! It didn't show up when searching for string repeat 😄

Copy link
Member

Choose a reason for hiding this comment

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

The npm search sucks... Try http://node-modules.com.

@sindresorhus
Copy link
Member

Tests are failing.

@novemberborn
Copy link
Member Author

Tests are failing.

Yea, probably due to the wip commit. Will patch that up tomorrow.

I'm using toLocaleTimeString() which works even back to Node.js 0.10. Forcing a
24-hour clock because we're geeks.
The CLI starts the logger so the watcher shouldn't reset it on its first run.
Restart the logger after resetting, this allows the mini reporter to render its
spinner.
Return an object for the runStatus, add assertions to verify this object is
passed to logger.finish()
Clear the mini reporter unless the previous run had failures, or "r\n" was
entered on stdin.
Always print two empty lines before each error/rejection/exception when the mini
and verbose reporters finish. Remove trailing whitespace from stack traces.
Always print an empty line after the finish output.

Add a test helper to more easily compare line output, with useful debug
information. At the moment this new helper is only used for failing tests.
@novemberborn
Copy link
Member Author

Updated!

I changed the finish() output as well to be more consistent between the mini and verbose reporters. Each error/rejection/exception is now preceeded by two empty lines. Trailing whitespace is removed from stack traces. There's always an empty line at the end of the finish output.

This means that if the horizontal sectioning line is printed there will always be a single empty line before it, and a single empty line after it. Oh so very tidy! 😜

Watch mode won't clear the mini reporter if there were errors, or "r\n" was
entered on stdin. The verbose reporter can't be cleared at all. To improve the
separation between multiple test runs, write a horizontal line when starting a
new test run and the reporter was not cleared.
@sindresorhus
Copy link
Member

@novemberborn :shipit:

@jamestalmage jamestalmage merged commit 95a5c97 into master Apr 13, 2016
@jamestalmage
Copy link
Contributor

👍 The output looks really slick now!

@supercrabtree
Copy link

Thanks for all your hard work on this, what a pleasant surprise to see in the console this morning. Looks 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.

5 participants