diff --git a/crates/puffin-cli/src/main.rs b/crates/puffin-cli/src/main.rs index 0f743e965..08d01fa46 100644 --- a/crates/puffin-cli/src/main.rs +++ b/crates/puffin-cli/src/main.rs @@ -147,6 +147,7 @@ struct VenvArgs { python: Option, /// The path to the virtual environment to create. + #[clap(default_value = ".venv")] name: PathBuf, } diff --git a/crates/puffin-cli/tests/snapshots/venv__create_venv_defaults_to_cwd.snap b/crates/puffin-cli/tests/snapshots/venv__create_venv_defaults_to_cwd.snap new file mode 100644 index 000000000..ca81a43dd --- /dev/null +++ b/crates/puffin-cli/tests/snapshots/venv__create_venv_defaults_to_cwd.snap @@ -0,0 +1,15 @@ +--- +source: crates/puffin-cli/tests/venv.rs +info: + program: puffin + args: + - venv +--- +success: true +exit_code: 0 +----- stdout ----- + +----- stderr ----- +Using Python interpreter: /usr/bin/python3 +Creating virtual environment at: .venv + diff --git a/crates/puffin-cli/tests/venv.rs b/crates/puffin-cli/tests/venv.rs index 69fe06bd4..f8ff31a06 100644 --- a/crates/puffin-cli/tests/venv.rs +++ b/crates/puffin-cli/tests/venv.rs @@ -30,3 +30,24 @@ fn create_venv() -> Result<()> { Ok(()) } + +#[test] +fn create_venv_defaults_to_cwd() -> Result<()> { + let tempdir = assert_fs::TempDir::new()?; + let venv = tempdir.child(".venv"); + + insta::with_settings!({ + filters => vec![ + (r"Using Python interpreter: .+", "Using Python interpreter: /usr/bin/python3"), + (tempdir.to_str().unwrap(), "/home/ferris/project"), + ] + }, { + assert_cmd_snapshot!(Command::new(get_cargo_bin(BIN_NAME)) + .arg("venv") + .current_dir(&tempdir)); + }); + + venv.assert(predicates::path::is_dir()); + + Ok(()) +}