Skip to content

Command::cargo_bin is deprecated... and is used in several examples #259

Description

@ahl

Some examples:

assert_cmd/README.md

Lines 15 to 22 in ee88946

Here's a trivial example:
```rust,no_run
use assert_cmd::Command;
let mut cmd = Command::cargo_bin("bin_fixture").unwrap();
cmd.assert().success();
```

assert_cmd/src/lib.rs

Lines 48 to 63 in ee88946

//! And a little of everything:
//! ```rust,no_run
//! use assert_cmd::Command;
//!
//! let mut cmd = Command::cargo_bin("bin_fixture").unwrap();
//! let assert = cmd
//! .arg("-A")
//! .env("stdout", "hello")
//! .env("exit", "42")
//! .write_stdin("42")
//! .assert();
//! assert
//! .failure()
//! .code(42)
//! .stdout("hello\n");
//! ```

assert_cmd/src/cargo.rs

Lines 6 to 19 in ee88946

//! # Examples
//!
//! Simple case:
//!
//! ```rust,no_run
//! use assert_cmd::prelude::*;
//! use assert_cmd::pkg_name;
//!
//! use std::process::Command;
//!
//! let mut cmd = Command::cargo_bin(pkg_name!())
//! .unwrap();
//! let output = cmd.unwrap();
//! ```

Perhaps beyond the scope of this issue, but I haven't been able to make use of the proposed alternatives to Command::cargo_bin:
https://github.com/oxidecomputer/oxide.rs/blob/06f4a01170f2decf81d4d39ca3a5f02a3c5345a6/cli/src/cmd_auth.rs#L651-L663

In particular, we're using this in a unit test which appears to be either something that worked by accident or a newly broken use case.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions