From 5e9b2d88f38bf65f20162b27547f19cc4dfbd62c Mon Sep 17 00:00:00 2001 From: Nextest Bot Date: Thu, 21 Dec 2023 15:50:50 -0800 Subject: [PATCH] Update Rust crate owo-colors to v4 (#1178) Co-authored-by: Rain --- Cargo.lock | 59 +++++---------- cargo-nextest/Cargo.toml | 4 +- cargo-nextest/src/dispatch.rs | 17 +++-- cargo-nextest/src/errors.rs | 67 +++++++++-------- cargo-nextest/src/helpers.rs | 6 +- cargo-nextest/src/output.rs | 132 ++-------------------------------- cargo-nextest/src/update.rs | 22 +++--- nextest-runner/Cargo.toml | 2 +- quick-junit/Cargo.toml | 2 +- workspace-hack/Cargo.toml | 4 +- 10 files changed, 81 insertions(+), 234 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 681e0e07fee..ab82bd81def 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -163,17 +163,6 @@ dependencies = [ "windows-sys 0.48.0", ] -[[package]] -name = "atty" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" -dependencies = [ - "hermit-abi 0.1.19", - "libc", - "winapi", -] - [[package]] name = "autocfg" version = "1.1.0" @@ -388,12 +377,13 @@ dependencies = [ "nextest-runner", "nextest-workspace-hack", "once_cell", - "owo-colors", + "owo-colors 3.5.0", + "owo-colors 4.0.0", "pathdiff", "semver", "serde_json", "shell-words", - "supports-color 2.1.0", + "supports-color", "supports-unicode", "thiserror", ] @@ -511,7 +501,7 @@ dependencies = [ "eyre", "indenter", "once_cell", - "owo-colors", + "owo-colors 3.5.0", ] [[package]] @@ -1157,15 +1147,6 @@ version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" -[[package]] -name = "hermit-abi" -version = "0.1.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" -dependencies = [ - "libc", -] - [[package]] name = "hermit-abi" version = "0.3.3" @@ -1433,7 +1414,7 @@ version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb0889898416213fab133e1d33a0e5858a48177452750691bde3666d0fdbaf8b" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi", "rustix", "windows-sys 0.48.0", ] @@ -1560,8 +1541,8 @@ dependencies = [ "is-terminal", "miette-derive", "once_cell", - "owo-colors", - "supports-color 2.1.0", + "owo-colors 3.5.0", + "supports-color", "supports-hyperlinks", "supports-unicode", "terminal_size", @@ -1729,7 +1710,7 @@ dependencies = [ "nextest-workspace-hack", "nix", "once_cell", - "owo-colors", + "owo-colors 4.0.0", "pathdiff", "pin-project-lite", "pretty_assertions", @@ -1790,7 +1771,7 @@ dependencies = [ "miniz_oxide", "num-traits", "once_cell", - "owo-colors", + "owo-colors 4.0.0", "proc-macro2", "quote", "rand", @@ -1877,7 +1858,7 @@ version = "1.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4161fcb6d602d4d2081af7c3a45852d875a03dd337a6bfdd6e06407b61342a43" dependencies = [ - "hermit-abi 0.3.3", + "hermit-abi", "libc", ] @@ -1961,8 +1942,14 @@ name = "owo-colors" version = "3.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f" + +[[package]] +name = "owo-colors" +version = "4.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "caff54706df99d2a78a5a4e3455ff45448d81ef1bb63c22cd14052ca0e993a3f" dependencies = [ - "supports-color 1.3.1", + "supports-color", ] [[package]] @@ -2152,7 +2139,7 @@ dependencies = [ "goldenfile", "indexmap 2.1.0", "nextest-workspace-hack", - "owo-colors", + "owo-colors 4.0.0", "quick-xml 0.31.0", "strip-ansi-escapes", "thiserror", @@ -2790,16 +2777,6 @@ version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc" -[[package]] -name = "supports-color" -version = "1.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ba6faf2ca7ee42fdd458f4347ae0a9bd6bcc445ad7cb57ad82b383f18870d6f" -dependencies = [ - "atty", - "is_ci", -] - [[package]] name = "supports-color" version = "2.1.0" diff --git a/cargo-nextest/Cargo.toml b/cargo-nextest/Cargo.toml index 49ac438749b..7d0a811ccd0 100644 --- a/cargo-nextest/Cargo.toml +++ b/cargo-nextest/Cargo.toml @@ -30,7 +30,9 @@ nextest-filtering = { version = "=0.7.0", path = "../nextest-filtering" } nextest-runner = { version = "=0.52.2", path = "../nextest-runner" } nextest-metadata = { version = "=0.10.0", path = "../nextest-metadata" } once_cell = "1.19.0" -owo-colors = { version = "3.5.0", features = ["supports-colors"] } +owo-colors = { version = "4.0.0", features = ["supports-colors"] } +# owo-colors 3 is required for miette v5 styling +owo-colors-3 = { package = "owo-colors", version = "3.5.0" } pathdiff = { version = "0.2.1", features = ["camino"] } semver = "1.0.20" shell-words = "1.1.0" diff --git a/cargo-nextest/src/dispatch.rs b/cargo-nextest/src/dispatch.rs index 399ce1e25a5..a479c6523b4 100644 --- a/cargo-nextest/src/dispatch.rs +++ b/cargo-nextest/src/dispatch.rs @@ -3,7 +3,7 @@ use crate::{ cargo_cli::{CargoCli, CargoOptions}, - output::{OutputContext, OutputOpts, OutputWriter, SupportsColorsV2}, + output::{OutputContext, OutputOpts, OutputWriter}, reuse_build::{make_path_mapper, ArchiveFormatOpt, ReuseBuildOpts}, ExpectedError, Result, ReuseBuildKind, }; @@ -37,7 +37,7 @@ use nextest_runner::{ test_filter::{RunIgnored, TestFilterBuilder}, }; use once_cell::sync::OnceCell; -use owo_colors::{OwoColorize, Style}; +use owo_colors::{OwoColorize, Stream, Style}; use semver::Version; use std::{ collections::BTreeSet, @@ -46,7 +46,6 @@ use std::{ io::{Cursor, Write}, sync::Arc, }; -use supports_color::Stream; /// A next-generation test runner for Rust. /// @@ -1104,8 +1103,8 @@ impl BaseApp { } => { log::warn!( "this repository recommends nextest version {}, but the current version is {}", - required.if_supports_color_2(Stream::Stderr, |x| x.bold()), - current.if_supports_color_2(Stream::Stderr, |x| x.bold()), + required.if_supports_color(Stream::Stderr, |x| x.bold()), + current.if_supports_color(Stream::Stderr, |x| x.bold()), ); if let Some(tool) = tool { log::info!( @@ -1182,8 +1181,8 @@ impl BaseApp { } => { log::warn!( "this repository recommends nextest version {}, but the current version is {}", - required.if_supports_color_2(Stream::Stderr, |x| x.bold()), - current.if_supports_color_2(Stream::Stderr, |x| x.bold()), + required.if_supports_color(Stream::Stderr, |x| x.bold()), + current.if_supports_color(Stream::Stderr, |x| x.bold()), ); if let Some(tool) = tool { log::info!( @@ -1938,7 +1937,7 @@ fn log_platform_runner(prefix: &str, runner: &PlatformRunner) { let runner_command = shell_words::join(std::iter::once(runner.binary()).chain(runner.args())); log::info!( "{prefix}using target runner `{}` defined by {}", - runner_command.if_supports_color_2(Stream::Stderr, |s| s.bold()), + runner_command.if_supports_color(Stream::Stderr, |s| s.bold()), runner.source() ) } @@ -1951,7 +1950,7 @@ fn warn_on_err(thing: &str, err: &(dyn std::error::Error)) -> Result<(), std::fm write!( s, "\n {} {}", - "caused by:".if_supports_color_2(Stream::Stderr, |s| s.style(Style::new().yellow())), + "caused by:".if_supports_color(Stream::Stderr, |s| s.style(Style::new().yellow())), err )?; next_error = err.source(); diff --git a/cargo-nextest/src/errors.rs b/cargo-nextest/src/errors.rs index 9e9145c717a..ac00dc4af05 100644 --- a/cargo-nextest/src/errors.rs +++ b/cargo-nextest/src/errors.rs @@ -1,16 +1,14 @@ // Copyright (c) The nextest Contributors // SPDX-License-Identifier: MIT OR Apache-2.0 -use crate::output::SupportsColorsV2; use camino::Utf8PathBuf; use itertools::Itertools; use nextest_filtering::errors::FilterExpressionParseErrors; use nextest_metadata::NextestExitCode; use nextest_runner::errors::*; -use owo_colors::OwoColorize; +use owo_colors::{OwoColorize, Stream}; use semver::Version; use std::{error::Error, string::FromUtf8Error}; -use supports_color::Stream; use thiserror::Error; pub(crate) type Result = std::result::Result; @@ -447,7 +445,7 @@ impl ExpectedError { Self::CargoMetadataExecFailed { command, err } => { log::error!( "failed to execute `{}`", - command.if_supports_color_2(Stream::Stderr, |x| x.bold()) + command.if_supports_color(Stream::Stderr, |x| x.bold()) ); Some(err as &dyn Error) } @@ -458,7 +456,7 @@ impl ExpectedError { Self::CargoLocateProjectExecFailed { command, err } => { log::error!( "failed to execute `{}`", - command.if_supports_color_2(Stream::Stderr, |x| x.bold()) + command.if_supports_color(Stream::Stderr, |x| x.bold()) ); Some(err as &dyn Error) } @@ -473,7 +471,7 @@ impl ExpectedError { Self::WorkspaceRootInvalid { workspace_root } => { log::error!( "workspace root `{}` is invalid", - workspace_root.if_supports_color_2(Stream::Stderr, |x| x.bold()) + workspace_root.if_supports_color(Stream::Stderr, |x| x.bold()) ); None } @@ -489,7 +487,7 @@ impl ExpectedError { ReuseBuildKind::ReuseWithWorkspaceRemap { workspace_root } => { format!( "\n(hint: ensure that project source is available at {})", - workspace_root.if_supports_color_2(Stream::Stderr, |x| x.bold()) + workspace_root.if_supports_color(Stream::Stderr, |x| x.bold()) ) } ReuseBuildKind::Reuse => { @@ -501,14 +499,14 @@ impl ExpectedError { }; log::error!( "workspace root manifest at {} does not exist{hint_str}", - path.if_supports_color_2(Stream::Stderr, |x| x.bold()) + path.if_supports_color(Stream::Stderr, |x| x.bold()) ); None } Self::StoreDirCreateError { store_dir, err } => { log::error!( "failed to create store dir at `{}`", - store_dir.if_supports_color_2(Stream::Stderr, |x| x.bold()) + store_dir.if_supports_color(Stream::Stderr, |x| x.bold()) ); Some(err as &dyn Error) } @@ -527,7 +525,7 @@ impl ExpectedError { provided_by_tool(err.tool()), override_error .profile_name - .if_supports_color_2(Stream::Stderr, |p| p.bold()), + .if_supports_color(Stream::Stderr, |p| p.bold()), ); for report in override_error.reports() { log::error!(target: "cargo_nextest::no_heading", "{report:?}"); @@ -542,17 +540,17 @@ impl ExpectedError { let known_groups_str = known_groups .iter() .map(|group_name| { - group_name.if_supports_color_2(Stream::Stderr, |x| x.bold()) + group_name.if_supports_color(Stream::Stderr, |x| x.bold()) }) .join(", "); let mut errors_str = String::new(); for error in errors { errors_str.push_str(&format!( " - group `{}` in overrides for profile `{}`\n", - error.name.if_supports_color_2(Stream::Stderr, |x| x.bold()), + error.name.if_supports_color(Stream::Stderr, |x| x.bold()), error .profile_name - .if_supports_color_2(Stream::Stderr, |x| x.bold()) + .if_supports_color(Stream::Stderr, |x| x.bold()) )); } @@ -571,17 +569,17 @@ impl ExpectedError { let known_scripts_str = known_scripts .iter() .map(|group_name| { - group_name.if_supports_color_2(Stream::Stderr, |x| x.bold()) + group_name.if_supports_color(Stream::Stderr, |x| x.bold()) }) .join(", "); let mut errors_str = String::new(); for error in errors { errors_str.push_str(&format!( " - script `{}` specified within profile `{}`\n", - error.name.if_supports_color_2(Stream::Stderr, |x| x.bold()), + error.name.if_supports_color(Stream::Stderr, |x| x.bold()), error .profile_name - .if_supports_color_2(Stream::Stderr, |x| x.bold()) + .if_supports_color(Stream::Stderr, |x| x.bold()) )); } @@ -597,13 +595,13 @@ impl ExpectedError { let unknown_str = unknown .iter() .map(|feature_name| { - feature_name.if_supports_color_2(Stream::Stderr, |x| x.bold()) + feature_name.if_supports_color(Stream::Stderr, |x| x.bold()) }) .join(", "); let known_str = known .iter() .map(|feature_name| { - feature_name.if_supports_color_2(Stream::Stderr, |x| x.bold()) + feature_name.if_supports_color(Stream::Stderr, |x| x.bold()) }) .join(", "); @@ -637,29 +635,29 @@ impl ExpectedError { } => { log::error!( "argument {} specified file `{}` that couldn't be read", - format!("--{arg_name}").if_supports_color_2(Stream::Stderr, |x| x.bold()), - file_name.if_supports_color_2(Stream::Stderr, |x| x.bold()), + format!("--{arg_name}").if_supports_color(Stream::Stderr, |x| x.bold()), + file_name.if_supports_color(Stream::Stderr, |x| x.bold()), ); Some(err as &dyn Error) } Self::UnknownArchiveFormat { archive_file, err } => { log::error!( "failed to autodetect archive format for {}", - archive_file.if_supports_color_2(Stream::Stderr, |x| x.bold()) + archive_file.if_supports_color(Stream::Stderr, |x| x.bold()) ); Some(err as &dyn Error) } Self::ArchiveCreateError { archive_file, err } => { log::error!( "error creating archive `{}`", - archive_file.if_supports_color_2(Stream::Stderr, |x| x.bold()) + archive_file.if_supports_color(Stream::Stderr, |x| x.bold()) ); Some(err as &dyn Error) } Self::ArchiveExtractError { archive_file, err } => { log::error!( "error extracting archive `{}`", - archive_file.if_supports_color_2(Stream::Stderr, |x| x.bold()) + archive_file.if_supports_color(Stream::Stderr, |x| x.bold()) ); Some(err as &dyn Error) } @@ -674,17 +672,16 @@ impl ExpectedError { } => { log::error!( "argument {} specified JSON file `{}` that couldn't be deserialized", - format!("--{arg_name}").if_supports_color_2(Stream::Stderr, |x| x.bold()), - file_name.if_supports_color_2(Stream::Stderr, |x| x.bold()), + format!("--{arg_name}").if_supports_color(Stream::Stderr, |x| x.bold()), + file_name.if_supports_color(Stream::Stderr, |x| x.bold()), ); Some(err as &dyn Error) } Self::PathMapperConstructError { arg_name, err } => { log::error!( "argument {} specified `{}` that couldn't be read", - format!("--{arg_name}").if_supports_color_2(Stream::Stderr, |x| x.bold()), - err.input() - .if_supports_color_2(Stream::Stderr, |x| x.bold()) + format!("--{arg_name}").if_supports_color(Stream::Stderr, |x| x.bold()), + err.input().if_supports_color(Stream::Stderr, |x| x.bold()) ); Some(err as &dyn Error) } @@ -692,7 +689,7 @@ impl ExpectedError { let metadata_source = match file_name { Some(path) => format!( " from file `{}`", - path.if_supports_color_2(Stream::Stderr, |x| x.bold()) + path.if_supports_color(Stream::Stderr, |x| x.bold()) ), None => "".to_owned(), }; @@ -710,7 +707,7 @@ impl ExpectedError { Self::BuildExecFailed { command, err } => { log::error!( "failed to execute `{}`", - command.if_supports_color_2(Stream::Stderr, |x| x.bold()) + command.if_supports_color(Stream::Stderr, |x| x.bold()) ); Some(err as &dyn Error) } @@ -719,7 +716,7 @@ impl ExpectedError { Some(code) => { format!( " with code {}", - code.if_supports_color_2(Stream::Stderr, |x| x.bold()) + code.if_supports_color(Stream::Stderr, |x| x.bold()) ) } None => "".to_owned(), @@ -727,7 +724,7 @@ impl ExpectedError { log::error!( "command `{}` exited{}", - command.if_supports_color_2(Stream::Stderr, |x| x.bold()), + command.if_supports_color(Stream::Stderr, |x| x.bold()), with_code_str, ); @@ -768,8 +765,8 @@ impl ExpectedError { } => { log::error!( "this repository requires nextest version {}, but the current version is {}", - required.if_supports_color_2(Stream::Stderr, |x| x.bold()), - current.if_supports_color_2(Stream::Stderr, |x| x.bold()), + required.if_supports_color(Stream::Stderr, |x| x.bold()), + current.if_supports_color(Stream::Stderr, |x| x.bold()), ); if let Some(tool) = tool { log::info!( @@ -794,7 +791,7 @@ impl ExpectedError { Self::UpdateError { err } => { log::error!( "failed to update nextest (please update manually by visiting <{}>)", - "https://get.nexte.st".if_supports_color_2(Stream::Stderr, |x| x.bold()) + "https://get.nexte.st".if_supports_color(Stream::Stderr, |x| x.bold()) ); Some(err as &dyn Error) } diff --git a/cargo-nextest/src/helpers.rs b/cargo-nextest/src/helpers.rs index c3ab18dc11f..aedf6bd947f 100644 --- a/cargo-nextest/src/helpers.rs +++ b/cargo-nextest/src/helpers.rs @@ -3,14 +3,12 @@ #[cfg(feature = "self-update")] pub(crate) fn log_needs_update(level: log::Level, extra: &str) { - use crate::output::SupportsColorsV2; - use owo_colors::OwoColorize; + use owo_colors::{OwoColorize, Stream}; log::log!( level, "update nextest with {}{}", - "cargo nextest self update" - .if_supports_color_2(supports_color::Stream::Stderr, |x| x.bold()), + "cargo nextest self update".if_supports_color(Stream::Stderr, |x| x.bold()), extra, ); } diff --git a/cargo-nextest/src/output.rs b/cargo-nextest/src/output.rs index c77d938c6c9..3dbbffcd7a9 100644 --- a/cargo-nextest/src/output.rs +++ b/cargo-nextest/src/output.rs @@ -7,9 +7,9 @@ use env_logger::fmt::Formatter; use log::{Level, LevelFilter, Record}; use miette::{GraphicalTheme, MietteHandlerOpts, ThemeStyles}; use nextest_runner::reporter::ReporterStderr; -use owo_colors::{style, OwoColorize, Style}; +use owo_colors::{OwoColorize, Stream, Style}; +use owo_colors_3::style; use std::{ - fmt, io::{BufWriter, Stderr, Stdout, Write}, marker::PhantomData, }; @@ -68,15 +68,12 @@ impl Color { match self { Color::Auto => { owo_colors::unset_override(); - overrides::unset_override(); } Color::Always => { owo_colors::set_override(true); - overrides::set_override(true); } Color::Never => { owo_colors::set_override(false); - overrides::set_override(false); } } @@ -144,27 +141,25 @@ fn format_fn(f: &mut Formatter, record: &Record<'_>) -> std::io::Result<()> { Level::Error => writeln!( f, "{}: {}", - "error".if_supports_color_2(supports_color::Stream::Stderr, |s| s - .style(Style::new().red().bold())), + "error".if_supports_color(Stream::Stderr, |s| s.style(Style::new().red().bold())), record.args() ), Level::Warn => writeln!( f, "{}: {}", - "warning".if_supports_color_2(supports_color::Stream::Stderr, |s| s - .style(Style::new().yellow().bold())), + "warning".if_supports_color(Stream::Stderr, |s| s.style(Style::new().yellow().bold())), record.args() ), Level::Info => writeln!( f, "{}: {}", - "info".if_supports_color_2(supports_color::Stream::Stderr, |s| s.bold()), + "info".if_supports_color(Stream::Stderr, |s| s.bold()), record.args() ), Level::Debug => writeln!( f, "{}: {}", - "debug".if_supports_color_2(supports_color::Stream::Stderr, |s| s.bold()), + "debug".if_supports_color(Stream::Stderr, |s| s.bold()), record.args() ), _other => Ok(()), @@ -283,118 +278,3 @@ impl<'a> Write for StderrWriter<'a> { } } } - -/// Override support. Used by SupportsColorsV2Display. -mod overrides { - use std::sync::atomic::{AtomicU8, Ordering}; - - pub(crate) fn set_override(enabled: bool) { - OVERRIDE.set_force(enabled) - } - - pub(crate) fn unset_override() { - OVERRIDE.unset() - } - - pub(crate) static OVERRIDE: Override = Override::none(); - - pub(crate) struct Override(AtomicU8); - - const FORCE_MASK: u8 = 0b10; - const FORCE_ENABLE: u8 = 0b11; - const FORCE_DISABLE: u8 = 0b10; - const NO_FORCE: u8 = 0b00; - - impl Override { - const fn none() -> Self { - Self(AtomicU8::new(NO_FORCE)) - } - - fn inner(&self) -> u8 { - self.0.load(Ordering::SeqCst) - } - - pub(crate) fn is_force_enabled_or_disabled(&self) -> (bool, bool) { - let inner = self.inner(); - - (inner == FORCE_ENABLE, inner == FORCE_DISABLE) - } - - fn set_force(&self, enable: bool) { - self.0.store(FORCE_MASK | (enable as u8), Ordering::SeqCst) - } - - fn unset(&self) { - self.0.store(0, Ordering::SeqCst); - } - } -} - -/// An extension trait for applying supports-color v2 to owo-colors. -/// -/// supports-color v2 has some fixes that nextest needs. -pub(crate) trait SupportsColorsV2: OwoColorize { - fn if_supports_color_2<'a, Out, ApplyFn>( - &'a self, - stream: supports_color::Stream, - apply: ApplyFn, - ) -> SupportsColorsV2Display<'a, Self, Out, ApplyFn> - where - ApplyFn: Fn(&'a Self) -> Out, - { - SupportsColorsV2Display(self, apply, stream) - } -} - -impl SupportsColorsV2 for T {} - -/// A display wrapper which applies a transformation based on if the given stream supports -/// colored terminal output -pub struct SupportsColorsV2Display<'a, InVal, Out, ApplyFn>( - pub(crate) &'a InVal, - pub(crate) ApplyFn, - pub(crate) supports_color::Stream, -) -where - InVal: ?Sized, - ApplyFn: Fn(&'a InVal) -> Out; - -macro_rules! impl_fmt_for { - ($($trait:path),* $(,)?) => { - $( - impl<'a, In, Out, F> $trait for SupportsColorsV2Display<'a, In, Out, F> - where In: $trait, - Out: $trait, - F: Fn(&'a In) -> Out, - { - #[inline(always)] - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - // OVERRIDE is currently not supported - let (force_enabled, force_disabled) = overrides::OVERRIDE.is_force_enabled_or_disabled(); - if force_enabled || ( - supports_color::on_cached(self.2) - .map(|level| level.has_basic) - .unwrap_or(false) - && !force_disabled - ) { - ::fmt(&self.1(self.0), f) - } else { - ::fmt(self.0, f) - } - } - } - )* - }; -} - -impl_fmt_for! { - fmt::Display, - fmt::Debug, - fmt::UpperHex, - fmt::LowerHex, - fmt::Binary, - fmt::UpperExp, - fmt::LowerExp, - fmt::Octal, - fmt::Pointer, -} diff --git a/cargo-nextest/src/update.rs b/cargo-nextest/src/update.rs index 62644d5ecb0..a7236ea2e2d 100644 --- a/cargo-nextest/src/update.rs +++ b/cargo-nextest/src/update.rs @@ -1,17 +1,13 @@ // Copyright (c) The nextest Contributors // SPDX-License-Identifier: MIT OR Apache-2.0 -use crate::{ - output::{OutputContext, SupportsColorsV2}, - ExpectedError, Result, -}; +use crate::{output::OutputContext, ExpectedError, Result}; use camino::Utf8PathBuf; use nextest_metadata::NextestExitCode; use nextest_runner::update::{CheckStatus, MuktiBackend, UpdateVersion}; -use owo_colors::OwoColorize; +use owo_colors::{OwoColorize, Stream}; use semver::Version; use std::cmp::Ordering; -use supports_color::Stream; // Returns the smallest version with a `self setup` command. fn min_version_with_setup() -> Version { @@ -65,7 +61,7 @@ pub(crate) fn perform_update( CheckStatus::AlreadyOnRequested(version) => { log::info!( "cargo-nextest is already at the latest version: {}", - version.if_supports_color_2(Stream::Stderr, |s| s.bold()) + version.if_supports_color(Stream::Stderr, |s| s.bold()) ); Ok(0) } @@ -76,8 +72,8 @@ pub(crate) fn perform_update( log::info!( "not performing downgrade from {} to {}\n\ (pass in --force to force downgrade)", - current_version.if_supports_color_2(Stream::Stderr, |s| s.bold()), - requested.if_supports_color_2(Stream::Stderr, |s| s.bold()), + current_version.if_supports_color(Stream::Stderr, |s| s.bold()), + requested.if_supports_color(Stream::Stderr, |s| s.bold()), ); Ok(NextestExitCode::UPDATE_DOWNGRADE_NOT_PERFORMED) } @@ -89,9 +85,8 @@ pub(crate) fn perform_update( Ordering::Equal => "reinstall", Ordering::Less => "downgrade", }, - current_version.if_supports_color_2(Stream::Stderr, |s| s.bold()), - ctx.version - .if_supports_color_2(Stream::Stderr, |s| s.bold()) + current_version.if_supports_color(Stream::Stderr, |s| s.bold()), + ctx.version.if_supports_color(Stream::Stderr, |s| s.bold()) ); if check { // check + non-empty ops implies a non-zero exit status. @@ -120,8 +115,7 @@ pub(crate) fn perform_update( .map_err(|err| ExpectedError::UpdateError { err })?; log::info!( "cargo-nextest updated to {}", - ctx.version - .if_supports_color_2(Stream::Stderr, |s| s.bold()) + ctx.version.if_supports_color(Stream::Stderr, |s| s.bold()) ); Ok(0) } else { diff --git a/nextest-runner/Cargo.toml b/nextest-runner/Cargo.toml index cec276b12f8..64f3bbf927d 100644 --- a/nextest-runner/Cargo.toml +++ b/nextest-runner/Cargo.toml @@ -43,7 +43,7 @@ log = "0.4.20" rand = "0.8.5" miette = "5.10.0" once_cell = "1.19.0" -owo-colors = "3.5.0" +owo-colors = "4.0.0" pin-project-lite = "0.2.13" regex = "1.10.2" semver = "1.0.20" diff --git a/quick-junit/Cargo.toml b/quick-junit/Cargo.toml index 5f5b5e3eb73..04c866f64a2 100644 --- a/quick-junit/Cargo.toml +++ b/quick-junit/Cargo.toml @@ -22,4 +22,4 @@ nextest-workspace-hack.workspace = true [dev-dependencies] goldenfile = "1.6.0" -owo-colors = "3.5.0" +owo-colors = "4.0.0" diff --git a/workspace-hack/Cargo.toml b/workspace-hack/Cargo.toml index 3774dd5b372..0dd424a88e5 100644 --- a/workspace-hack/Cargo.toml +++ b/workspace-hack/Cargo.toml @@ -28,7 +28,7 @@ log = { version = "0.4.20", default-features = false, features = ["std"] } memchr = { version = "2.6.4", features = ["use_std"] } miette = { version = "5.10.0", features = ["fancy"] } num-traits = { version = "0.2.17", default-features = false, features = ["libm", "std"] } -owo-colors = { version = "3.5.0", default-features = false, features = ["supports-colors"] } +owo-colors = { version = "4.0.0", default-features = false, features = ["supports-colors"] } rand = { version = "0.8.5" } serde = { version = "1.0.193", features = ["alloc", "derive"] } serde_json = { version = "1.0.108", features = ["preserve_order", "unbounded_depth"] } @@ -74,7 +74,7 @@ futures-core = { version = "0.3.29" } futures-sink = { version = "0.3.29" } once_cell = { version = "1.19.0", features = ["unstable"] } tokio = { version = "1.35.1", default-features = false, features = ["net"] } -winapi = { version = "0.3.9", default-features = false, features = ["basetsd", "consoleapi", "handleapi", "jobapi2", "minwinbase", "minwindef", "processenv", "processthreadsapi", "psapi", "std", "synchapi", "winbase", "wincon", "winerror", "winnt", "ws2ipdef", "ws2tcpip"] } +winapi = { version = "0.3.9", default-features = false, features = ["basetsd", "handleapi", "jobapi2", "processenv", "processthreadsapi", "psapi", "std", "synchapi", "winbase", "wincon", "winerror", "winnt", "ws2ipdef", "ws2tcpip"] } windows-sys-b21d60becc0929df = { package = "windows-sys", version = "0.52.0", features = ["Win32_Foundation", "Win32_Storage_FileSystem", "Win32_System_Com", "Win32_System_Console", "Win32_UI_Shell"] } windows-sys-c8eced492e86ede7 = { package = "windows-sys", version = "0.48.0", features = ["Win32_Foundation", "Win32_Networking_WinSock", "Win32_Security", "Win32_Storage_FileSystem", "Win32_System_Console", "Win32_System_Diagnostics_Debug", "Win32_System_Environment", "Win32_System_IO", "Win32_System_LibraryLoader", "Win32_System_Memory", "Win32_System_Pipes", "Win32_System_Registry", "Win32_System_SystemServices", "Win32_System_Threading", "Win32_System_Time", "Win32_System_WindowsProgramming", "Win32_UI_Shell"] }