Skip to content

Commit 7019d29

Browse files
committed
Add nocapture option to tests
1 parent 6d6e42b commit 7019d29

File tree

5 files changed

+13
-2
lines changed

5 files changed

+13
-2
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ xtask/target
33

44
.DS_Store
55
.vscode
6-
.dir-locals.el
6+
.dir-locals.el
7+
8+
notes.org

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ syn = {version = "~2.0" , features = ["full"]}
3333
tracing = { version = "0.1.40", features = ["log"] }
3434
tracing-subscriber = { version = "0.3.18", features = ["env-filter", "registry"] }
3535

36+
# for tests
3637
rstest = "0.25.0"
3738
serial_test = "3.2.0"
3839

crates/tracel-xtask-macros/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ fn get_additional_cmd_args_map() -> HashMap<&'static str, proc_macro2::TokenStre
303303
required = false
304304
)]
305305
pub force: bool,
306+
#[doc = r"If set, test logs are sent to output."]
307+
#[arg(long = "nocapture", required = false)]
308+
pub no_capture: bool,
306309
},
307310
),
308311
(
@@ -526,6 +529,7 @@ fn generate_command_args_tryinto(args: TokenStream, input: TokenStream) -> Token
526529
|| ident_str == "ignore_audit"
527530
|| ident_str == "jobs"
528531
|| ident_str == "no_default_features"
532+
|| ident_str == "no_capture"
529533
|| ident_str == "only"
530534
|| ident_str == "release"
531535
|| ident_str == "threads")

crates/tracel-xtask/src/commands/test.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ pub fn handle_command(args: TestCmdArgs, env: Environment, _ctx: Context) -> any
4040
force: args.force,
4141
features: args.features.clone(),
4242
no_default_features: args.no_default_features,
43+
no_capture: args.no_capture,
4344
},
4445
env.clone(),
4546
_ctx.clone(),
@@ -81,6 +82,9 @@ fn push_optional_args(cmd_args: &mut Vec<String>, args: &TestCmdArgs) {
8182
if let Some(threads) = &args.threads {
8283
cmd_args.extend(vec!["--test-threads".to_string(), threads.to_string()]);
8384
};
85+
if args.no_capture {
86+
cmd_args.push("--nocapture".to_string());
87+
}
8488
}
8589

8690
pub fn run_unit(target: &Target, args: &TestCmdArgs) -> Result<()> {
@@ -100,7 +104,6 @@ pub fn run_unit(target: &Target, args: &TestCmdArgs) -> Result<()> {
100104
.map(|s| s.to_string())
101105
.collect::<Vec<String>>();
102106
push_optional_args(&mut cmd_args, args);
103-
// let cmd_args: Vec<&str> = cmd_args.iter().map(String::as_str).collect();
104107
run_process_for_workspace(
105108
"cargo",
106109
&cmd_args.iter().map(String::as_str).collect::<Vec<&str>>(),

crates/tracel-xtask/src/commands/validate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ pub fn handle_command(args: ValidateCmdArgs, env: Environment, ctx: Context) ->
4848
force: false,
4949
features: None,
5050
no_default_features: false,
51+
no_capture: false,
5152
},
5253
env.clone(),
5354
ctx.clone(),

0 commit comments

Comments
 (0)