Skip to content

Comments

Feature/cli refactor tests#143

Merged
dschwartznyc merged 61 commits intomainfrom
feature/cli-refactor-tests
Feb 20, 2026
Merged

Feature/cli refactor tests#143
dschwartznyc merged 61 commits intomainfrom
feature/cli-refactor-tests

Conversation

@dschwartznyc
Copy link
Contributor

@dschwartznyc dschwartznyc commented Feb 8, 2026

CLI Refactoring and Test Suite Reorganization

Summary

This release introduces a significant refactoring of the PythonCodeGeneratorCLI and a major reorganization of the Python unit test suite. The primary goals are to improve the robustness of the command-line interface, enhance validation feedback, and restructure the testing framework to be more maintainable and aligned with the current capabilities of the generator.

Key Changes

1. CLI Refactoring and Enhancement (PythonCodeGeneratorCLI.java)

The CLI has been updated to "v2" with several improvements:

  • Robust Validation: Integrated IResourceValidator to perform full model validation before code generation. The tool now identifies and logs specific validation errors (including line numbers and element context) and skips invalid models.
  • Target Directory Management: Added logic to safely clean and recreate the target directory before generation, preventing "stale" code from persisting.
  • Improved Logging: Migrated to SLF4J for consistent logging and provided clearer console output for progress and errors.
  • see issue #142

2. Test Suite Reorganization (test/python_unit_tests/)

The Python test suite has been restructured from a flat or ad-hoc layout into a categorized hierarchy:

  • Feature-Based Categorization: Tests are now organized into logical folders:
    • features/model_structure/: Tests for inheritance, entity reuse, metadata, etc.
    • features/operators/: Tests for arithmetic, comparison, and boolean logic.
    • features/robustness/: Tests for null handling and edge cases.
  • Integrated Rosetta Sources: Rosetta files used for tests are now co-located with their corresponding Python tests within the features/ directory tree, making it easier to understand the relationship between the DSL source and the test assertions.

3. "No-Function" Test Alignment

In alignment with the current generator status (where full function generation is still in progress), many tests were refactored to verify logic using Type Conditions rather than standalone Functions.

  • Rationale: This allows for comprehensive testing of expression semantics (arithmetic, logic, etc.) using the fully supported Pydantic-based model validation, without being blocked by the pending function generator implementation.

4. New Java Unit Tests

Several new JUnit tests were added to the Java codebase to verify specific generation logic:

  • RosettaSwitchExpressionTest.java
  • PythonFunctionBasicTest.java (and other targeted function tests)
  • PythonBasicTypeGeneratorTest.java

Impact

  • Developers: The CLI is now much more helpful for debugging Rosetta models, as it provides specific error locations during the build process.
  • CI/CD: The restructured test suite is more modular and provides better granularity for identifying regressions.
  • Maintainability: Moving away from complex functional tests toward type-condition-based tests ensures the test suite remains green while core generator features are still being matured.

Verification Results

  • All JUnit tests in src/test/java passed.
  • Python unit tests passed.
  • CLI successfully validated and processed complex Rosetta models with the new "v2" logic.

dschwartznyc and others added 30 commits January 22, 2026 18:15
sync function support with remove trailing spaces
… graph and enum imports, removing internal bundling logic, and add a design document for DAG sharing.
…e generation state and extract common constants.
…ectGenerator.generate` instead of individual dependency graph and enum imports.
…Expression generation. Added arithmetic unit tests
…nerated functions into the main object output.
…s to utils and update function generator to use them
Refactor error messages and add argument parsing for local runtime installation.
…n generation by removing enum imports parameter, and consolidate object generation tests.
…r` and enhance function parameter type and docstring generation.
…nputs and outputs, including fully qualified name generation and new unit tests.
…d field annotations, into `RuneToPythonMapper` and update the runtime environment setup.
…tity reuse tests, and improve generator build process for tests.
… venv path resolution and Windows compatibility in test scripts.
…ort, improved validation, and updated reference handling.
…specific test classes and update the generator.
…on, and collection literals, and refactor Python generator tests to assert specific expressions.
…ce, object conditions, shortcuts, and `asKey` operations, while refactoring existing enum and object generation tests.
…nce, enums, expressions, operators, collections, and null handling, and update the test runner script.
…ameters, and refactor list extension tests.
…es and update the Python environment setup script.
…neration methods and integrating if-condition block handling directly into alias and operation generation, and update the local runtime path in the setup script.
…constraints to ensure financial accuracy.
…ph population for functions and types. added tests that are disabled until the related isseus are resolved
…n error/warning handling, accompanied by new unit tests.
@dschwartznyc
Copy link
Contributor Author

Some of the tests were failing (they depended on function support which is forthcoming)- these have been fixed.

@dschwartznyc dschwartznyc merged commit 522377f into main Feb 20, 2026
3 checks passed
@dschwartznyc dschwartznyc deleted the feature/cli-refactor-tests branch February 20, 2026 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants