Skip to content

Commit c25b234

Browse files
Enhance test suite with gravity and particles testing
.gitignore updates
1 parent 39da09c commit c25b234

File tree

2 files changed

+120
-3
lines changed

2 files changed

+120
-3
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ deps/downloads/
1313
deps/usr/
1414
deps/src/
1515
validation_runs/
16+
test_backup_20250808_143045/
17+
src/Mera.jl*
18+
paper/
19+
1620
# Benchmark scripts, only publish zip files
1721
src/benchmarks/RAMSES_reading/downloads/run_test_plots.jl
1822
src/benchmarks/RAMSES_reading/downloads/run_test.jl

test/simulation_data_tests.jl

Lines changed: 116 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,78 @@ function run_simulation_data_tests()
238238
end
239239
end
240240

241+
@testset "Gravity Data Loading" begin
242+
test_data_dir = joinpath(@__DIR__, "test_data")
243+
244+
if !isdir(test_data_dir)
245+
@test_skip "Test data not available"
246+
return
247+
end
248+
249+
simulation_dirs = filter(d -> isdir(joinpath(test_data_dir, d)) &&
250+
startswith(d, "output_"),
251+
readdir(test_data_dir))
252+
253+
if isempty(simulation_dirs)
254+
@test_skip "No simulation output directories found"
255+
return
256+
end
257+
258+
sim_path = joinpath(test_data_dir, simulation_dirs[1])
259+
260+
try
261+
info = getinfo(sim_path)
262+
# Check if gravity data is available in the simulation
263+
if haskey(info.levelmax, "gravity")
264+
gravity = getgravity(info)
265+
@test gravity isa GravityDataType
266+
@test haskey(gravity.data, :level)
267+
println("✓ Successfully loaded gravity data")
268+
else
269+
@test_skip "Gravity data not available in simulation"
270+
println("ℹ️ Gravity data not present in this simulation")
271+
end
272+
catch e
273+
@test_skip "Could not load gravity data: $e"
274+
end
275+
end
276+
277+
@testset "Particles Data Loading" begin
278+
test_data_dir = joinpath(@__DIR__, "test_data")
279+
280+
if !isdir(test_data_dir)
281+
@test_skip "Test data not available"
282+
return
283+
end
284+
285+
simulation_dirs = filter(d -> isdir(joinpath(test_data_dir, d)) &&
286+
startswith(d, "output_"),
287+
readdir(test_data_dir))
288+
289+
if isempty(simulation_dirs)
290+
@test_skip "No simulation output directories found"
291+
return
292+
end
293+
294+
sim_path = joinpath(test_data_dir, simulation_dirs[1])
295+
296+
try
297+
info = getinfo(sim_path)
298+
# Check if particle data is available in the simulation
299+
if haskey(info.levelmax, "particles")
300+
particles = getparticles(info)
301+
@test particles isa PartDataType
302+
@test haskey(particles.data, :level)
303+
println("✓ Successfully loaded particles data")
304+
else
305+
@test_skip "Particles data not available in simulation"
306+
println("ℹ️ Particles data not present in this simulation")
307+
end
308+
catch e
309+
@test_skip "Could not load particles data: $e"
310+
end
311+
end
312+
241313
@testset "Basic getvar Functionality" begin
242314
test_data_dir = joinpath(@__DIR__, "test_data")
243315

@@ -259,9 +331,9 @@ function run_simulation_data_tests()
259331

260332
try
261333
info = getinfo(sim_path)
262-
hydro = gethydro(info)
263334

264-
# Test basic getvar calls
335+
# Test hydro getvar
336+
hydro = gethydro(info)
265337
rho_data = getvar(hydro, :rho)
266338
@test rho_data isa AbstractArray
267339
@test length(rho_data) == length(hydro.data[:rho])
@@ -271,7 +343,48 @@ function run_simulation_data_tests()
271343
@test rho_cgs isa AbstractArray
272344
@test length(rho_cgs) == length(hydro.data[:rho])
273345

274-
println("✓ getvar functionality working")
346+
println("✓ Hydro getvar functionality working")
347+
348+
# Test gravity getvar if available
349+
if haskey(info.levelmax, "gravity")
350+
try
351+
gravity = getgravity(info)
352+
# Test basic gravity variable (typically :epot or :acc)
353+
if haskey(gravity.data, :epot)
354+
epot_data = getvar(gravity, :epot)
355+
@test epot_data isa AbstractArray
356+
@test length(epot_data) == length(gravity.data[:epot])
357+
println("✓ Gravity getvar functionality working")
358+
else
359+
println("ℹ️ Gravity data loaded but no :epot field found")
360+
end
361+
catch e
362+
@test_skip "Could not test gravity getvar: $e"
363+
end
364+
else
365+
println("ℹ️ Gravity getvar test skipped - no gravity data")
366+
end
367+
368+
# Test particles getvar if available
369+
if haskey(info.levelmax, "particles")
370+
try
371+
particles = getparticles(info)
372+
# Test basic particle variables (typically :mass, :x, :y, :z)
373+
if haskey(particles.data, :mass)
374+
mass_data = getvar(particles, :mass)
375+
@test mass_data isa AbstractArray
376+
@test length(mass_data) == length(particles.data[:mass])
377+
println("✓ Particles getvar functionality working")
378+
else
379+
println("ℹ️ Particles data loaded but no :mass field found")
380+
end
381+
catch e
382+
@test_skip "Could not test particles getvar: $e"
383+
end
384+
else
385+
println("ℹ️ Particles getvar test skipped - no particles data")
386+
end
387+
275388
catch e
276389
@test_skip "Could not test getvar: $e"
277390
end

0 commit comments

Comments
 (0)