Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .JuliaFormatter.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
style = "blue"
47 changes: 38 additions & 9 deletions test/robust_pmap.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,35 @@
i += 1
throw(err)
end
isodd(x)
return isodd(x)
end
return throw_isodd
end

# Check other errors don't retry
throw_isodd = make_throw_isodd(ErrorException("Error"))
@test_throws ErrorException robust_pmap(throw_isodd, input)
throw_isodd = make_throw_isodd(ErrorException("Error123"))
if VERSION < v"1.8-"
@test_throws ErrorException robust_pmap(throw_isodd, input)
else
@test_throws "Error123" robust_pmap(throw_isodd, input)
end

# Check ProcessExitedException is retried
throw_isodd = make_throw_isodd(ProcessExitedException())
@test robust_pmap(throw_isodd, input) == expected
# Check retries are logged
throw_isodd = make_throw_isodd(ProcessExitedException())
@test_log LOGGER "info" ("Retrying", "ProcessExitedException") robust_pmap(throw_isodd, input)
@test_log LOGGER "info" ("Retrying", "ProcessExitedException") robust_pmap(
throw_isodd, input
)
# Check with lower number of retrys
throw_isodd = make_throw_isodd(ProcessExitedException())
@test_throws ProcessExitedException robust_pmap(throw_isodd, input, num_retries=1)
if VERSION < v"1.8-"
@test_throws ProcessExitedException robust_pmap(throw_isodd, input, num_retries=1)

else
@test_throws "ProcessExitedException" robust_pmap(throw_isodd, input, num_retries=1)
end
# ArgumentErrors with this message should be retried
throw_isodd = make_throw_isodd(ArgumentError("stream is closed or unusable"))
@test robust_pmap(throw_isodd, input) == expected
Expand All @@ -37,14 +47,29 @@
@test_log LOGGER "info" ("Retrying", "ArgumentError") robust_pmap(throw_isodd, input)
# Check with lower number of retrys
throw_isodd = make_throw_isodd(ArgumentError("stream is closed or unusable"))
@test_throws ArgumentError robust_pmap(throw_isodd, input, num_retries=1)
if VERSION < v"1.8-"
@test_throws ArgumentError robust_pmap(throw_isodd, input, num_retries=1)
else
@test_throws "stream is closed or unusable" robust_pmap(
throw_isodd, input, num_retries=1
)
end

# Other ArgumentErrors should not be retried
throw_isodd = make_throw_isodd(ArgumentError("stream is open but other stuff is wrong"))
@test_throws ArgumentError robust_pmap(throw_isodd, input)
if VERSION < v"1.8-"
@test_throws ArgumentError robust_pmap(throw_isodd, input)
else
@test_throws "stream is open but other stuff is wrong" robust_pmap(
throw_isodd, input
)
end
# No retries should mean no log of retries
throw_isodd = make_throw_isodd(ArgumentError("stream is open but other stuff is wrong"))
@test_nolog LOGGER "info" "Retrying" try robust_pmap(throw_isodd, input) catch end
@test_nolog LOGGER "info" "Retrying" try
robust_pmap(throw_isodd, input)
catch
end

# Check IOError is retried
throw_isodd = make_throw_isodd(Base.IOError("msg", 1))
Expand All @@ -54,5 +79,9 @@
@test_log LOGGER "info" ("Retrying", "IOError") robust_pmap(throw_isodd, input)
# Check with lower number of retrys
throw_isodd = make_throw_isodd(Base.IOError("msg", 1))
@test_throws Base.IOError robust_pmap(throw_isodd, input, num_retries=1)
if VERSION < v"1.8-"
@test_throws Base.IOError robust_pmap(throw_isodd, input, num_retries=1)
else
@test_throws "msg" robust_pmap(throw_isodd, input, num_retries=1)
end
end