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

Add verbose option to @testset #33755

Merged
merged 2 commits into from
Nov 6, 2020
Merged

Add verbose option to @testset #33755

merged 2 commits into from
Nov 6, 2020

Conversation

ronisbr
Copy link
Member

@ronisbr ronisbr commented Nov 3, 2019

This addresses a feature I proposed in #27088 (sorry for the delay 😊). The idea is to provide a mean to @testset to print child results even though all of them passed. IMHO (as I mentioned in the issue), the default behavior starts to become a problem when you have a very big package and wants to be sure that all necessary tests are working.

The way I coded is very simple: if verbose = true is passed to @testset, then the statistics of the children will be printed regardless of the test results. Notice that this does not affect the children of the children.

Thus, if we have:

using Test

@testset "Parent" verbose = true begin
    @testset "Child 1" verbose = true begin
        @testset "Child 1.1" begin
            @test 1 == 1
        end

        @testset "Child 1.2" begin
            @test 1 == 1
        end

        @testset "Child 1.3" begin
            @test 1 == 1
        end
    end

    @testset "Child 2" begin
        @testset "Child 2.1" begin
            @test 1 == 1
        end

        @testset "Child 2.2" begin
            @test 1 == 1
        end

        @testset "Child 2.3" begin
            @test 1 == 1
        end
    end

    @testset "Child 3" verbose = true begin
        @testset "Child 3.1" begin
            @test 1 == 1
        end

        @testset "Child 3.2" begin
            @test 1 == 1
        end

        @testset "Child 3.3" begin
            @test 1 == 1
        end
    end
end

we will get:

Test Summary: | Pass  Total
Parent        |    9      9
  Child 1     |    3      3
    Child 1.1 |    1      1
    Child 1.2 |    1      1
    Child 1.3 |    1      1
  Child 2     |    3      3
  Child 3     |    3      3
    Child 3.1 |    1      1
    Child 3.2 |    1      1
    Child 3.3 |    1      1

Notice that I chose to do not print the results of Child 2.

P.S.: In this PR, I added the functionality and the test so that we can discuss. After discussing, I can add the documentation as well.

@ronisbr ronisbr changed the title Add verbose option to testset Add verbose option to @testset Nov 3, 2019
@ronisbr
Copy link
Member Author

ronisbr commented Nov 15, 2019

Bump! :)

@gasagna
Copy link
Contributor

gasagna commented Nov 16, 2019

I'd like to be able to specify the "depth of verbosity" with an option like verbose_depth and in some cases do not print anything at all, if verbose_depth=0.

@ronisbr
Copy link
Member Author

ronisbr commented Nov 16, 2019

Wouldn't it add unnecessary complications? I mean, with the current proposal, you can do that. Moreover, what would be the expected behavior if a parent has verbose_depth = 10 and the children verbose_depth = 1?

@ronisbr
Copy link
Member Author

ronisbr commented Dec 7, 2019

Bump # 2 :)

@ViralBShah
Copy link
Member

Who would be the right person to review? @KristofferC ?

@ronisbr
Copy link
Member Author

ronisbr commented Dec 7, 2019

Looking at the commits to Test stdlib package, yes, I do think so.

@ronisbr
Copy link
Member Author

ronisbr commented Jan 6, 2020

Bump # 3 :)

@ronisbr
Copy link
Member Author

ronisbr commented Feb 7, 2020

Bump # 4

@StefanKarpinski StefanKarpinski added the triage This should be discussed on a triage call label Feb 8, 2020
@StefanKarpinski
Copy link
Member

Marking for triage so that this gets discussed.

@ronisbr
Copy link
Member Author

ronisbr commented May 6, 2020

Bump # 5 :) (please, tell me if this should be closed or if this is not the right time to implement such change)

@ronisbr
Copy link
Member Author

ronisbr commented Nov 2, 2020

Hi!

Is there any chance to consider this modification for Julia 1.6?

Copy link
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.

Needs a rebase, but sgtm

@ronisbr
Copy link
Member Author

ronisbr commented Nov 3, 2020

Nice! I will rebase then. Thanks for the feedback @vtjnash !

The `verbose` option in `@testset` can be used to print the results
of the childs even though all of them has passed.

Closes #27088
@ronisbr
Copy link
Member Author

ronisbr commented Nov 4, 2020

@vtjnash Done! The test failure in macOS does not seem related to this PR.

@vtjnash vtjnash merged commit 68c71f5 into JuliaLang:master Nov 6, 2020
@simeonschaub simeonschaub added testsystem The unit testing framework and Test stdlib and removed triage This should be discussed on a triage call labels Nov 12, 2020
@ronisbr ronisbr deleted the test_verbose branch February 27, 2021 04:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
testsystem The unit testing framework and Test stdlib
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants