diff --git a/.JuliaFormatter.toml b/.JuliaFormatter.toml new file mode 100644 index 0000000..323237b --- /dev/null +++ b/.JuliaFormatter.toml @@ -0,0 +1 @@ +style = "blue" diff --git a/test/robust_pmap.jl b/test/robust_pmap.jl index 501618b..9b1f125 100644 --- a/test/robust_pmap.jl +++ b/test/robust_pmap.jl @@ -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 @@ -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)) @@ -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