@@ -3,31 +3,41 @@ using Serialization
33@testset " File IO" begin
44 @testset " File" begin
55 data = [1 ,2 ,3 ]
6- data_path = joinpath (tempdir (), " jl_" * join (rand (' a' :' z' , 8 )) * " .jls" )
7- atexit () do
8- @assert isfile (data_path)
9- rm (data_path)
10- end
11- serialize (data_path, data)
6+ # test both absolute and relative paths
7+ dir_abs = tempdir ()
8+ dir_rel = splitpath (mktempdir (pwd ()))[end ]
9+ for dir in [dir_abs, dir_rel]
10+ data_path = joinpath (dir, " jl_" * join (rand (' a' :' z' , 8 )) * " .jls" )
11+ atexit () do
12+ @assert isfile (data_path)
13+ rm (data_path)
14+ end
15+ serialize (data_path, data)
1216
13- data_c = Dagger. File (data_path):: Dagger.File
14- @test fetch (data_c) == data
15- @test fetch (Dagger. @spawn identity (data_c)) == data
17+ data_c = Dagger. File (data_path):: Dagger.File
18+ @test fetch (data_c) == data
19+ @test fetch (Dagger. @spawn identity (data_c)) == data
1620
17- @test isfile (data_path)
21+ @test isfile (data_path)
22+ end
1823 end
1924 @testset " tofile" begin
2025 data = [4 ,5 ,6 ]
21- data_path = joinpath (tempdir (), " jl_" * join (rand (' a' :' z' , 8 )) * " .jls" )
22- atexit () do
23- @assert isfile (data_path)
24- rm (data_path)
25- end
26+ # test both absolute and relative paths
27+ dir_abs = tempdir ()
28+ dir_rel = splitpath (mktempdir (pwd ()))[end ]
29+ for dir in [dir_abs, dir_rel]
30+ data_path = joinpath (dir, " jl_" * join (rand (' a' :' z' , 8 )) * " .jls" )
31+ atexit () do
32+ @assert isfile (data_path)
33+ rm (data_path)
34+ end
2635
27- data_c = Dagger. tofile (data, data_path):: Dagger.File
28- @test fetch (data_c) == data
29- @test fetch (Dagger. @spawn identity (data_c)) == data
36+ data_c = Dagger. tofile (data, data_path):: Dagger.File
37+ @test fetch (data_c) == data
38+ @test fetch (Dagger. @spawn identity (data_c)) == data
3039
31- @test isfile (data_path)
40+ @test isfile (data_path)
41+ end
3242 end
3343end
0 commit comments