dtolnay/anyhow

Question regarding stacktrace

Opened this issue · 0 comments

Hello,
I have a regression in some test for a CLI using anyhow when upgrading from 1.0.75 to 1.0.80.

Here is the test:

#[sealed_test]
fn commit_fail_if_not_a_repository() -> Result<()> {
    // Act
    let output = Command::cargo_bin("cog")?
        .arg("commit")
        .arg("feat")
        .arg("this is a commit message")
        .arg("scope")
        .output()?;

    let stderr = String::from_utf8(output.stderr)?;

    // Assert
    let current_dir = std::env::current_dir()?;
    let current_dir: &OsStr = current_dir.as_os_str();
    let current_dir = current_dir.to_str().expect("utf8 error");

    assert_eq!(
        stderr,
        formatdoc!(
            "Error: failed to open repository

        cause: could not find repository at '{}'; class=Repository (6); code=NotFound (-3)

        ",
            current_dir
        )
    );
    Ok(())
}

On 1.0.75, the test pass, when upgrading I now have the stacktrace displayed in stderr as well as the expected error message.
I saw there is a backstrace feature flag in anyhow, but I am not sure its related or not. Is there a way to disable this behavior ?