Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
term: Fix flaky color test
Alexis Sellier committed 3 years ago
commit 1f711b394a48dd74849ebdaa00f8e15fc87395b6
parent 4142d85178d6b79b4d5255e3560a85e937ca8f82
2 files changed +6 -4
modified radicle-term/src/ansi/paint.rs
@@ -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.
modified radicle-term/src/ansi/tests.rs
@@ -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(),