1+ # ==============================================================================
2+ # CTParser Test Runner
3+ # ==============================================================================
4+
5+ # Test dependencies
16using Test
27using Aqua
38using OrderedCollections: OrderedDict
@@ -59,73 +64,31 @@ include("utils.jl")
5964const VERBOSE = true
6065const SHOWTIMING = true
6166
62- """ Return the default set of tests enabled for CTParser."""
63- function default_tests ()
64- return OrderedDict (
65- :aqua => true ,
66- :exa_linalg => true ,
67- :initial_guess => true ,
68- :utils => true ,
69- :utils_bis => true ,
70- :prefix => true ,
71- :prefix_bis => true ,
72- :onepass_fun => true ,
73- :onepass_fun_bis => true ,
74- :onepass_exa => true ,
75- :onepass_exa_bis => true ,
76- :dynamics_exa => true ,
77- )
78- end
79-
80- const TEST_SELECTIONS = isempty (ARGS ) ? Symbol[] : Symbol .(ARGS )
81-
82- function selected_tests ()
83- tests = default_tests ()
84- sels = TEST_SELECTIONS
85-
86- # No selection: use defaults
87- if isempty (sels)
88- return tests
89- end
67+ # Run tests using the TestRunner extension
68+ CTBase. run_tests (;
69+ args= String .(ARGS ),
70+ testset_name= " CTParser tests" ,
71+ available_tests= (
72+ " suite/test_*" ,
73+ ),
74+ filename_builder= name -> " test_$(name) .jl" ,
75+ funcname_builder= name -> " test_$(name) " ,
76+ verbose= VERBOSE,
77+ showtiming= SHOWTIMING,
78+ test_dir= @__DIR__ ,
79+ )
9080
91- # Single :all selection: enable everything
92- if length (sels) == 1 && sels[ 1 ] == :all
93- for k in keys (tests)
94- tests[k] = true
95- end
96- return tests
97- end
81+ # If running with coverage enabled, remind the user to run the post-processing script
82+ # because .cov files are flushed at process exit and cannot be cleaned up by this script.
83+ if Base . JLOptions () . code_coverage != 0
84+ println (
85+ """
86+ ================================================================================
87+ Coverage files generated. To process them, please run:
9888
99- # Otherwise, start with everything disabled
100- for k in keys (tests)
101- tests[k] = false
102- end
89+ julia --project -e 'using Pkg; Pkg.test("CTParser"; coverage=true); include("test/coverage.jl")'
10390
104- # Enable explicit selections
105- for sel in sels
106- if sel == :all
107- for k in keys (tests)
108- tests[k] = true
109- end
110- break
111- end
112- if haskey (tests, sel)
113- tests[sel] = true
114- end
115- end
116-
117- return tests
118- end
119-
120- const SELECTED_TESTS = selected_tests ()
121-
122- @testset verbose = VERBOSE showtiming = SHOWTIMING " CTParser tests" begin
123- for (name, enabled) in SELECTED_TESTS
124- enabled || continue
125- @testset " $(name) " begin
126- test_name = Symbol (:test_ , name)
127- include (" $(test_name) .jl" )
128- @eval $ test_name ()
129- end
130- end
131- end
91+ ================================================================================
92+ """
93+ )
94+ end
0 commit comments