Skip to content

Commit 1211690

Browse files
Add --nocapture flag to cargo contract test subcommand (#2037)
* Add `--nocapture` flag to `cargo contract test` subcommand * Update changelog
1 parent d67fd09 commit 1211690

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
### Added
1010
- Support setting ABI in `Cargo.toml` and propagate ABI into build environment via `cfg` flag - [#2033](https://github.com/use-ink/cargo-contract/pull/2033)
1111
- Add `cargo contract test` subcommand - [#2034](https://github.com/use-ink/cargo-contract/pull/2034)
12+
- Add `--nocapture` flag to `cargo contract test` subcommand - [#2037](https://github.com/use-ink/cargo-contract/pull/2037)
1213

1314
### Fixed
1415
- Fixed erroneous "[lib] name" warnings - [#2035](https://github.com/use-ink/cargo-contract/pull/2035)

crates/cargo-contract/src/cmd/test_cmd.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ pub struct TestCommand {
3838
all_features: bool,
3939
#[clap(flatten)]
4040
verbosity: VerbosityFlags,
41+
/// Disable capturing of test output (e.g. for debugging).
42+
#[clap(long)]
43+
nocapture: bool,
4144
/// Arguments to pass to `cargo test`.
4245
#[arg(last = true)]
4346
args: Vec<String>,
@@ -55,6 +58,13 @@ impl TestCommand {
5558
if !self.args.is_empty() {
5659
args.extend(self.args.clone());
5760
}
61+
if self.nocapture {
62+
// Adds escape arg (if necessary).
63+
if !self.args.iter().any(|arg| arg == "--") {
64+
args.push("--".to_string());
65+
}
66+
args.push("--nocapture".to_string());
67+
}
5868

5969
// Composes ABI `cfg` flag.
6070
let mut env = Vec::new();

0 commit comments

Comments
 (0)