Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ include = [
anyhow = "1.0.62"
clap = { version = "3.2.17", features = ["derive", "env"] }
tracing = "0.1.36"
tracing-subscriber = "0.3.15"
tracing-subscriber = { version = "0.3.15", features = ["env-filter"] }
heck = "0.4.0"
zip = { version = "0.6.2", default-features = false }
parity-wasm = "0.45.0"
Expand Down
18 changes: 1 addition & 17 deletions src/cmd/extrinsics/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,6 @@ impl ContractsNodeProcess {
}
}

/// Init a tracing subscriber for logging in tests.
///
/// Be aware that this enables `TRACE` by default. It also ignores any error
/// while setting up the logger.
///
/// The logs are not shown by default, logs are only shown when the test fails
/// or if [`nocapture`](https://doc.rust-lang.org/cargo/commands/cargo-test.html#display-options)
/// is being used.
#[cfg(feature = "std")]
pub fn init_tracing_subscriber() {
let _ = tracing_subscriber::fmt()
.with_max_level(tracing::Level::TRACE)
.with_test_writer()
.try_init();
}

/// Sanity test the whole lifecycle of:
/// new -> build -> upload -> instantiate -> call
///
Expand All @@ -152,7 +136,7 @@ pub fn init_tracing_subscriber() {
#[ignore]
#[async_std::test]
async fn build_upload_instantiate_call() {
init_tracing_subscriber();
crate::util::tests::init_tracing_subscriber();

let tmp_dir = tempfile::Builder::new()
.prefix("cargo-contract.cli.test.")
Expand Down
2 changes: 1 addition & 1 deletion src/cmd/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ mod tests {

#[test]
fn generate_metadata() {
tracing_subscriber::fmt::init();
crate::util::tests::init_tracing_subscriber();
with_new_contract_project(|manifest_path| {
// add optional metadata fields
let mut test_manifest = TestContractManifest::new(manifest_path)?;
Expand Down
15 changes: 15 additions & 0 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,21 @@ pub mod tests {
std::fs::set_permissions(&path, std::fs::Permissions::from_mode(0o777))
.expect("setting permissions failed");
}

/// Init a tracing subscriber for logging in tests.
///
/// Be aware that this enables `TRACE` by default. It also ignores any error
/// while setting up the logger.
///
/// The logs are not shown by default, logs are only shown when the test fails
/// or if [`nocapture`](https://doc.rust-lang.org/cargo/commands/cargo-test.html#display-options)
/// is being used.
pub fn init_tracing_subscriber() {
let _ = tracing_subscriber::fmt()
.with_max_level(tracing::Level::TRACE)
.with_test_writer()
.try_init();
}
}

// Unzips the file at `template` to `out_dir`.
Expand Down