Skip to content

Commit

Permalink
Merge pull request #189 from cmhamel/feature/exodiff-cli-args
Browse files Browse the repository at this point in the history
Adding a feature to pass in command line arguments to exodiff()
  • Loading branch information
cmhamel authored Sep 10, 2024
2 parents 6163dd6 + 5ee4a9f commit 8a6715e
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 15 deletions.
1 change: 1 addition & 0 deletions .github/workflows/Documentation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
contents: write
runs-on: ubuntu-latest
steps:
- uses: julia-actions/cache@v2
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
Expand Down
6 changes: 2 additions & 4 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
name = "Exodus"
uuid = "f57ae99e-f805-4780-bdca-96e224be1e5a"
authors = ["cmhamel <[email protected]>"]
version = "0.13.2"
version = "0.13.3"

[deps]
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
Exodus_jll = "fc7263ad-bce8-5229-97b1-c6ddabda41b1"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"

[weakdeps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand All @@ -25,8 +24,7 @@ DocStringExtensions = "0.9"
Exodus_jll = "8.19"
JET = "0.8"
MPI = "0.20"
PartitionedArrays = "0.4, 0.5"
Pkg = "1"
PartitionedArrays = "0.4"
Test = "1"
TestSetExtensions = "2"
Unitful = "1"
Expand Down
7 changes: 4 additions & 3 deletions docs/src/opening_files.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ Initialization:
Number of side sets = 4
Block:
unnamed_block_1
NodeSet:
unnamed_nset_1 unnamed_nset_2 unnamed_nset_3 unnamed_nset_4
SideSet:
unnamed_sset_1 unnamed_sset_2 unnamed_sset_3 unnamed_sset_4
NodalVariable:
u
```
62 changes: 57 additions & 5 deletions src/ExoDiff.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,8 @@ function exodiff(
ex_2::String;
command_file = nothing
)
# if Sys.iswindows()
# exodus_windows_error()
# end

@assert !Sys.iswindows()
# @assert is

exo_cmd = String[]

Expand Down Expand Up @@ -82,4 +79,59 @@ function exodiff(

rm("exodiff_stderr.log", force=true)
return return_bool
end
end

function exodiff(
ex_1::String,
ex_2::String,
cli_args::Vector{String}
)

@assert !Sys.iswindows()

exo_cmd = String[]

for arg in cli_args
push!(exo_cmd, arg)
end

# push files to compare to command list
push!(exo_cmd, abspath(ex_1))
push!(exo_cmd, abspath(ex_2))

# finally run the command
errors_found = false
exodiff_exe() do exe
pushfirst!(exo_cmd, "$exe")
cmd = Cmd(exo_cmd)

redirect_stdio(stdout="exodiff.log", stderr="exodiff_stderr.log") do
try
run(cmd, wait=true)
catch
errors_found = true
end
end
end

# now handle errors
return_bool = false
if errors_found
open("exodiff_stderr.log") do f
words = read(f, String) |> lowercase

# look for no such file error
if contains(words, "no such file")
println("\n\nFile not found error in exodiff\n\n")
exodiff_error(Cmd(exo_cmd))
end
end

return_bool = false
else
return_bool = true
end

rm("exodiff_stderr.log", force=true)
return return_bool
end
8 changes: 5 additions & 3 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ if Sys.iswindows()
else
@exodus_unit_test_set "exodiff help" begin
exodiff()
exodiff("./example_output/output.gold", "./example_output/output.gold", ["-Help"]) == true
end

@exodus_unit_test_set "exodiff" begin
Expand Down Expand Up @@ -364,6 +365,7 @@ end

# JET testing
# report_package("Exodus")
@testset ExtendedTestSet "JET.jl" begin
test_package("Exodus"; target_defined_modules=true)
end
# @testset ExtendedTestSet "JET.jl" begin
# # test_package("Exodus"; target_defined_modules=true)
# JET.test_all("Exodus")
# end

0 comments on commit 8a6715e

Please sign in to comment.