test: add CLI integration tests for find and resolve commands (Fixes #355)#363
test: add CLI integration tests for find and resolve commands (Fixes #355)#363karthiknadig wants to merge 2 commits intomainfrom
Conversation
Performance Report (Linux) ➖
Legend
|
Test Coverage Report (Linux)
Coverage increased! Great work! |
Test Coverage Report (Windows)
Coverage increased! Great work! |
Performance Report (Windows) ✅
Legend
|
There was a problem hiding this comment.
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.rscovering find/resolve commands, filtering, scoping, configuration equivalence, and glob expansion - All tests are properly gated behind the
cifeature flag to ensure they only run in environments with real Python installations - Includes a helper function
run_find_jsonand a utilityto_cli_kindfor converting JSON kind values to CLI kebab-case format
Performance Report (macOS)
Legend
|
There was a problem hiding this comment.
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
executablefield. According to thePythonEnvironmentstruct definition, theexecutablefield isOption<PathBuf>and can beNonefor 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;
Adds CLI integration tests for the
findandresolvecommands, covering all 6 test categories from #355 plus two additional tests.Tests added (
crates/pet/tests/cli_test.rs):find --jsonbasic output validation (structure, required fields)resolve --jsonoutput validation (version populated, executable matches)find --kindfiltering (all returned envs match requested kind)find --workspacescoping (empty temp dir yields fewer results)--conda-executablevsPET_CONDA_EXECUTABLE)--environment-directoriesviaPET_ENVIRONMENT_DIRECTORIESenv varAll tests are gated behind the
cifeature flag using#[cfg_attr(feature = "ci", test)].Fixes #355