Skip to content

Commit 4414fda

Browse files
committed
Add option to run all
1 parent b496944 commit 4414fda

4 files changed

Lines changed: 110 additions & 52 deletions

File tree

examples/menu.jl

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,44 @@ using REPL.TerminalMenus
77

88
url = "https://opensourceawe.github.io/VortexStepMethod.jl/dev"
99

10-
options = [
11-
"V3_kite = include(\"V3_kite.jl\")",
12-
"billowing = include(\"billowing.jl\")",
13-
"pyramid_model = include(\"pyramid_model.jl\")",
14-
"rectangular_wing = include(\"rectangular_wing.jl\")",
15-
"ram_air_kite = include(\"ram_air_kite.jl\")",
16-
"stall_model = include(\"stall_model.jl\")",
17-
"bench = include(\"bench.jl\")",
18-
"cleanup = include(\"cleanup.jl\")",
19-
"help_me = VortexStepMethod.help(url)",
20-
"quit"]
10+
example_files = [
11+
"V3_kite.jl",
12+
"billowing.jl",
13+
"pyramid_model.jl",
14+
"rectangular_wing.jl",
15+
"ram_air_kite.jl",
16+
"stall_model.jl",
17+
"bench.jl",
18+
"cleanup.jl",
19+
]
20+
21+
function run_all()
22+
for f in example_files
23+
f == "cleanup.jl" && continue
24+
println("\n" * "="^60)
25+
println("Running: $f")
26+
println("="^60)
27+
try
28+
include(joinpath(@__DIR__, f))
29+
catch e
30+
@error "Failed: $f" exception=(e, catch_backtrace())
31+
end
32+
end
33+
println("\nAll examples completed.")
34+
end
2135

2236
function example_menu()
37+
options = [
38+
[("$( splitext(f)[1]) = include(\"$f\")") for f in example_files];
39+
"help_me = VortexStepMethod.help(\"$url\")";
40+
"quit"
41+
]
2342
active = true
2443
while active
2544
menu = RadioMenu(options, pagesize=8)
26-
choice = request("\nChoose function to execute or `q` to quit: ", menu)
27-
45+
choice = request(
46+
"\nChoose function to execute or `q` to quit: ",
47+
menu)
2848
if choice != -1 && choice != length(options)
2949
eval(Meta.parse(options[choice]))
3050
else
@@ -34,4 +54,8 @@ function example_menu()
3454
end
3555
end
3656

37-
example_menu()
57+
if "--run-all" in ARGS
58+
run_all()
59+
else
60+
example_menu()
61+
end

examples_cp/menu_cp.jl

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,24 +9,47 @@ using REPL.TerminalMenus
99

1010
url = "https://opensourceawe.github.io/VortexStepMethod.jl/dev"
1111

12-
options = [
13-
"V3_kite = include(\"../examples/V3_kite.jl\")",
14-
"billowing = include(\"../examples/billowing.jl\")",
15-
"pyramid_model = include(\"../examples/pyramid_model.jl\")",
16-
"rectangular_wing = include(\"../examples/rectangular_wing.jl\")",
17-
"ram_air_kite = include(\"../examples/ram_air_kite.jl\")",
18-
"stall_model = include(\"../examples/stall_model.jl\")",
19-
"bench = include(\"../examples/bench.jl\")",
20-
"cleanup = include(\"../examples/cleanup.jl\")",
21-
"help_me = VortexStepMethod.help(url)",
22-
"quit"]
12+
examples_dir = joinpath(@__DIR__, "..", "examples")
13+
14+
example_files = [
15+
"V3_kite.jl",
16+
"billowing.jl",
17+
"pyramid_model.jl",
18+
"rectangular_wing.jl",
19+
"ram_air_kite.jl",
20+
"stall_model.jl",
21+
"bench.jl",
22+
"cleanup.jl",
23+
]
24+
25+
function run_all()
26+
for f in example_files
27+
f == "cleanup.jl" && continue
28+
println("\n" * "="^60)
29+
println("Running: $f")
30+
println("="^60)
31+
try
32+
include(joinpath(examples_dir, f))
33+
catch e
34+
@error "Failed: $f" exception=(e, catch_backtrace())
35+
end
36+
end
37+
println("\nAll examples completed.")
38+
end
2339

2440
function example_menu()
41+
options = [
42+
[("$(splitext(f)[1]) = include(\"../examples/$f\")")
43+
for f in example_files];
44+
"help_me = VortexStepMethod.help(\"$url\")";
45+
"quit"
46+
]
2547
active = true
2648
while active
2749
menu = RadioMenu(options, pagesize=8)
28-
choice = request("\nChoose function to execute or `q` to quit: ", menu)
29-
50+
choice = request(
51+
"\nChoose function to execute or `q` to quit: ",
52+
menu)
3053
if choice != -1 && choice != length(options)
3154
eval(Meta.parse(options[choice]))
3255
else
@@ -36,4 +59,8 @@ function example_menu()
3659
end
3760
end
3861

39-
example_menu()
62+
if "--run-all" in ARGS
63+
run_all()
64+
else
65+
example_menu()
66+
end

test/plotting/test_plotting.jl

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -290,30 +290,36 @@ end
290290
# Unit-test tuple parsing branch (e.g. readdlm(...; header=true) shape).
291291
tuple_table = [0.0 0.10 0.010; 5.0 0.20 0.020]
292292
tuple_header = [" AoA " "CL" "CD"]
293-
tuple_pd = ext._extract_literature_polar_data((tuple_table, tuple_header), "tuple.csv")
294-
@test tuple_pd[1] == tuple_table[:, 1]
295-
@test tuple_pd[2] == tuple_table[:, 2]
296-
@test tuple_pd[3] == tuple_table[:, 3]
297-
@test tuple_pd[4] == zeros(size(tuple_table, 1))
293+
tuple_result = ext._extract_literature_polar_data(
294+
(tuple_table, tuple_header), "tuple.csv")
295+
@test tuple_result.polar_data[1] == tuple_table[:, 1]
296+
@test tuple_result.polar_data[2] == tuple_table[:, 2]
297+
@test tuple_result.polar_data[3] == tuple_table[:, 3]
298+
@test tuple_result.polar_data[4] == zeros(size(tuple_table, 1))
299+
@test all(isnan, tuple_result.cmx)
300+
@test all(isnan, tuple_result.cmy)
301+
@test all(isnan, tuple_result.cmz)
298302

299303
# Unit-test matrix parsing branch (header in first row + explicit CS column).
300304
matrix_data = Any[
301305
"alpha" "cl" "cd" "cs";
302306
0.0 0.11 0.011 0.001;
303307
4.0 0.21 0.021 0.002
304308
]
305-
matrix_pd = ext._extract_literature_polar_data(matrix_data, "matrix.csv")
306-
@test Float64.(matrix_pd[1]) == [0.0, 4.0]
307-
@test Float64.(matrix_pd[2]) == [0.11, 0.21]
308-
@test Float64.(matrix_pd[3]) == [0.011, 0.021]
309-
@test Float64.(matrix_pd[4]) == [0.001, 0.002]
309+
matrix_result = ext._extract_literature_polar_data(
310+
matrix_data, "matrix.csv")
311+
@test Float64.(matrix_result.polar_data[1]) == [0.0, 4.0]
312+
@test Float64.(matrix_result.polar_data[2]) == [0.11, 0.21]
313+
@test Float64.(matrix_result.polar_data[3]) == [0.011, 0.021]
314+
@test Float64.(matrix_result.polar_data[4]) == [0.001, 0.002]
310315

311316
# Missing required columns should throw a clear ArgumentError.
312317
bad_data = Any[
313318
"aoa" "cl" "cs";
314319
0.0 0.1 0.0
315320
]
316-
@test_throws ArgumentError ext._extract_literature_polar_data(bad_data, "bad.csv")
321+
@test_throws ArgumentError ext._extract_literature_polar_data(
322+
bad_data, "bad.csv")
317323

318324
# Integration: literature CSV with AoA alias and no CS should still plot.
319325
lit_no_cs_path = tempname() * "_lit_no_cs.csv"

test/test_setup.sh

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,19 @@ for d in data/ram_air_kite data/TUDELFT_V3_KITE \
4949
[[ -d "$d" ]] && pass "copied $d/" || fail "copied $d/"
5050
done
5151

52-
# Verify all examples use GLMakie, not ControlPlots
53-
for f in menu.jl bench.jl rectangular_wing.jl V3_kite.jl \
52+
# Verify menu.jl loads GLMakie and examples are backend-agnostic
53+
if grep -q "using GLMakie" "examples/menu.jl"; then
54+
pass "menu.jl uses GLMakie"
55+
else
56+
fail "menu.jl uses GLMakie"
57+
fi
58+
for f in bench.jl rectangular_wing.jl V3_kite.jl \
5459
pyramid_model.jl ram_air_kite.jl stall_model.jl; do
55-
if grep -q "using GLMakie" "examples/$f" && \
60+
if ! grep -q "using GLMakie" "examples/$f" && \
5661
! grep -q "using ControlPlots" "examples/$f"; then
57-
pass "$f uses GLMakie"
62+
pass "$f is backend-agnostic"
5863
else
59-
fail "$f uses GLMakie"
64+
fail "$f is backend-agnostic"
6065
fi
6166
done
6267

@@ -78,14 +83,10 @@ $JULIA --project=. -e '
7883
@assert !("ControlPlots" ∈ deps) "ControlPlots should not be installed"
7984
' 2>&1 && pass "correct packages installed" || fail "correct packages installed"
8085

81-
# Run all examples
82-
for f in rectangular_wing.jl pyramid_model.jl V3_kite.jl \
83-
stall_model.jl ram_air_kite.jl bench.jl; do
84-
echo " Running $f..."
85-
$JULIA --project=examples -e '
86-
include("examples/'"$f"'")
87-
' 2>&1 && pass "run $f" || fail "run $f"
88-
done
86+
# Run all examples via menu.jl --run-all (single Julia process)
87+
echo " Running all examples..."
88+
$JULIA --project=examples examples/menu.jl -- --run-all \
89+
2>&1 && pass "run all examples" || fail "run all examples"
8990

9091
echo ""
9192
echo "=== Results: $PASS passed, $FAIL failed ==="

0 commit comments

Comments
 (0)