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
3 changes: 1 addition & 2 deletions crates/libtest2-harness/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ pre-release-replacements = [
[features]
default = []
color = ["dep:anstream", "dep:anstyle"]
json = ["libtest-json/json"]
threads = []

[dependencies]
Expand All @@ -35,7 +34,7 @@ lexarg-error = { version = "0.0.1", path = "../lexarg-error" }
libtest-lexarg = { version = "0.0.1", path = "../libtest-lexarg" }
anstream = { version = "0.6.4", optional = true }
anstyle = { version = "1.0.10", optional = true }
libtest-json = { version = "0.0.1", path = "../libtest-json" }
libtest-json = { version = "0.0.1", path = "../libtest-json", features = ["json"] }

[dev-dependencies]

Expand Down
20 changes: 4 additions & 16 deletions crates/libtest2-harness/src/harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ impl Harness<StateArgs> {
}
.write_global();

let notifier = notifier(&opts).unwrap_or_else(|err| {
eprintln!("{err}");
std::process::exit(1)
});
let notifier = notifier(&opts);

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

fn notifier(opts: &libtest_lexarg::TestOpts) -> std::io::Result<Box<dyn notify::Notifier>> {
fn notifier(opts: &libtest_lexarg::TestOpts) -> Box<dyn notify::Notifier> {
#[cfg(feature = "color")]
let stdout = anstream::stdout();
#[cfg(not(feature = "color"))]
let stdout = std::io::stdout();
let notifier: Box<dyn notify::Notifier> = match opts.format {
#[cfg(feature = "json")]
match opts.format {
OutputFormat::Json => Box::new(notify::JsonNotifier::new(stdout)),
#[cfg(not(feature = "json"))]
OutputFormat::Json => {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
"`--format=json` is not supported",
));
}
_ if opts.list => Box::new(notify::TerseListNotifier::new(stdout)),
OutputFormat::Pretty => Box::new(notify::PrettyRunNotifier::new(stdout)),
OutputFormat::Terse => Box::new(notify::TerseRunNotifier::new(stdout)),
};
Ok(notifier)
}
}

fn discover(
Expand Down
2 changes: 1 addition & 1 deletion crates/libtest2-harness/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! An experimental replacement for the core of libtest

#![cfg_attr(docsrs, feature(doc_auto_cfg))]
// #![warn(clippy::print_stderr)]
#![warn(clippy::print_stderr)]
// #![warn(clippy::print_stdout)]

mod case;
Expand Down
2 changes: 0 additions & 2 deletions crates/libtest2-harness/src/notify/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#[cfg(feature = "json")]
mod json;
#[cfg(not(feature = "color"))]
mod no_style;
Expand All @@ -8,7 +7,6 @@ mod style;
mod summary;
mod terse;

#[cfg(feature = "json")]
pub(crate) use json::*;
#[cfg(not(feature = "color"))]
pub(crate) use no_style::*;
Expand Down
3 changes: 1 addition & 2 deletions crates/libtest2-mimic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ pre-release-replacements = [
]

[features]
default = ["color", "json", "threads"]
default = ["color", "threads"]
color = ["libtest2-harness/color"]
json = ["libtest2-harness/json"]
threads = ["libtest2-harness/threads"]

[dependencies]
Expand Down
3 changes: 0 additions & 3 deletions crates/libtest2-mimic/tests/testsuite/mixed_bag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,6 @@ test result: FAILED. 1 passed; 1 failed; 0 ignored; 6 filtered out; finished in
}

#[test]
#[cfg(feature = "json")]
fn list_json() {
check(
&["-Zunstable-options", "--format=json", "--list", "a"],
Expand Down Expand Up @@ -827,7 +826,6 @@ fn list_json() {
}

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

#[test]
#[cfg(feature = "json")]
fn fail_fast_json() {
check(
&["-Zunstable-options", "--format=json", "--fail-fast"],
Expand Down
3 changes: 1 addition & 2 deletions crates/libtest2/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ pre-release-replacements = [
]

[features]
default = ["color", "json", "threads"]
default = ["color", "threads"]
color = ["libtest2-harness/color"]
json = ["libtest2-harness/json"]
threads = ["libtest2-harness/threads"]

[dependencies]
Expand Down
3 changes: 0 additions & 3 deletions crates/libtest2/tests/testsuite/mixed_bag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -705,7 +705,6 @@ test result: FAILED. 1 passed; 1 failed; 0 ignored; 6 filtered out; finished in
}

#[test]
#[cfg(feature = "json")]
fn list_json() {
check(
&["-Zunstable-options", "--format=json", "--list", "a"],
Expand Down Expand Up @@ -834,7 +833,6 @@ fn list_json() {
}

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

#[test]
#[cfg(feature = "json")]
fn fail_fast_json() {
check(
&["-Zunstable-options", "--format=json", "--fail-fast"],
Expand Down
Loading