Skip to content

Commit

Permalink
Rewrite juliatests.jl to use new top-level API
Browse files Browse the repository at this point in the history
  • Loading branch information
timholy committed Feb 16, 2019
1 parent 3bb39d7 commit 4e8e63d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 27 deletions.
19 changes: 8 additions & 11 deletions Manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
[[Base64]]
uuid = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"

[[Distributed]]
deps = ["Random", "Serialization", "Sockets"]
uuid = "8ba89e20-285c-5b6f-9357-94700520ee1b"
[[Dates]]
deps = ["Printf"]
uuid = "ade2ca70-3891-5945-98fb-dc099432e06a"

[[InteractiveUtils]]
deps = ["Markdown"]
Expand All @@ -15,12 +15,9 @@ uuid = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
deps = ["Base64"]
uuid = "d6f4376e-aef5-505a-96c1-9c027394607a"

[[Random]]
deps = ["Serialization"]
uuid = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
[[Printf]]
deps = ["Unicode"]
uuid = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[[Serialization]]
uuid = "9e88b42a-f829-5b0c-bbe9-9e923198166b"

[[Sockets]]
uuid = "6462fe0b-24de-5631-8697-dd941f90decc"
[[Unicode]]
uuid = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ version = "0.1.1"
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"

[extras]
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test", "Distributed", "Random"]
test = ["Test", "Distributed", "Random", "Dates"]
66 changes: 51 additions & 15 deletions test/juliatests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using JuliaInterpreter
using Test, Random, InteractiveUtils, Distributed
using Test, Random, InteractiveUtils, Distributed, Dates

# Much of this file is taken from Julia's test/runtests.jl file.

Expand Down Expand Up @@ -69,40 +69,76 @@ move_to_node1("stress")
move_to_node1("Distributed")

@testset "Julia tests" begin
nworkers = min(Sys.CPU_THREADS, length(tests))
println("Using $nworkers workers")
procs = spin_up_workers(nworkers)
# nworkers = min(Sys.CPU_THREADS, length(tests))
# println("Using $nworkers workers")
# procs = nworkers > 1 ? spin_up_workers(nworkers) : (configure_test(); [1])
configure_test()
results = Dict{String,Any}()
tests0 = copy(tests)
@sync begin
for p in procs
@async begin
oldpath = current_task().storage[:SOURCE_PATH]
# @sync begin
# for p in procs
# @async begin
while length(tests) > 0
test = popfirst!(tests)
local resp
wrkr = p
# wrkr = p
fullpath = test_path(test) * ".jl"
try
resp = remotecall_fetch(dotest, p, test, fullpath, nstmts)
# r = @spawnat p begin
# These must be run at top level, so we can't put this in a function
println("Working on ", test, "...")
Core.eval(Main, :(
module JuliaTests
using Test, Random
end
))
ex = read_and_parse(fullpath)
isexpr(ex, :error) && @error "error parsing $test: $ex"
aborts = Aborted[]
ts = Test.DefaultTestSet(test)
Test.push_testset(ts)
current_task().storage[:SOURCE_PATH] = fullpath
try
frames, _ = JuliaInterpreter.prepare_toplevel(JuliaTests, ex)
stack = JuliaStackFrame[]
for (i, frame) in enumerate(frames) # having the index is useful for debugging
nstmtsleft = nstmts
while true
ret, nstmtsleft = evaluate_limited!(stack, frame, nstmtsleft)
isa(ret, Some{Any}) && break
isa(ret, Aborted) && (push!(aborts, ret); break)
end
end
finally
current_task().storage[:SOURCE_PATH] = oldpath
end
println("Finished ", test)
# return ts, aborts
# end
# resp = fetch(r)
resp = ts, aborts
catch e
isa(e, InterruptException) && return
resp = e
if isa(e, ProcessExitedException)
p = spin_up_workers(1)[1]
end
# if isa(e, ProcessExitedException)
# p = spin_up_workers(1)[1]
# end
end
results[test] = resp
if resp isa Exception && exit_on_error
skipped = length(tests)
empty!(tests)
end
end
end
end
end
# end
# end
# end

open("results.md", "w") do io
versioninfo(io)
println(io, "Test run at: ", now())
println(io)
println(io, "Maximum number of statements per lowered expression: ", nstmts)
println(io)
println(io, "| Test file | Passes | Fails | Errors | Broken | Aborted blocks |")
Expand Down

0 comments on commit 4e8e63d

Please sign in to comment.