Skip to content

Commit

Permalink
feat(pocket-ic): POCKET_IC_MUTE_SERVER only mutes output when set to …
Browse files Browse the repository at this point in the history
…non-empty string (#2314)

This allows an override that explicitly unmutes the server, which is
needed when debugging canbench tests.

See: https://github.com/dfinity/canbench/pull/73/files
  • Loading branch information
max-dfinity authored Oct 31, 2024
1 parent 7dede60 commit 8822742
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
2 changes: 1 addition & 1 deletion packages/pocket-ic/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- The type `Topology` becomes a struct with two fields: `subnet_configs` contains an association of subnet ids to their configurations
and `default_effective_canister_id` contains a default effective canister id for canister creation.
- Management canister types are defined in a new `management_canister` module to avoid a dependency on `ic-cdk`.

- Environment variable `POCKET_IC_MUTE_SERVER` now only mutes output when set to non-empty string (previously any value muted server).


## 5.0.0 - 2024-09-12
Expand Down
31 changes: 17 additions & 14 deletions packages/pocket-ic/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,16 @@
//! ```
//! For more information, see the [README](https://crates.io/crates/pocket-ic).
//!
use crate::common::rest::{
BlobCompression, BlobId, CanisterHttpRequest, DtsFlag, ExtendedSubnetConfigSet, HttpsConfig,
InstanceId, MockCanisterHttpResponse, RawEffectivePrincipal, RawMessageId, SubnetId,
SubnetKind, SubnetSpec, Topology,
};
pub use crate::management_canister::CanisterSettings;
use crate::management_canister::{CanisterId, CanisterStatusResult};
use crate::nonblocking::PocketIc as PocketIcAsync;
use crate::{
common::rest::{
BlobCompression, BlobId, CanisterHttpRequest, DtsFlag, ExtendedSubnetConfigSet,
HttpsConfig, InstanceId, MockCanisterHttpResponse, RawEffectivePrincipal, RawMessageId,
SubnetId, SubnetKind, SubnetSpec, Topology,
},
management_canister::{CanisterId, CanisterStatusResult},
nonblocking::PocketIc as PocketIcAsync,
};
use candid::{
decode_args, encode_args,
utils::{ArgumentDecoder, ArgumentEncoder},
Expand All @@ -51,14 +53,13 @@ use reqwest::Url;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use slog::Level;
use std::sync::mpsc::channel;
use std::thread;
use std::thread::JoinHandle;
use std::{
net::SocketAddr,
path::{Path, PathBuf},
process::Command,
sync::Arc,
sync::{mpsc::channel, Arc},
thread,
thread::JoinHandle,
time::{Duration, SystemTime},
};
use thiserror::Error;
Expand Down Expand Up @@ -1382,9 +1383,11 @@ To download the binary, please visit https://github.com/dfinity/pocketic."
));
#[cfg(not(windows))]
cmd.arg(port_file_path.clone());
if std::env::var("POCKET_IC_MUTE_SERVER").is_ok() {
cmd.stdout(std::process::Stdio::null());
cmd.stderr(std::process::Stdio::null());
if let Ok(mute_server) = std::env::var("POCKET_IC_MUTE_SERVER") {
if !mute_server.is_empty() {
cmd.stdout(std::process::Stdio::null());
cmd.stderr(std::process::Stdio::null());
}
}
cmd.spawn()
.unwrap_or_else(|_| panic!("Failed to start PocketIC binary ({:?})", bin_path));
Expand Down

0 comments on commit 8822742

Please sign in to comment.