Skip to content

test: add CLI integration tests for find and resolve commands (Fixes #355)#363

Open
karthiknadig wants to merge 2 commits intomainfrom
feature/issue-355
Open

test: add CLI integration tests for find and resolve commands (Fixes #355)#363
karthiknadig wants to merge 2 commits intomainfrom
feature/issue-355

Conversation

@karthiknadig
Copy link
Member

Adds CLI integration tests for the find and resolve commands, covering all 6 test categories from #355 plus two additional tests.

Tests added (crates/pet/tests/cli_test.rs):

  1. find --json basic output validation (structure, required fields)
  2. resolve --json output validation (version populated, executable matches)
  3. find --kind filtering (all returned envs match requested kind)
  4. find --workspace scoping (empty temp dir yields fewer results)
  5. CLI flag and env var equivalence (--conda-executable vs PET_CONDA_EXECUTABLE)
  6. CLI flag takes precedence over env var (crash-safety)
  7. Glob expansion in search paths (temp dirs with glob pattern)
  8. --environment-directories via PET_ENVIRONMENT_DIRECTORIES env var

All tests are gated behind the ci feature flag using #[cfg_attr(feature = "ci", test)].

Fixes #355

@karthiknadig karthiknadig requested a review from Copilot February 25, 2026 19:36
@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Performance Report (Linux) ➖

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 1ms 1ms 1ms 0ms 0%
Full Refresh 98ms 289ms 79ms 19ms 20.0%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Test Coverage Report (Linux)

Metric Value
Current Coverage 62.7%
Base Branch Coverage 58.8%
Delta 3.9% ✅

Coverage increased! Great work!

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Test Coverage Report (Windows)

Metric Value
Current Coverage 58.88%
Base Branch Coverage 55.04%
Delta 3.84% ✅

Coverage increased! Great work!

@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Performance Report (Windows) ✅

Metric PR (P50) PR (P95) Baseline (P50) Delta Change
Server Startup 9ms 12ms 10ms -1ms -10%
Full Refresh 144ms 1236ms 197ms -53ms -26.9%

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds comprehensive CLI integration tests for the pet find and pet resolve commands, addressing all requirements from issue #355. The tests use std::process::Command to spawn the pet binary and validate JSON output, following the same pattern as existing end-to-end tests.

Changes:

  • Added 8 CLI integration tests in crates/pet/tests/cli_test.rs covering find/resolve commands, filtering, scoping, configuration equivalence, and glob expansion
  • All tests are properly gated behind the ci feature flag to ensure they only run in environments with real Python installations
  • Includes a helper function run_find_json and a utility to_cli_kind for converting JSON kind values to CLI kebab-case format

aeschli
aeschli previously approved these changes Feb 25, 2026
@github-actions
Copy link

github-actions bot commented Feb 25, 2026

Performance Report (macOS)

Metric PR (P50) PR (P95) Baseline (P50) Delta
Server Startup 90ms 615ms 79ms 11ms
Full Refresh 159ms 32274ms 130ms 29ms

Results based on 10 iterations. P50 = median, P95 = 95th percentile.


Legend
  • 🚀 Significant speedup (>100ms faster)
  • ✅ Faster than baseline
  • ➖ No significant change
  • 🔺 Slower than baseline (>100ms)
  • ⚠️ Significant slowdown (>500ms)

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

crates/pet/tests/cli_test.rs:58

  • This test incorrectly asserts that all environments have an executable field. According to the PythonEnvironment struct definition, the executable field is Option<PathBuf> and can be None for Conda environments that don't have Python installed (see comment in crates/pet-core/src/python_environment.rs:56-57). This assertion will cause the test to fail when it encounters such environments. The test should check if at least one environment has an executable field, rather than requiring all of them to have one.
    // Each environment should have at minimum a kind.
    // Executable may be null for environments without Python installed (e.g. Conda
    // envs created without specifying python as a dependency).
    let environments = json["environments"].as_array().unwrap();
    assert!(
        !environments.is_empty(),
        "expected at least one environment to be discovered"
    );
    let mut has_executable = false;
    for env in environments {
        assert!(env["kind"].is_string(), "environment missing 'kind': {env}");
        if env["executable"].is_string() {
            has_executable = true;

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.

Add CLI integration tests for find and resolve commands

4 participants