diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fe3e6df52..f288b0d9a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -91,6 +91,12 @@ All errors should be handled in one of these ways: - With `.log_err().ok()`. - Bubbled up with `?`. +`backtrace` feature is enabled for `anyhow` crate +and `debug = 1` option is set in the test profile. +This allows to run `RUST_BACKTRACE=1 cargo test` +and get a backtrace with line numbers in resultified tests +which return `anyhow::Result`. + ### Logging For logging, use `info!`, `warn!` and `error!` macros. diff --git a/Cargo.toml b/Cargo.toml index c22119833..c0a312c32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,10 @@ panic = 'abort' opt-level = 1 [profile.test] +# Make anyhow `backtrace` feature useful. +# With `debug = 0` there are no line numbers in the backtrace +# produced with RUST_BACKTRACE=1. +debug = 1 opt-level = 0 # Always optimize dependencies. @@ -99,6 +103,7 @@ uuid = { version = "1", features = ["serde", "v4"] } [dev-dependencies] ansi_term = "0.12.0" +anyhow = { version = "1", features = ["backtrace"] } # Enable `backtrace` feature in tests. criterion = { version = "0.5.1", features = ["async_tokio"] } futures-lite = "2.0.0" log = "0.4"