commit: 508fc9371a4c4e8d2099cc6a6121d02789d0cdf0 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Sun Aug 31 16:13:10 2025 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Sun Aug 31 16:40:41 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=508fc937
sys-apps/lsd: Fix tests with NO_COLOR Closes: https://bugs.gentoo.org/949007 Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> sys-apps/lsd/files/lsd-1.1.3-no-color-test.patch | 56 ++++++++++++++++++++++++ sys-apps/lsd/lsd-1.1.3-r1.ebuild | 7 ++- 2 files changed, 62 insertions(+), 1 deletion(-) diff --git a/sys-apps/lsd/files/lsd-1.1.3-no-color-test.patch b/sys-apps/lsd/files/lsd-1.1.3-no-color-test.patch new file mode 100644 index 000000000000..b02749a64747 --- /dev/null +++ b/sys-apps/lsd/files/lsd-1.1.3-no-color-test.patch @@ -0,0 +1,56 @@ +From f03121a4dfa51c3282a2dd7ef59a3418b4d860b5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= <[email protected]> +Date: Sun, 31 Aug 2025 18:05:17 +0200 +Subject: [PATCH] Fix tests with `NO_COLOR=1` set +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Fix tests to force internal coloring independently of `NO_COLOR` +in the calling environment, to ensure that they pass. This is needed +when `NO_COLOR` is set globally in the environment, e.g. when collecting +plain text test logs. + +Technically, `crossterm::style::force_color_output()` leaks to other +tests. However, there should be no harm in setting it globally, +and the library does not seem to provide a trivial way to scope +the change. Just call it in both places where it is actually necessary, +to ensure that things work correctly also when only parts of the test +suite are run. + +Fixes #1136 + +Signed-off-by: Michał Górny <[email protected]> +--- + src/display.rs | 3 +++ + src/meta/symlink.rs | 3 +++ + 2 files changed, 6 insertions(+) + +diff --git a/src/display.rs b/src/display.rs +index 2c9c2f1..842ffb2 100644 +--- a/src/display.rs ++++ b/src/display.rs +@@ -584,6 +584,9 @@ mod tests { + + #[test] + fn test_display_get_visible_width_with_colors() { ++ // crossterm implicitly colors if NO_COLOR is set. ++ crossterm::style::force_color_output(true); ++ + for (s, l) in [ + ("Hello,world!", 22), + ("ASCII1234-_", 11), +diff --git a/src/meta/symlink.rs b/src/meta/symlink.rs +index 951ba24..786b492 100644 +--- a/src/meta/symlink.rs ++++ b/src/meta/symlink.rs +@@ -121,6 +121,9 @@ mod tests { + + #[test] + fn test_symlink_render_default_invalid_target_withcolor() { ++ // crossterm implicitly colors if NO_COLOR is set. ++ crossterm::style::force_color_output(true); ++ + let link = SymLink { + target: Some("/target".to_string()), + valid: false, diff --git a/sys-apps/lsd/lsd-1.1.3-r1.ebuild b/sys-apps/lsd/lsd-1.1.3-r1.ebuild index c152363a432b..907e56997951 100644 --- a/sys-apps/lsd/lsd-1.1.3-r1.ebuild +++ b/sys-apps/lsd/lsd-1.1.3-r1.ebuild @@ -1,4 +1,4 @@ -# Copyright 2017-2024 Gentoo Authors +# Copyright 2017-2025 Gentoo Authors # Distributed under the terms of the GNU General Public License v2 EAPI=8 @@ -212,6 +212,11 @@ DEPEND=" QA_FLAGS_IGNORED="usr/bin/lsd" src_prepare() { + local PATCHES=( + # https://github.com/lsd-rs/lsd/pull/1161 + "${FILESDIR}/${P}-no-color-test.patch" + ) + sed -i -e '/strip/s:true:false:' Cargo.toml || die default }
