-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #21 from DJ4Earth/rewrite_compare_archive_tests
change the structure of the tests
- Loading branch information
Showing
9 changed files
with
63 additions
and
51 deletions.
There are no files selected for viewing
Binary file not shown.
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
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,37 @@ | ||
using DJUICE | ||
using Test | ||
|
||
function searchdir(path,key) | ||
filter(x->occursin(key,x), readdir(path)) | ||
end | ||
|
||
function compareArchive(tf::String, field_names::Vector{String}, field_tolerances::Vector{Float64}, field_values::Vector{Vector{Float64}}, procedure::Symbol) | ||
# make the test | ||
id = match(r"test(\d+).jl", tf).captures[1] | ||
archive_name = "Archive"*string(id) | ||
archive_path = issmdir()*"/test/Archives/"*archive_name*".arch" | ||
if procedure===:update | ||
# TODO: update Archive | ||
else | ||
# check Archive | ||
if isfile(archive_path) | ||
@time @testset " Compare with $archive_name" begin | ||
for k=1:length(field_names) | ||
# Compare to archive | ||
if !isnan(field_tolerances[k]) | ||
@time @testset " $(field_names[k]): " begin | ||
# Our output is in the correct order (n,1) or (1,1), so we do not need to transpose again | ||
archive = archread(archive_path, archive_name*"_field"*string(k)) | ||
error_diff = (maximum(abs.(archive-field_values[k]))/(maximum(abs.(archive))+eps(Float64))) | ||
|
||
@test isnan(error_diff) == false | ||
@test error_diff < field_tolerances[k] skip = isnan(field_tolerances[k]) | ||
end | ||
end | ||
end | ||
end | ||
else | ||
@warn "$archive_name does not exist! Skip the comparison of the results" | ||
end | ||
end | ||
end |