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

RFC: Add information to passing tests #36879

Merged
merged 1 commit into from
May 29, 2021

Conversation

mmiller-max
Copy link
Contributor

@mmiller-max mmiller-max commented Aug 2, 2020

Closes #25483.

Summary

With this PR, the information (tested expression and the value) of a succfessul test will be stored in the Pass Result rather than these fields being set to nothing. This will be the case for both @test and @test_throws. There will be no change to DefaultTestSet behaviour, as the current behaviour of record(ts:DefaultTestSet, t::Pass) discards any information in the Pass result and just increments the number of successful tests. Storing the information allows other testsets to use this information, for example in test report generation.

More info

Following the discussion in the issue, it seems like the changes made by #20150 mean that information can be stored when tests Pass as the whole result is discarded by DefaultTestSets.

This allows other CustomTestSets to use this information, which is important if this information is required, for example by a test case management suite.

@mmiller-max mmiller-max changed the title Add information to passing tests WIP: Add information to passing tests Aug 2, 2020
@mmiller-max mmiller-max changed the title WIP: Add information to passing tests RFC: Add information to passing tests Aug 3, 2020
@mmiller-max
Copy link
Contributor Author

To retain the same output for a Pass as before this PR, Base.show needed to be modified. I think the code that I removed from Base.show was never being used (as those fields were always nothing) but this needs confirming by someone with a wider knowledge than me.

This PR is ready for a code review.

@mmiller-max
Copy link
Contributor Author

Please can someone review this? Cheers

@StefanKarpinski
Copy link
Sponsor Member

Giving a summary of the effect of this would be helpful. Who would be good to review? GitHub suggests @JeffBezanson, but that may just be because the did some sweeping change that touched this code.

@timholy
Copy link
Sponsor Member

timholy commented Aug 5, 2020

Maybe @oxinabox who filed the issue.

Would also be great to see some numbers on whether/how this affects the time to run Julia's own tests.

@mmiller-max
Copy link
Contributor Author

Thanks both for your comments.

I'll run a comparison on make test-all (if that's the best way to do it?) tonight (Australian time), and here's a brief summary of the effect:

With this PR, the information (tested expression and the value) of a succfessul test will be stored in the Pass Result rather than these fields being set to nothing. This will be the case for both @test and @test_throws. There will be no change to DefaultTestSet, as the current behaviour of record(ts:DefaultTestSet, t::Pass) discards any information in the Pass result and just increments the number of successful tests. Storing the information allows other testsets to use this information, for example in test report generation.

The storing of information in the Pass object means that Base.show(io::IO, t::Pass) has to be modified so that the output when a test passes is unchanged. The removed lines from this function print the Pass information if not nothing, which on master it always is and therefore the printing was never being done. I think removing these lines should have no effect.

@mmiller-max
Copy link
Contributor Author

mmiller-max commented Aug 8, 2020

Julia test times averaged across two runs:

With this PR: 42.5 mins
On a master commit (7c0cb30): 44.5 mins

The difference could be just what else was running on my machine at the same time, it would be useful if someone else could repeat the test so the results don't just rely on one laptop.

I have been struggling to actually run Julia's tests as the generating precompile statements step hangs (>1 hr) whilst building, so have had to resort to running make test-all inside a container. This in turns means the sockets and file tests fail, but hopefully its still representative. The same failures occur with and without the changes. (Any help with this would be appreciated, but don't want to cloud up this PR).

@oxinabox
Copy link
Contributor

Maybe @oxinabox who filed the issue.

Note that @mmiller-max is now working on the package that I was working on when I filed that issue.
(TestReports.jl)

I will review this PR presently

Copy link
Contributor

@oxinabox oxinabox left a comment

Choose a reason for hiding this comment

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

I think this needs tests that it actually is storing the correct thing.

elseif t.test_type === :test && t.data !== nothing
# The test was an expression, so display the term-by-term
# evaluated version as well
print(io, "\n Evaluated: ", t.data)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't we want to display this?
Given someone has created a test result object, why not show its fields?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can see it being argued either way.

One the one hand the information is there so why not display it to give the user more information, but on the other hand if a test has passed the user may not want the details of the passing of that test to fill up the REPL. I typically only see the Test Passed output when manually stepping through tests to find the failing ones, and wouldn't be interested in knowing the details of the ones that passed. Normally the tests are in testsets and therefore the pass information isn't shown either way.

I kept it to the latter as that's what was originally happening before the changes here, albeit because that information wasn't stored so couldn't be displayed anyway.

I'm leaning towards not displaying it, but its definitely worth a discussion.

Copy link
Contributor

@oxinabox oxinabox Aug 13, 2020

Choose a reason for hiding this comment

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

Fair enough. I am not sure when this is displayed, except if @test is used on its out, in the REPL.
do @testsets call display on the tests with in them? If so, i agree we want to minimize noise and not display this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it's only displayed when @test is used on its own in the REPL, as you say. @testsets do not call display so makes no difference for them.

