Skip to content

Feature/sort modules by dependencies#166

Merged
polsala merged 3 commits intomasterfrom
feature/sort-modules-by-dependencies
Nov 12, 2025
Merged

Feature/sort modules by dependencies#166
polsala merged 3 commits intomasterfrom
feature/sort-modules-by-dependencies

Conversation

@ecarreras
Copy link
Copy Markdown
Member

This pull request introduces dependency-aware sorting for modules in the destral CLI and utilities, ensuring that modules are processed in the correct order based on their dependencies. The main change is the addition of a topological sort function, which is now used before running tests, and is thoroughly tested with new unit tests.

Dependency-aware module sorting

  • Added sort_modules_by_dependencies function to destral/utils.py, which sorts a list of modules so that dependencies are processed before dependent modules using a topological sort. This prevents issues where a module is tested before its dependencies.
  • Updated the destral/cli.py test runner to use the new sorting function, ensuring modules are tested in dependency order.
  • Exported sort_modules_by_dependencies in destral/utils.py so it can be used elsewhere in the codebase.

Testing improvements

  • Added a comprehensive test suite for sort_modules_by_dependencies in tests/test_utils.py, covering various scenarios including linear dependencies, random input order, empty lists, and modules without shared dependencies.

This function sorts a list of modules by their dependencies using
topological sort, ensuring that dependencies are processed before
the modules that depend on them.

For example, if module_a depends on module_b, the result will be
[module_b, module_a].
Apply automatic sorting of modules by dependencies in the CLI
when multiple -m options are provided. This ensures that if
module1 depends on module2, they are executed in the correct
order [module2, module1].
Add comprehensive test suite to validate module sorting by dependencies:
- Test single module
- Test two modules with dependency
- Test multiple modules with linear dependencies
- Test all modules in dependency chain
- Test modules out of order
- Test empty list
- Test modules without shared dependencies
@polsala polsala added the minor Minor auto version V_.X._ label Nov 12, 2025
@polsala polsala merged commit fda2939 into master Nov 12, 2025
2 checks passed
@polsala polsala deleted the feature/sort-modules-by-dependencies branch November 12, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement minor Minor auto version V_.X._

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants