term: Fix flaky color test

This commit is contained in:
Alexis Sellier 2023-05-13 21:39:11 +02:00
parent 4142d85178
commit 1f711b394a
No known key found for this signature in database
2 changed files with 6 additions and 4 deletions

View File

@ -282,8 +282,9 @@ impl Paint<()> {
}
/// Force paint styling.
pub fn force() {
FORCED.store(true, sync::atomic::Ordering::SeqCst);
/// Useful when you want to output colors to a non-TTY.
pub fn force(force: bool) {
FORCED.store(force, sync::atomic::Ordering::SeqCst);
}
/// Disable paint styling.

View File

@ -10,7 +10,7 @@ static SERIAL: Mutex<()> = Mutex::new(());
fn colors_enabled() {
let _guard = SERIAL.lock();
Paint::force();
Paint::force(true);
assert_eq!(
Paint::new("text/plain").to_string(),
@ -144,6 +144,7 @@ fn colors_enabled() {
fn colors_disabled() {
let _guard = SERIAL.lock();
Paint::force(false);
Paint::disable();
assert_eq!(
@ -246,7 +247,7 @@ fn wrapping() {
let inner = || format!("{} b {}", Paint::red("a"), Paint::green("c"));
let inner2 = || format!("0 {} 1", Paint::magenta(&inner()).wrap());
Paint::force();
Paint::force(true);
assert_eq!(
Paint::new("text/plain").wrap().to_string(),