Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question regarding stacktrace #353

Open
oknozor opened this issue Mar 7, 2024 · 0 comments
Open

Question regarding stacktrace #353

oknozor opened this issue Mar 7, 2024 · 0 comments

Comments

@oknozor
Copy link

oknozor commented Mar 7, 2024

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 ?

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

No branches or pull requests

1 participant