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

[WIP] Help wanted: switch Base.Test to use testsets everywhere #17165

Closed
wants to merge 9 commits into from

Conversation

kshyatt
Copy link
Contributor

@kshyatt kshyatt commented Jun 28, 2016

We have all this great testing infrastructure we're not using. I changed test/runtests.jl to collect @testset results from files and generate a nice report at the end, also using @timed for more statistics (gc time!) instead of @elapsed. But we have some problems:

  • not sure how to work with parallel{_exec}.jl and boundscheck{_exec}.jl - need to pass testset results along from the exec files.
  • test/test.jl is broken because of changes I made!
  • Make printing more attractive - somewhat done, now sending error and failure info to STDERR which it seems to me we should have been doing all along. Need to print error backtraces still. Should we align the gc time/memory info I have?
  • Tests may be much slower now
  • Make sure that packages can use this as a drop-in no-effort replacement
  • print the error backtraces right
  • return max_rss as part of the tuple in runtests
  • the build needs to not time out/segfault

I would really appreciate help with any/all of this. cc: @ranjanan

@kshyatt kshyatt added the test This change adds or pertains to unit tests label Jun 28, 2016
@StefanKarpinski
Copy link
Member

This is really nice. The test output is even nicer than the way you write the tests.

@KristofferC
Copy link
Member

I thought the reason we didn't use testset is because the output was a bit too verbose. Did something change regarding this? @tkelman

@kshyatt
Copy link
Contributor Author

kshyatt commented Jun 28, 2016

@KristofferC the output doesn't have to be verbose if you nest your @testsets properly, which we can & will modify the files in test to do. I'll post a screenshot example or you can checkout the branch, deliberately mess up a test in test/math.jl, and run make test-math to see what happens.

@StefanKarpinski
Copy link
Member

Yes, @kshyatt did a bunch of work to make the output look nice.

@quinnj
Copy link
Member

quinnj commented Jun 28, 2016

Why would existing tests "not work"? (i.e dates/ranges.jl?)

@kshyatt
Copy link
Contributor Author

kshyatt commented Jun 28, 2016

@quinnj Wrapping dates/ranges in a @testset is making a bunch of the tests fail.

Specifically:

@test length(a:Dates.Year(1):Dates.Date(2020,2,1)) == 8
@test length(a:Dates.Year(1):Dates.Date(2020,6,1)) == 8
@test length(a:Dates.Year(1):Dates.Date(2020,11,1)) == 8
@test length(a:Dates.Year(1):Dates.Date(2020,12,31)) == 8
@test length(a:Dates.Year(1):Dates.Date(2021,1,1)) == 9

Don't work.

@ranjanan
Copy link
Contributor

ranjanan commented Jun 28, 2016

@kshyatt I get an error in dates/arithmetic.jl at

@test (Date(2009,1,1):Week(1):Date(2009,1,21)) - (Date(2009,1,1):Day(1):Date(2009,1,3)) == [0d, 6d, 12d]

with UndefVarError for d

@kshyatt
Copy link
Contributor Author

kshyatt commented Jun 28, 2016

@ranjanan Me too, I'm fixing it now. linalg/arnoldi is also broken.

@tkelman
Copy link
Contributor

tkelman commented Jun 28, 2016

It seems like the top-level testset per file could probably just be figured out from the filename automatically, either in Base.Test or test/runtests.jl, instead of included by hand?

@kshyatt
Copy link
Contributor Author

kshyatt commented Jun 28, 2016

It seems like the top-level testset per file could probably just be figured out from the filename automatically, either in Base.Test or test/runtests.jl, instead of included by hand?

This might be annoying for the subdirectories like linalg, strings, etc. though

@ranjanan
Copy link
Contributor

@kshyatt #17171 fixes dates/arithmetic.jl tests

@kshyatt
Copy link
Contributor Author

kshyatt commented Jun 28, 2016

OK I've updated the PR with some fixes. I'll cherry-pick @ranjanan's fixes as well in a bit.

@tkelman
Copy link
Contributor

tkelman commented Jun 28, 2016

for the subdirectories

That would be a good reason to do the nice version in Base.Test - maybe @testset include could be rewritten to this?

@StefanKarpinski
Copy link
Member

Let's keep it simple for now. We can refine the mechanisms later.

@kshyatt
Copy link
Contributor Author

kshyatt commented Jul 2, 2016

I've updated this PR a bunch! @StefanKarpinski @tkelman @ranjanan thoughts? @carnaval is the gc info we are printing useful to you?

@kshyatt
Copy link
Contributor Author

kshyatt commented Jul 2, 2016

The top-level modules in enums and docs are breaking on remote workers with an UndefVarError - anyone know why?

# Finally throw an error as we are the outermost test set
if total != total_pass
#print_test_results(ts)
Copy link
Member

Choose a reason for hiding this comment

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

Whats happening here now?

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 changed things so that now only the King of the Nodes outputs anything. Otherwise we were getting horrendous looking spam from each worker.

Copy link
Member

Choose a reason for hiding this comment

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

