Skip to content

Commit

Permalink
Add basic mac support to netcdf test
Browse files Browse the repository at this point in the history
  • Loading branch information
jakelangham committed Dec 5, 2023
1 parent 022fe65 commit 4a3799b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
5 changes: 2 additions & 3 deletions tests/runall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,9 @@ tests_identical = [
]

# Check if NetCDF support enabled and define extra test if so.
with_netcdf = false
tests_netcdf = []
if !isempty(read(pipeline(`ldd $prog`, `grep netcdf`)))
with_netcdf = true
with_netcdf = links_to_netcdf(prog)
if with_netcdf
tests_netcdf = [
("netcdf_restart", 2)
]
Expand Down
19 changes: 19 additions & 0 deletions tests/testlib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,25 @@ function strip_comments(strings)
return stripped
end

# Verify if the executable prog links to the NetCDF libraries.
function links_to_netcdf(prog)
lib_printer_exec = "ldd" # default library checker
if Sys.isapple()
lib_printer_exec = "otool -L"
end

cmd = `$lib_printer_exec $prog`
cmd_output = try
read(cmd, String)
catch
println("Warning: unable to look for netcdf support with command: $cmd")
println("Continuing without testing netcdf features.")
return false
end

return match(r"netcdf", cmd_output) !== nothing
end

# Print a pending animation while waiting for task t to complete.
function wait_for_task(t)
while !istaskdone(t)
Expand Down

0 comments on commit 4a3799b

Please sign in to comment.