From a9775b038cfbd9e23aaecec0e645cc0e87a2daad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20G=C3=B6ttgens?= Date: Fri, 15 Sep 2023 11:17:29 +0200 Subject: [PATCH] Address comment --- experimental/FTheoryTools/test/tate.jl | 6 +++++- experimental/QuadFormAndIsom/test/runtests.jl | 4 ++++ test/Serialization/runtests.jl | 4 +++- .../{init_tests.jl => test_save_load_roundtrip.jl} | 9 ++++----- test/runtests.jl | 2 -- 5 files changed, 16 insertions(+), 9 deletions(-) rename test/Serialization/{init_tests.jl => test_save_load_roundtrip.jl} (77%) diff --git a/experimental/FTheoryTools/test/tate.jl b/experimental/FTheoryTools/test/tate.jl index 7e97626f0cf3..e054dfa5b3f9 100644 --- a/experimental/FTheoryTools/test/tate.jl +++ b/experimental/FTheoryTools/test/tate.jl @@ -30,9 +30,13 @@ t = global_tate_model(base; completeness_check = false) @test is_smooth(ambient_space(t)) == false @test toric_variety(calabi_yau_hypersurface(t)) == ambient_space(t) + isdefined(Main, :test_save_load_roundtrip) || include( + joinpath(Oscar.oscardir, "test", "Serialization", "test_save_load_roundtrip.jl") + ) + mktempdir() do path test_save_load_roundtrip(path, t) do loaded - @test tate_polynomial(loaded) == tate_polynomial(t) + @test tate_polynomial(t) == tate_polynomial(loaded) @test tate_section_a1(t) == tate_section_a1(loaded) @test tate_section_a2(t) == tate_section_a2(loaded) @test tate_section_a3(t) == tate_section_a3(loaded) diff --git a/experimental/QuadFormAndIsom/test/runtests.jl b/experimental/QuadFormAndIsom/test/runtests.jl index 6c9790523d02..bfe04fb2edad 100644 --- a/experimental/QuadFormAndIsom/test/runtests.jl +++ b/experimental/QuadFormAndIsom/test/runtests.jl @@ -77,6 +77,10 @@ end Lf = integer_lattice_with_isometry(L; neg = true) @test order_of_isometry(Lf) == -1 + isdefined(Main, :test_save_load_roundtrip) || include( + joinpath(Oscar.oscardir, "test", "Serialization", "test_save_load_roundtrip.jl") + ) + mktempdir() do path test_save_load_roundtrip(path, Lf) do loaded @test Lf == loaded diff --git a/test/Serialization/runtests.jl b/test/Serialization/runtests.jl index 7a1479b70b15..c3be92b4e358 100644 --- a/test/Serialization/runtests.jl +++ b/test/Serialization/runtests.jl @@ -1,5 +1,8 @@ using Oscar +isdefined(Main, :test_save_load_roundtrip) || + include(joinpath(Oscar.oscardir, "test", "Serialization", "test_save_load_roundtrip.jl")) + include("basic_types.jl") include("PolyhedralGeometry.jl") include("containers.jl") @@ -13,4 +16,3 @@ include("TropicalGeometry.jl") include("QuadForm.jl") include("polymake/runtests.jl") include("upgrades/runtests.jl") - diff --git a/test/Serialization/init_tests.jl b/test/Serialization/test_save_load_roundtrip.jl similarity index 77% rename from test/Serialization/init_tests.jl rename to test/Serialization/test_save_load_roundtrip.jl index 1876387cfea4..f267de31999d 100644 --- a/test/Serialization/init_tests.jl +++ b/test/Serialization/test_save_load_roundtrip.jl @@ -1,8 +1,7 @@ -# This file is dedicated for code that needs to be run on every worker before -# running the tests. This is useful for test-code that is called from multiple files -# that may run on different workers. +# 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 +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) @@ -31,7 +30,7 @@ function test_save_load_roundtrip(func, path, original::T; params=nothing) where io = IOBuffer() save(io, original) seekstart(io) - loaded = load(io, type=T, params=params) + loaded = load(io; type=T, params=params) if T <: Vector @test loaded isa Vector else diff --git a/test/runtests.jl b/test/runtests.jl index ee636d00ac39..f6de72fc7f94 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -104,8 +104,6 @@ end Base.cumulative_compile_timing(true) end -@everywhere include("Serialization/init_tests.jl") - testlist = [ "Aqua.jl",