Skip to content

Better logging #88

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 2 commits into from
Jul 2, 2019
Merged

Better logging #88

merged 2 commits into from
Jul 2, 2019

Conversation

szeiger
Copy link
Contributor

@szeiger szeiger commented Jun 28, 2019

szeiger added 2 commits June 28, 2019 22:27
- "Test run started/finished" messages include class name.
- More useful verbosity settings with a new option to show only the
  (now more useful) "Test run finished" messages.
- Optional summary with more details.
Copy link
Contributor

@benmccann benmccann left a comment

Choose a reason for hiding this comment

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

It's nice to see the project getting some love! Can you share an example of the default output when all the tests are passing and when one is failing? It's an area that's caused issues in this project in the past, so I wanted to make sure it's what users are expecting. Thanks!

ju.addListener(ed);
if (runner.runListener != null) ju.addListener(runner.runListener);

Map<String, Object> oldprops = settings.overrideSystemProperties();
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment explaining why this is necessary? I'm not exactly sure what it's doing, but it seems a little hackish and I wonder if there isn't a better way

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's more than a little hackish but this is all old code that I only moved around. No actual changes here.

@@ -151,12 +158,16 @@ void logTo(RichLogger logger) {
private void postIfFirst(AbstractEvent e)
{
e.logTo(logger);
if(reported.add(e.fullyQualifiedName())) handler.handle(e);
if(reported.add(e.fullyQualifiedName())) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I generally would put a space after if, for, etc. Can we consider changing throughout this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These extra spaces always look wrong to me. Most of the code here is probably without spaces (unless someone else rewrote it in the mean time). My style changed over time to put opening braces at the end of the line even in Java and this is inconsistent in the codebase, too. This could be made consistent in a separate PR but honestly I'm not too bothered by it.

}

@Override
public String done() {
return "";
// Can't simply return the summary due to https://github.com/sbt/sbt/issues/3510
if(!used) return "";
Copy link
Contributor

Choose a reason for hiding this comment

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

It'd be nice to use multi-line curly braces:

if (!used) {
  return "";
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This just looks convoluted to me. I know many people like this style but I have no idea why.

@szeiger
Copy link
Contributor Author

szeiger commented Jul 2, 2019

Can you share an example of the default output when all the tests are passing and when one is failing?

The default output hasn't changed at all and neither has the meaning of the existing options. The only visible change is when using -v (which is now the same as --verbosity=2 or enabling debug logging:

[info] Test run test.TestOne started
[info] Test test.TestOne.fast started
[info] Test test.TestOne.fast finished, took 0.008 sec
[info] Test test.TestOne.none started
[info] Test test.TestOne.none finished, took 0.001 sec
[info] Test run test.TestOne finished: 0 failed, 0 ignored, 2 total, 0.014s

The "Test run" lines didn't have any test name in them before. Now they contain the name that was seen by sbt as the test case (in this case test.TestOne).

With the new --verbosity=1 option you get only the "Test run finished" lines (unless there's a failure):

[info] Test run test.TestOne finished: 0 failed, 0 ignored, 2 total, 0.014s

This new mode only makes sense with the addition of the test names in these lines.

@szeiger
Copy link
Contributor Author

szeiger commented Jul 2, 2019

For anyone looking at the code, the nomenclature will be confusing. I didn't make any changes in this regard and I also think it is good on the user-facing side but sbt uses confusing names in the test interface.

  • "Test run" in user-facing texts means an instance of sbt.testing.Task. In JUnit terms it is also called a "run", corresponding to a single instance of JUnitCore and a single call to JUnitCore#run.
  • "Task" means an execution of an sbt task (like test or testOnly), which corresponds to an instance of sbt.testing.Runner.

@benmccann benmccann merged commit 2018357 into sbt:master Jul 2, 2019
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