I still think it is more helpful to not display this information, but actually thinking about it @test_throws already displays the exception type, so to be consistent we should either remove that printing too, or keep them all in.

Is this a question for slack/a wider group of people?

Current situation is:

julia> @test 1==1
Test Passed
julia> @test_throws ErrorException throw(ErrorException("Msg"))
Test Passed
      Thrown: ErrorException

Full printing:

julia> @test 1==1
Test Passed
  Expression: 1 == 1
   Evaluated: 1 == 1

julia> @test_throws ErrorException throw(ErrorException("Msg"))
Test Passed
  Expression: throw(ErrorException("Msg"))
      Thrown: ErrorException

Or no printing:

julia> @test 1==1
Test Passed
julia> @test_throws ErrorException throw(ErrorException("Msg"))
Test Passed

stdlib/Test/src/Test.jl Outdated Show resolved Hide resolved
@mmiller-max
Copy link
Contributor Author

Bump.

I think the following two points need addressing to move this PR forward:

  1. Deciding on the test output, as per this discussion. Who needs to be involved with the decision?
  2. Getting someone else to do a benchmark to check performance of Julia's tests.

Cheers

@StefanKarpinski StefanKarpinski added the triage This should be discussed on a triage call label Nov 16, 2020
@mmiller-max
Copy link
Contributor Author

Bump

Just wondering if this has been discussed on a triage call or if that's still pending?

@vtjnash vtjnash removed the triage This should be discussed on a triage call label Apr 22, 2021
@vtjnash
Copy link
Sponsor Member

vtjnash commented Apr 22, 2021

This looks fine to me. We needed to make sure not to store the information (by default), but it didn't need to be removed this early. Please ping me when you rebase for review. For the questions:

  1. Please remove the printing changes, as those aren't applicable to the rest of the PR and will let us merge this without issue.
  2. If it passes on CI, that should be good enough for confirming performance is good.

@mmiller-max mmiller-max force-pushed the mm/add-test-pass-information branch 2 times, most recently from 2380b12 to d2a3576 Compare April 27, 2021 22:50
@mmiller-max
Copy link
Contributor Author

@vtjnash thanks for following up. Rebased and ready for another review. Without the changes for printing there are quite a few doctest changes due to Passes now containing information that can be printed.

Copy link
Sponsor Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

lgtm

@vtjnash vtjnash added the forget me not PRs that one wants to make sure aren't forgotten label Apr 28, 2021
@vtjnash vtjnash merged commit 6b10500 into JuliaLang:master May 29, 2021
@simeonschaub simeonschaub removed the forget me not PRs that one wants to make sure aren't forgotten label May 29, 2021
shirodkara pushed a commit to shirodkara/julia that referenced this pull request Jun 9, 2021
johanmon pushed a commit to johanmon/julia that referenced this pull request Jul 5, 2021
nickrobinson251 added a commit to nickrobinson251/julia that referenced this pull request Jan 14, 2022
This restores the behaviour of how `@test` shows
a test pass in Julia v1.0 - v1.6, reverting the
display changes that resulted when we began storing
more info in the `Pass` type in JuliaLang#36879.
Closes JuliaLang#43794.
nickrobinson251 added a commit to nickrobinson251/julia that referenced this pull request Jan 14, 2022
This restores the behaviour of how `@test` shows
a test pass in Julia v1.0 - v1.6, reverting the
display changes that resulted when we began storing
more info in the `Pass` type in JuliaLang#36879.
Closes JuliaLang#43794.
nickrobinson251 added a commit to nickrobinson251/julia that referenced this pull request Jan 14, 2022
This restores the behaviour of how `@test` shows
a test pass in Julia v1.0 - v1.6, reverting the
display changes that resulted when we began storing
more info in the `Pass` type in JuliaLang#36879.
Closes JuliaLang#43794.
fredrikekre pushed a commit that referenced this pull request Jan 14, 2022
This restores the behavior of how `at-test` shows a test pass in Julia
v1.0 - v1.6, reverting the display changes introduced when
storing more info in the `Pass` type in #36879, closes #43794.
N5N3 pushed a commit to N5N3/julia that referenced this pull request Jan 24, 2022
This restores the behavior of how `at-test` shows a test pass in Julia
v1.0 - v1.6, reverting the display changes introduced when
storing more info in the `Pass` type in JuliaLang#36879, closes JuliaLang#43794.
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Feb 22, 2022
This restores the behavior of how `at-test` shows a test pass in Julia
v1.0 - v1.6, reverting the display changes introduced when
storing more info in the `Pass` type in JuliaLang#36879, closes JuliaLang#43794.
LilithHafner pushed a commit to LilithHafner/julia that referenced this pull request Mar 8, 2022
This restores the behavior of how `at-test` shows a test pass in Julia
v1.0 - v1.6, reverting the display changes introduced when
storing more info in the `Pass` type in JuliaLang#36879, closes JuliaLang#43794.
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 discard all information about passing tests immidately
6 participants