So am I reading this right: if I'm just a general package, and I'm using Base.Test, there will be no output from test sets?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You can dump it explicitly with Base.Test.print_test_results(Base.Test.get_testset()) but yeah, it would be silent unless things fail. There's a reason I put WIP on this. I wish I could put bold in titles: WIP. Ideally I think we'd have a verbose/quiet flag you could pass depending if you want output or not. It would be good to just let packages use test/runtests.jl themselves, rather than hacking their own weird fake parallel testing together like happens now.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I see. I was thinking that the solution for the Base testing setting would be making a different kind of test set, or as you say, maybe DefaultTestSet can have an option.

@MichaelHatherly
Copy link
Member

docs are breaking

@kshyatt I'll try sort out the docs tests later tonight or tomorrow if possible. They probably need a bit of reorganisation since there's several modules in there that definitely won't like being wrapped in @testset.

@kshyatt
Copy link
Contributor Author

kshyatt commented Jul 2, 2016

@MichaelHatherly I don't think you should have to change anything. People should be able to write tests around custom modules! The problem is deserializing the module in the test file as it comes in from the remote worker. I need to figure out how to import the test module onto the master worker.

Since the docs and enums tests don't take very long, perhaps the best choice is just to run them on node1 with compile and parallel?

@MichaelHatherly
Copy link
Member

OK, cool. That sounds much simpler.

@kshyatt
Copy link
Contributor Author

kshyatt commented Jul 2, 2016

Things are currently erroring out because we (ironically) have too many tests. I'm going to set it to get the test counts before it sends the message, and only send the full TestSet in the case of a failure/error.

@kshyatt
Copy link
Contributor Author

kshyatt commented Jul 3, 2016

screen shot 2016-07-02 at 22 20 29
@KristofferC @StefanKarpinski pretty enough?

@kshyatt kshyatt added testsystem The unit testing framework and Test stdlib and removed test This change adds or pertains to unit tests labels Jul 3, 2016
@nalimilan
Copy link
Member

Cool! If you want to make the output as pretty as possible, you could use the box-drawing character for vertical lines.

@@ -793,5 +793,4 @@ mktempdir() do dir
end
end
=#
end
Copy link
Contributor

Choose a reason for hiding this comment

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

this will probably be a syntax error and not bisect, should be squashed into whichever commit added it

@@ -104,14 +133,28 @@ cd(dirname(@__FILE__)) do
end
println()
Base.Test.print_test_results(o_ts,1)
#pretty print the information about gc and mem usage
name_align = maximum(map(x -> length(x[1]), results))
Copy link
Contributor

Choose a reason for hiding this comment

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

note for later, should also consider the length of the "Test:" header line here

@@ -366,3 +366,5 @@ end
@test Dates.Date("Apr 01 2014", "uuu dd yyyy") == Dates.Date(2014,4,1)
@test_throws ArgumentError Dates.Date("Apr 01 xx 2014", "uuu dd zz yyyy")
@test_throws ArgumentError Dates.Date("Apr 01 xx 2014", "uuu dd yyyy")

end
Copy link
Contributor

Choose a reason for hiding this comment

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

this was probably needed earlier to pass at intermediate commits

@@ -427,6 +427,7 @@ mktempdir() do dir
finally
finalize(repo)
end
end
Copy link
Contributor

Choose a reason for hiding this comment

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

probably needs to be added earlier

@@ -1788,6 +1788,8 @@ for op in (:.+, :.*, :.÷, :.%, :.<<, :.>>, :.-, :./, :.\, :.//, :.^)
@eval @test typeof($(op)(A,A)) == Matrix{Foo}
end

end
Copy link
Contributor

Choose a reason for hiding this comment

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

this was mistakenly deleted in an earlier commit, in order for intermediate commits to pass the re-addition should be squashed into the same commit that deleted it

@@ -794,6 +799,5 @@ mktempdir() do dir
end
end
=#
end
Copy link
Contributor

@tkelman tkelman Sep 29, 2016

Choose a reason for hiding this comment

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

I see what happened. You want to end the now-commented-out @testset "SSH" begin also inside the block comment

@StefanKarpinski
Copy link
Member

I propose that we just squash and merge this now that it's passing CI. I don't think it's worth the additional pain and suffering just to get a series of commits out of this that realistically no one is ever going to care about.

@tkelman
Copy link
Contributor

tkelman commented Sep 29, 2016

OK.

Follow-up for later PR: printing of @test true or @test 1==1 should be adjusted to not bother showing Expression: nothing

catch ex
#redirect_stdout(OLD_STDOUT)
#redirect_stderr(OLD_STDERR)
#@show ex
Copy link
Contributor

@tkelman tkelman Sep 29, 2016

Choose a reason for hiding this comment

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

leftover debugging comments? the following tests need to test ex , not ts

edit: so this should output ex in the catch too

@kshyatt
Copy link
Contributor Author

kshyatt commented Sep 30, 2016

The pretty version got merged. Let this PR be a graveyard of intermediate screencaps.

edit by tkelman: that was #18738

@tkelman
Copy link
Contributor

tkelman commented Dec 15, 2016

I presume returning correct data for the *_exec tests will be done in a different PR?

@amitmurthy did that ever get fixed?

@amitmurthy
Copy link
Contributor

Looking at the code, not yet.

@tkelman
Copy link
Contributor

tkelman commented Dec 16, 2016

Should/can we open an issue to track that?

@amitmurthy
Copy link
Contributor

Sure. I'll do it in a bit.

@amitmurthy
Copy link
Contributor

Ref: #19620

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.