-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move
test_save_load_roundtrip
to init file (#2801)
- Loading branch information
1 parent
b493a8e
commit db6a5f9
Showing
6 changed files
with
57 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# This code is needed for multiple test files that may end up on different workers. | ||
# Thus, this needs to be conditionally included in each of these test files. | ||
|
||
function test_save_load_roundtrip(func, path, original::T; params=nothing) where {T} | ||
# save and load from a file | ||
filename = joinpath(path, "original.json") | ||
save(filename, original) | ||
loaded = load(filename; params=params) | ||
if T <: Vector | ||
@test loaded isa Vector | ||
else | ||
@test loaded isa T | ||
end | ||
func(loaded) | ||
|
||
# save and load from an IO buffer | ||
io = IOBuffer() | ||
save(io, original) | ||
seekstart(io) | ||
loaded = load(io; params=params) | ||
|
||
if T <: Vector | ||
@test loaded isa Vector | ||
else | ||
@test loaded isa T | ||
end | ||
func(loaded) | ||
|
||
# save and load from an IO buffer, with prescribed type | ||
io = IOBuffer() | ||
save(io, original) | ||
seekstart(io) | ||
loaded = load(io; type=T, params=params) | ||
if T <: Vector | ||
@test loaded isa Vector | ||
else | ||
@test loaded isa T | ||
end | ||
func(loaded) | ||
|
||
# test loading on a empty state | ||
save(filename, original) | ||
reset_global_serializer_state() | ||
loaded = load(filename; params=params) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,8 +104,6 @@ end | |
Base.cumulative_compile_timing(true) | ||
end | ||
|
||
println("Making test list") | ||
|
||
testlist = [ | ||
|
||
"Aqua.jl", | ||
|