Reorganize test suite by functionality (orthogonal to source structure)#326
Merged
Conversation
- Reorganized test/suite/ from source-aligned to functionality-aligned structure - New directories: components/, models/, building/, solutions/, init/, serialization/, display/, extensions/, meta/, integration/ - Removed empty shells: suite/ocp/, suite/exceptions/, suite/initial_guess/ - Renamed 40 test files to match new directory structure - Updated module names and entry functions in 4 files (test_components.jl, test_model_types.jl, test_solution_types.jl, test_building_exceptions.jl) - Updated test/README.md with new directory structure and examples - All 3521 tests pass - Tests now organized by functionality rather than source file structure, improving maintainability and discoverability
- Replace `using CTModels: CTModels` + `CTModels.foo` with direct submodule imports (`import CTModels.Components: Components`, `import CTModels.Building: Building`, etc.) across all 44 test files - Remove empty placeholder testsets "Abstract Types" (36 occurrences) - Add `import Test: Test` (qualified import) uniformly - Fix test_plot.jl: keep `import CTModels: CTModels` for `Base.get_extension(CTModels, ...)` - Update Project.toml / docs/Project.toml: widen CTBase compat to "0.18, 0.19" - All 3530 tests pass (3399 core + 131 plot), zero regressions
- test_dedup.jl (new): 6 direct testsets on Building._dedup_box_constraints! and build(ConstraintsDictType) unknown-type error path - test_components.jl: empty sentinels (EmptyControlModel, EmptyVariableModel, EmptyDefinition), StateModelSolution/ControlModelSolution accessors, time accessors (Base.time, Components.name, has_* predicates), has_mayer_cost / has_lagrange_cost - test_model.jl: is_autonomous/has_variable traits, free-time branches (scalar and vector), mayer/lagrange error stubs, get_build_examodel, missing label, @inferred and @allocated quality assertions - test_dual_model.jl: label :nonexistent -> IncorrectArgument error path - test_initial_guess_validation.jl: scalar variable on vdim=0, :variable block on problem without variable 3614/3614 tests pass, zero regressions
… tests - test_contracts.jl (new): top-level fakes for AbstractStateModel, AbstractControlModel, AbstractVariableModel, AbstractModel; generic LSP contract checkers; mayer/lagrange/initial_time/final_time stubs on AbstractModel -> PreconditionError - test_CTModels.jl: verify CTModels top-level exports only :CTModels (tenet #1); full list of symbols announced by Components - test_multi_grids.jl: retro-compat — JSON with legacy key time_grid_dual imported correctly as time_grid_path - test_print.jl: smoke tests show(Model) autonomous and with optimisation variable 237/237 tests pass. Plan elegant-milner Phases 1+2+3 complete.
- Add # Returns and # Arguments sections to all accessors in build_solution.jl (20 functions) - Add # Returns and See also: to dual accessors in dual_model.jl (8 functions) - Add See also: to interpolation helpers in interpolation_helpers.jl (3 functions) - Enrich Solutions.jl module docstring with # Public API, # Dependencies, # See also sections - Ensure all cross-references use full paths (CTModels.Solutions.*, CTModels.Models.*) - All docstrings now conform to project standards with active descriptions and complete sections
Member
Author
|
Refactor docstrings for Solutions module This commit completes the docstring refactoring for the Solutions module, following the same standards applied to Models and Serialization modules. Changes:
Conformity:
|
- Fixed CTModels.Components.Base.time invalid refs in accessors.jl and times_accessors.jl
- Fixed CTModels.Models.xxx → CTModels.Components.xxx refs in model.jl (23 patterns)
- Fixed CTModels.Models.xxx → CTModels.Components.xxx refs in build_solution.jl (11 patterns)
- Fixed CTModels.Components.{state,control,variable}_dimension → CTModels.Models.xxx in Building files
- Removed unresolvable module @refs in Display.jl and Init.jl
- All Cannot resolve @ref warnings now resolved
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR completes the full three-phase test suite overhaul for CTModels.jl, bringing all files into conformance with the testing standards, filling targeted coverage gaps, and adding contract/LSP tests.
Phase 1 — Uniform cleanup (all files, low risk) ✅
1a — Structural reorganization
Reorganizes
test/suite/from a source-aligned structure to a functionality-aligned one.suite/components/suite/models/Modeltype, readers, user-facing predicatessuite/building/PreModel, mutators, validation, defaults,buildsuite/solutions/Solution, time grids, dual model, interpolationsuite/init/suite/serialization/suite/display/suite/extensions/suite/integration/suite/meta/suite/ocp/,suite/exceptions/,suite/initial_guess/test_components.jl,test_model_types.jl,test_solution_types.jl,test_building_exceptions.jltest/README.mdwith new directory structure and examples1b — Submodule-qualified imports and calls
import CTModels.Building: Building, etc.) across all 44 filesCTModels.footoSubmodule.foofollowing the canonical symbol-to-submodule map"Abstract Types"(noise)test_plot.jl: keptimport CTModels: CTModels(needed forBase.get_extension)Project.toml/docs/Project.toml: widened CTBase compat to"0.18, 0.19"Phase 2 — Coverage gaps + quality tests ✅
building/test_dedup.jl(new)Building._dedup_box_constraints!+build(ConstraintsDictType)unknown-type error pathcomponents/test_components.jlEmptyControlModel,EmptyVariableModel,EmptyDefinition),StateModelSolution/ControlModelSolutionaccessors, time accessors,has_mayer_cost/has_lagrange_costmodels/test_model.jlis_autonomous/has_variabletraits, free-time branches (scalar and vector),mayer/lagrangeerror stubs,get_build_examodel, missing label,@inferredand@allocatedquality assertionssolutions/test_dual_model.jl:nonexistent→IncorrectArgumenterror pathinit/test_initial_guess_validation.jlvdim=0,:variableblock on problem without variablePhase 3 — Contract/LSP tests, export verification, retro-compat ✅
components/test_contracts.jl(new)AbstractStateModel,AbstractControlModel,AbstractVariableModel,AbstractModel; generic LSP contract checkers;mayer/lagrange/initial_time/final_timestubs onAbstractModel→PreconditionErrormeta/test_CTModels.jl:CTModels(tenet #1); full list of symbols announced byComponentsserialization/test_multi_grids.jltime_grid_dualimported correctly astime_grid_pathdisplay/test_print.jlshow(Model)autonomous and with optimisation variableTest results
Building,Solutions,Models,Initaddressed@inferred,@allocated) addedRationale
The previous structure mirrored the source layout (
suite/ocp/forsrc/OCP/) and used bareCTModels.foocalls, both in violation of the testing standards. This PR brings the full test suite into conformance:Submodule.symbol, making intent explicit and namespace ownership clear