Skip to main content
The Palyra CLI employs a multi-layered testing strategy to ensure command consistency, cross-platform compatibility, and help-text stability. This system relies on a formal parity matrix that defines expected command structures and automates the verification of help outputs and installation workflows across Unix and Windows environments.

CLI Parity Matrix and Reporting

The CliParityMatrix serves as the source of truth for the intended surface area of the CLI. It defines the expected commands, subcommands, aliases, and flags that must exist in the binary.

Data Structures

The parity system is implemented in crates/palyra-cli/src/cli_parity.rs.

Verification Logic

The function build_cli_parity_report takes the matrix and the root command generated by Cli::command() and performs a deep inspection crates/palyra-cli/src/cli_parity.rs#165-171. It uses find_command to traverse the clap command tree and verify that all required elements defined in the matrix are present crates/palyra-cli/src/cli_parity.rs#179-200.

Parity Data Flow

The following diagram illustrates how the parity matrix is used to generate reports and enforce consistency. CLI Parity Verification Flow Sources: crates/palyra-cli/src/cli_parity.rs#165-200, crates/palyra-cli/src/lib.rs#76-80

Help Snapshot Testing

To prevent regressions in documentation and command discoverability, Palyra maintains a suite of help-text snapshots. These are verified by crates/palyra-cli/tests/help_snapshots.rs.

Snapshot Specification

The CliParitySnapshotSpec allows for platform-specific help files, accounting for differences like file extensions (.exe on Windows) or platform-specific subcommands crates/palyra-cli/src/cli_parity.rs#29-38.

Normalization and Comparison

During testing, the CLI output is normalized to ensure that minor environment differences (like terminal width or line endings) do not cause false failures.
  1. Terminal Width: Forced to 200 columns via the COLUMNS environment variable crates/palyra-cli/tests/help_snapshots.rs#26-31.
  2. Line Endings: CRLF is converted to LF crates/palyra-cli/tests/help_snapshots.rs#22-24.
  3. Binary Name: palyra.exe is normalized to palyra crates/palyra-cli/tests/help_snapshots.rs#23-23.
  4. Whitespace: Trailing whitespace is trimmed and redundant blank lines are collapsed crates/palyra-cli/tests/help_snapshots.rs#41-52.

Snapshot Update Workflow

If the CLI structure changes intentionally, developers can update snapshots by setting the PALYRA_UPDATE_HELP_SNAPSHOTS environment variable crates/palyra-cli/tests/help_snapshots.rs#8-12. Sources: crates/palyra-cli/src/cli_parity.rs#29-51, crates/palyra-cli/tests/help_snapshots.rs#22-53

CLI Install Smoke Tests

The smoke test suite ensures that the packaged CLI binary functions correctly in a real installation environment across Linux, macOS, and Windows.

Implementation

The smoke tests are driven by two main components:
  1. Rust Test Harness: crates/palyra-cli/tests/installed_smoke.rs executes the actual binary under test using environment variables to locate the installation root and configuration crates/palyra-cli/tests/installed_smoke.rs#17-36.
  2. PowerShell Orchestrator: scripts/test/run-cli-install-smoke.ps1 manages the lifecycle of the test environment, including creating temporary state directories and executing the CLI across different scenarios scripts/test/run-cli-install-smoke.ps1#41-83.

Smoke Test Scenarios

The suite validates several critical non-interactive flows: Smoke Test Execution Environment Sources: scripts/test/run-cli-install-smoke.ps1#41-101, crates/palyra-cli/tests/installed_smoke.rs#39-67, .github/workflows/cli-install-smoke.yml#21-47

Workflow Regression Matrix

The regression matrix is a component of the CI pipeline that ensures complex multi-step workflows (like onboarding or secret rotation) do not break. Sources: crates/palyra-cli/examples/emit_cli_install_smoke_inventory.rs#35-58, .github/workflows/cli-install-smoke.yml#1-7