Skip to content

Commit ebe28e6

Browse files
committed
Add test_menu.jl
1 parent 7cc694d commit ebe28e6

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

test/test_menu.jl

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
using REPL.TerminalMenus
2+
3+
function _test_scripts(test_dir::AbstractString)
4+
scripts = filter(readdir(test_dir; join=false)) do name
5+
startswith(name, "test_") && endswith(name, ".jl") && isfile(joinpath(test_dir, name))
6+
end
7+
# Avoid offering this menu script itself to prevent accidental recursion.
8+
filter!(name -> name != basename(@__FILE__), scripts)
9+
sort!(scripts)
10+
return scripts
11+
end
12+
13+
function test_menu()
14+
test_dir = @__DIR__
15+
16+
active = true
17+
while active
18+
scripts = _test_scripts(test_dir)
19+
if isempty(scripts)
20+
println("No test scripts matching test_*.jl found in $(test_dir).")
21+
break
22+
end
23+
24+
options = vcat(["include(\"$(name)\")" for name in scripts], ["quit"])
25+
menu = RadioMenu(options, pagesize=min(12, length(options)))
26+
choice = request("\nChoose test script to include or `q` to quit: ", menu)
27+
28+
if choice != -1 && choice != length(options)
29+
include(joinpath(test_dir, scripts[choice]))
30+
else
31+
println("Left menu. Press <ctrl><d> to quit Julia!")
32+
active = false
33+
end
34+
end
35+
end
36+
37+
test_menu()

0 commit comments

Comments
 (0)