Skip to content

Commit d8c2a86

Browse files
committed
fix(harness)!: Always include json support
1 parent 1a2dd58 commit d8c2a86

8 files changed

Lines changed: 8 additions & 31 deletions

File tree

crates/libtest2-harness/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ pre-release-replacements = [
2626
[features]
2727
default = []
2828
color = ["dep:anstream", "dep:anstyle"]
29-
json = ["libtest-json/json"]
3029
threads = []
3130

3231
[dependencies]
@@ -35,7 +34,7 @@ lexarg-error = { version = "0.0.1", path = "../lexarg-error" }
3534
libtest-lexarg = { version = "0.0.1", path = "../libtest-lexarg" }
3635
anstream = { version = "0.6.4", optional = true }
3736
anstyle = { version = "1.0.10", optional = true }
38-
libtest-json = { version = "0.0.1", path = "../libtest-json" }
37+
libtest-json = { version = "0.0.1", path = "../libtest-json", features = ["json"] }
3938

4039
[dev-dependencies]
4140

crates/libtest2-harness/src/harness.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,7 @@ impl Harness<StateArgs> {
6868
}
6969
.write_global();
7070

71-
let notifier = notifier(&opts).unwrap_or_else(|err| {
72-
eprintln!("{err}");
73-
std::process::exit(1)
74-
});
71+
let notifier = notifier(&opts);
7572

7673
Ok(Harness {
7774
state: StateParsed {
@@ -228,26 +225,17 @@ fn parse_argfile(path: &std::path::Path) -> std::io::Result<Vec<std::ffi::OsStri
228225
Ok(content.lines().map(|s| s.into()).collect())
229226
}
230227

231-
fn notifier(opts: &libtest_lexarg::TestOpts) -> std::io::Result<Box<dyn notify::Notifier>> {
228+
fn notifier(opts: &libtest_lexarg::TestOpts) -> Box<dyn notify::Notifier> {
232229
#[cfg(feature = "color")]
233230
let stdout = anstream::stdout();
234231
#[cfg(not(feature = "color"))]
235232
let stdout = std::io::stdout();
236-
let notifier: Box<dyn notify::Notifier> = match opts.format {
237-
#[cfg(feature = "json")]
233+
match opts.format {
238234
OutputFormat::Json => Box::new(notify::JsonNotifier::new(stdout)),
239-
#[cfg(not(feature = "json"))]
240-
OutputFormat::Json => {
241-
return Err(std::io::Error::new(
242-
std::io::ErrorKind::Other,
243-
"`--format=json` is not supported",
244-
));
245-
}
246235
_ if opts.list => Box::new(notify::TerseListNotifier::new(stdout)),
247236
OutputFormat::Pretty => Box::new(notify::PrettyRunNotifier::new(stdout)),
248237
OutputFormat::Terse => Box::new(notify::TerseRunNotifier::new(stdout)),
249-
};
250-
Ok(notifier)
238+
}
251239
}
252240

253241
fn discover(

crates/libtest2-harness/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! An experimental replacement for the core of libtest
22
33
#![cfg_attr(docsrs, feature(doc_auto_cfg))]
4-
// #![warn(clippy::print_stderr)]
4+
#![warn(clippy::print_stderr)]
55
// #![warn(clippy::print_stdout)]
66

77
mod case;

crates/libtest2-harness/src/notify/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#[cfg(feature = "json")]
21
mod json;
32
#[cfg(not(feature = "color"))]
43
mod no_style;
@@ -8,7 +7,6 @@ mod style;
87
mod summary;
98
mod terse;
109

11-
#[cfg(feature = "json")]
1210
pub(crate) use json::*;
1311
#[cfg(not(feature = "color"))]
1412
pub(crate) use no_style::*;

crates/libtest2-mimic/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ pre-release-replacements = [
2424
]
2525

2626
[features]
27-
default = ["color", "json", "threads"]
27+
default = ["color", "threads"]
2828
color = ["libtest2-harness/color"]
29-
json = ["libtest2-harness/json"]
3029
threads = ["libtest2-harness/threads"]
3130

3231
[dependencies]

crates/libtest2-mimic/tests/testsuite/mixed_bag.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,6 @@ test result: FAILED. 1 passed; 1 failed; 0 ignored; 6 filtered out; finished in
698698
}
699699

700700
#[test]
701-
#[cfg(feature = "json")]
702701
fn list_json() {
703702
check(
704703
&["-Zunstable-options", "--format=json", "--list", "a"],
@@ -827,7 +826,6 @@ fn list_json() {
827826
}
828827

829828
#[test]
830-
#[cfg(feature = "json")]
831829
fn test_json() {
832830
check(
833831
&["-Zunstable-options", "--format=json", "a"],
@@ -1102,7 +1100,6 @@ test result: FAILED. 1 passed; 1 failed; 2 ignored; 0 filtered out; finished in
11021100
}
11031101

11041102
#[test]
1105-
#[cfg(feature = "json")]
11061103
fn fail_fast_json() {
11071104
check(
11081105
&["-Zunstable-options", "--format=json", "--fail-fast"],

crates/libtest2/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ pre-release-replacements = [
2424
]
2525

2626
[features]
27-
default = ["color", "json", "threads"]
27+
default = ["color", "threads"]
2828
color = ["libtest2-harness/color"]
29-
json = ["libtest2-harness/json"]
3029
threads = ["libtest2-harness/threads"]
3130

3231
[dependencies]

crates/libtest2/tests/testsuite/mixed_bag.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -705,7 +705,6 @@ test result: FAILED. 1 passed; 1 failed; 0 ignored; 6 filtered out; finished in
705705
}
706706

707707
#[test]
708-
#[cfg(feature = "json")]
709708
fn list_json() {
710709
check(
711710
&["-Zunstable-options", "--format=json", "--list", "a"],
@@ -834,7 +833,6 @@ fn list_json() {
834833
}
835834

836835
#[test]
837-
#[cfg(feature = "json")]
838836
fn test_json() {
839837
check(
840838
&["-Zunstable-options", "--format=json", "a"],
@@ -1109,7 +1107,6 @@ test result: FAILED. 1 passed; 1 failed; 2 ignored; 0 filtered out; finished in
11091107
}
11101108

11111109
#[test]
1112-
#[cfg(feature = "json")]
11131110
fn fail_fast_json() {
11141111
check(
11151112
&["-Zunstable-options", "--format=json", "--fail-fast"],

0 commit comments

Comments
 (0)