Skip to content

Implement CLI Flags for Validation Control and Add Test Suite #142

@dschwartznyc

Description

@dschwartznyc

Feature Request

Description of Problem:

Description: The current PythonCodeGeneratorCLI exits immediately (System.exit(1)) upon encountering any validation errors, and ignores warnings. This rigid behavior prevents users from inspecting partially correct models or enforcing stricter quality control (e.g., treating warnings as errors).

We need to enhance the CLI with fine-grained control over the generation process and add unit tests to ensure robustness.

Potential Solutions:

  1. Refactor CLI for Testability: PythonCodeGeneratorCLI to expose a method (e.g., calculateExitCode(String[] args)) that returns an integer status code instead of directly calling System.exit(). This allows unit tests to invoke the CLI logic without terminating the JVM.main method will simply delegate to this new method and pass the result to System.exit().

  2. Add Control Flags:
    --allow-errors (-e): Continue generation even if validation errors occur. Useful for debugging or partial generation.
    --fail-on-warnings (-w): Treat validation warnings as errors. Useful for strict CI/CD pipelines.
    Add CLI Unit Tests:

  3. Create a new test class PythonCodeGeneratorCLITest.java.
    Test scenarios:
    -- Successful generation (exit code 0).
    -- Validation error -> Fail (exit code 1).
    -- Validation error + --allow-errors -> Success (exit code 0).
    -- Warning -> Success (exit code 0).
    -- Warning + --fail-on-warnings -> Fail (exit code 1).

Acceptance Criteria:

-- CLI accepts -e and -w flags and behaves as documented.
-- Unit tests cover all major execution paths and flag combinations.
-- No regression in existing CLI functionality.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions