Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions ext/TestRunner/test_selection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,11 @@ function _test_spec_matches(
candidate_filename_no_ext = replace(candidate_filename, ".jl" => "")
candidate_basename = basename(candidate_filename)
candidate_basename_no_ext = replace(candidate_basename, ".jl" => "")
candidate_basename_no_test_prefix =
if startswith(candidate_basename_no_ext, "test_")
candidate_basename_no_ext[6:end]
else
candidate_basename_no_ext
end
candidate_basename_no_test_prefix = if startswith(candidate_basename_no_ext, "test_")
candidate_basename_no_ext[6:end]
else
candidate_basename_no_ext
end

regex = _glob_to_regex(String(pattern))
return !isnothing(match(regex, candidate_str)) ||
Expand Down Expand Up @@ -192,7 +191,7 @@ function _select_tests(

if !isempty(excluded_tests)
filter!(candidates) do candidate
!any(
return !any(
pattern -> _test_spec_matches(
candidate, pattern, available_tests, filename_builder
),
Expand Down
2 changes: 1 addition & 1 deletion src/Data/control_law.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ See also: [`CTBase.Data.ControlLaw`](@ref), [`CTBase.Data.OpenLoop`](@ref).
function ControlLaw(
_f, ::Type{Traits.OpenLoopFeedback}, ::Type{Traits.Autonomous}, ::Type{VD}
) where {VD<:Traits.VariableDependence}
throw(
return throw(
Exceptions.IncorrectArgument(
"OpenLoop control laws cannot be Autonomous: an open-loop control always depends on time, u(t) (or u(t, v))";
suggestion="Use OpenLoop(f; is_variable).",
Expand Down
4 changes: 3 additions & 1 deletion test/suite/data/test_control_law.jl
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,9 @@ function test_control_law()
Test.@test Traits.variable_dependence(cl7) == Traits.NonFixed

# ClosedLoop, NonAutonomous, NonFixed
cl8 = Data.ClosedLoop((t, x, v) -> t + x + v; is_autonomous=false, is_variable=true)
cl8 = Data.ClosedLoop(
(t, x, v) -> t + x + v; is_autonomous=false, is_variable=true
)
Test.@test cl8 isa Data.ControlLaw
Test.@test Traits.feedback(cl8) == Traits.ClosedLoopFeedback
Test.@test Traits.time_dependence(cl8) == Traits.NonAutonomous
Expand Down
16 changes: 12 additions & 4 deletions test/suite/data/test_path_constraint.jl
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ function test_path_constraint()

Test.@testset "Natural calls - MixedConstraint" begin
Test.@test Data.MixedConstraint((x, u) -> x[1] + u[1])([2.0], [3.0]) == 5.0
Test.@test Data.MixedConstraint((t, x, u) -> t + x[1] + u[1]; is_autonomous=false)(
Test.@test Data.MixedConstraint(
(t, x, u) -> t + x[1] + u[1]; is_autonomous=false
)(
1.0, [2.0], [3.0]
) == 6.0
Test.@test Data.MixedConstraint(
Expand Down Expand Up @@ -115,10 +117,14 @@ function test_path_constraint()

# Mixed
Test.@test Data.MixedConstraint((x, u) -> x[1] + u[1])(t, x, u, v) == 5.0
Test.@test Data.MixedConstraint((t, x, u) -> t + x[1] + u[1]; is_autonomous=false)(
Test.@test Data.MixedConstraint(
(t, x, u) -> t + x[1] + u[1]; is_autonomous=false
)(
t, x, u, v
) == 6.0
Test.@test Data.MixedConstraint((x, u, v) -> x[1] + u[1] + v[1]; is_variable=true)(
Test.@test Data.MixedConstraint(
(x, u, v) -> x[1] + u[1] + v[1]; is_variable=true
)(
t, x, u, v
) == 9.0
# Mixed NonAut NonFixed: natural == uniform
Expand Down Expand Up @@ -167,7 +173,9 @@ function test_path_constraint()
Test.@test occursin("natural call: g(x, u)", str)
Test.@test occursin("uniform call: g(t, x, u, v)", str)

gs = Data.StateConstraint((t, x, v) -> x[1]; is_autonomous=false, is_variable=true)
gs = Data.StateConstraint(
(t, x, v) -> x[1]; is_autonomous=false, is_variable=true
)
strs = repr(MIME("text/plain"), gs)
Test.@test occursin("PathConstraint: state, non-autonomous, variable", strs)
Test.@test occursin("natural call: g(t, x, v)", strs)
Expand Down
12 changes: 9 additions & 3 deletions test/suite/data/test_pseudo_hamiltonian.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ function test_pseudo_hamiltonian()
Test.@test Traits.variable_dependence(ph2) == Traits.Fixed

# Autonomous, NonFixed
ph3 = Data.PseudoHamiltonian((x, p, u, v) -> sum(x .* p) + u^2 + v; is_variable=true)
ph3 = Data.PseudoHamiltonian(
(x, p, u, v) -> sum(x .* p) + u^2 + v; is_variable=true
)
Test.@test ph3 isa Data.PseudoHamiltonian
Test.@test Traits.time_dependence(ph3) == Traits.Autonomous
Test.@test Traits.variable_dependence(ph3) == Traits.NonFixed
Expand Down Expand Up @@ -62,7 +64,9 @@ function test_pseudo_hamiltonian()
Test.@test ph2(1.0, [2.0, 3.0], [4.0, 5.0], 6.0) == 1.0 + 8.0 + 15.0 + 36.0

# Autonomous, NonFixed: h̃(x, p, u, v)
ph3 = Data.PseudoHamiltonian((x, p, u, v) -> sum(x .* p) + u^2 + v; is_variable=true)
ph3 = Data.PseudoHamiltonian(
(x, p, u, v) -> sum(x .* p) + u^2 + v; is_variable=true
)
Test.@test ph3([1.0, 2.0], [3.0, 4.0], 5.0, 6.0) == 3.0 + 8.0 + 25.0 + 6.0

# NonAutonomous, NonFixed: h̃(t, x, p, u, v)
Expand Down Expand Up @@ -91,7 +95,9 @@ function test_pseudo_hamiltonian()
Test.@test ph2(1.0, [2.0, 3.0], [4.0, 5.0], 6.0, 7.0) == 1.0 + 8.0 + 15.0 + 36.0

# Autonomous, NonFixed — ignores t
ph3 = Data.PseudoHamiltonian((x, p, u, v) -> sum(x .* p) + u^2 + v; is_variable=true)
ph3 = Data.PseudoHamiltonian(
(x, p, u, v) -> sum(x .* p) + u^2 + v; is_variable=true
)
Test.@test ph3(0.0, [1.0, 2.0], [3.0, 4.0], 5.0, 6.0) == 3.0 + 8.0 + 25.0 + 6.0

# NonAutonomous, NonFixed — uses all
Expand Down
24 changes: 20 additions & 4 deletions test/suite/extensions/test_testrunner_selection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -187,26 +187,42 @@ function test_testrunner_selection()
Test.@testset verbose = VERBOSE showtiming = SHOWTIMING "test exclusions" begin
available = TestRunner.TestSpec[:utils, :core]
sel = select_tests(
String[], available, TestRunner.TestSpec[:core], false, test_builder_sym;
String[],
available,
TestRunner.TestSpec[:core],
false,
test_builder_sym;
test_dir=temp_dir,
)
Test.@test sel == [:utils]

available = TestRunner.TestSpec["suite_norm/*"]
sel = select_tests(
String[], available, TestRunner.TestSpec["suite_norm/test_y"], false, identity;
String[],
available,
TestRunner.TestSpec["suite_norm/test_y"],
false,
identity;
test_dir=temp_dir,
)
Test.@test sel == ["suite_norm/test_x.jl"]

sel = select_tests(
String[], available, TestRunner.TestSpec["suite_norm/test_*"], false, identity;
String[],
available,
TestRunner.TestSpec["suite_norm/test_*"],
false,
identity;
test_dir=temp_dir,
)
Test.@test isempty(sel)

sel = select_tests(
String[], Symbol[], TestRunner.TestSpec[:utils], false, identity;
String[],
Symbol[],
TestRunner.TestSpec[:utils],
false,
identity;
test_dir=temp_dir,
)
Test.@test "test_core.jl" in sel
Expand Down
4 changes: 2 additions & 2 deletions test/suite/meta/test_no_import.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ const DOTTED_USING_RE = r"^\s*using\s+[A-Za-z_]\w*\.[A-Za-z_]"
const DOTTED_USING_EXEMPT = ("BREAKING.md",)

function test_no_import()
Test.@testset "No `import` / no dotted `using Pkg.Sub` (Handbook tenet 2)" verbose = VERBOSE showtiming =
SHOWTIMING begin
Test.@testset "No `import` / no dotted `using Pkg.Sub` (Handbook tenet 2)" verbose =
VERBOSE showtiming = SHOWTIMING begin
repo_root = joinpath(@__DIR__, "..", "..", "..")
tracked = filter(
f -> endswith(f, ".jl") || endswith(f, ".md"),
Expand Down