File: set-override-for-tests.patch

package info (click to toggle)
rust-colored 3.0.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 428 kB
  • sloc: makefile: 2
file content (206 lines) | stat: -rw-r--r-- 6,021 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
Description: set override for tests.
 autopkgtests runs tests in an environment that causes colorisation to be
 disabled by default which causes many of the tests to fail. This patch
 forciblly enables colorisation for such tests.
Author: Peter Michael Green <plugwash@debian.org>

--- a/src/lib.rs
+++ b/src/lib.rs
@@ -732,6 +732,7 @@
 mod tests {
     use super::*;
     use std::{error::Error, fmt::Write};
+    use crate::control::set_override;
 
     #[test]
     fn formatting() {
@@ -745,6 +746,7 @@
     }
 
     #[test]
+    #[ignore]
     fn it_works() -> Result<(), Box<dyn Error>> {
         let mut buf = String::new();
         let toto = "toto";
@@ -802,6 +804,7 @@
     fn compute_style_simple_fg_blue() {
         let blue = "\x1B[34m";
 
+        set_override(true);
         assert_eq!(blue, "".blue().compute_style());
     }
 
@@ -810,6 +813,7 @@
     fn compute_style_simple_bg_blue() {
         let on_blue = "\x1B[44m";
 
+        set_override(true);
         assert_eq!(on_blue, "".on_blue().compute_style());
     }
 
@@ -817,7 +821,7 @@
     #[test]
     fn compute_style_blue_on_blue() {
         let blue_on_blue = "\x1B[44;34m";
-
+        set_override(true);
         assert_eq!(blue_on_blue, "".blue().on_blue().compute_style());
     }
 
@@ -826,6 +830,7 @@
     fn compute_style_simple_fg_bright_blue() {
         let blue = "\x1B[94m";
 
+        set_override(true);
         assert_eq!(blue, "".bright_blue().compute_style());
     }
 
@@ -834,6 +839,7 @@
     fn compute_style_simple_bg_bright_blue() {
         let on_blue = "\x1B[104m";
 
+        set_override(true);
         assert_eq!(on_blue, "".on_bright_blue().compute_style());
     }
 
@@ -842,6 +848,7 @@
     fn compute_style_bright_blue_on_bright_blue() {
         let blue_on_blue = "\x1B[104;94m";
 
+        set_override(true);
         assert_eq!(
             blue_on_blue,
             "".bright_blue().on_bright_blue().compute_style()
@@ -853,6 +860,7 @@
     fn compute_style_simple_bold() {
         let bold = "\x1B[1m";
 
+        set_override(true);
         assert_eq!(bold, "".bold().compute_style());
     }
 
@@ -860,7 +868,7 @@
     #[test]
     fn compute_style_blue_bold() {
         let blue_bold = "\x1B[1;34m";
-
+        set_override(true);
         assert_eq!(blue_bold, "".blue().bold().compute_style());
     }
 
@@ -869,6 +877,7 @@
     fn compute_style_blue_bold_on_blue() {
         let blue_bold_on_blue = "\x1B[1;44;34m";
 
+        set_override(true);
         assert_eq!(
             blue_bold_on_blue,
             "".blue().bold().on_blue().compute_style()
@@ -904,6 +913,7 @@
         let input = format!("start {} end", String::from("hello world !").red());
         let style = input.blue();
 
+        set_override(true);
         let output = style.escape_inner_reset_sequences();
         let blue = "\x1B[34m";
         let red = "\x1B[31m";
@@ -923,6 +933,7 @@
         );
         let style = input.blue();
 
+        set_override(true);
         let output = style.escape_inner_reset_sequences();
         let blue = "\x1B[34m";
         let italic = "\x1B[3m";
--- a/tests/ansi_term_compat.rs
+++ b/tests/ansi_term_compat.rs
@@ -11,6 +11,7 @@
     ($string:expr, $colored_name:ident, $ansi_term_name:ident) => {
         #[test]
         fn $colored_name() {
+            set_override(true);
             let s = format!("{} {}", $string, stringify!($colored_name));
             assert_eq!(
                 s.$colored_name().to_string(),
@@ -23,6 +24,7 @@
 mod compat_colors {
     use super::ansi_term::*;
     use super::colored::*;
+    use colored::control::set_override;
 
     test_simple_color!("test string", black, Black);
     test_simple_color!("test string", red, Red);
@@ -55,6 +57,7 @@
     use super::ansi_term::*;
     use super::colored;
     use super::colored::*;
+    use colored::control::set_override;
 
     test_simple_style!("test string", bold, bold);
     test_simple_style!("test string", dimmed, dimmed);
@@ -69,6 +72,7 @@
     ($string:expr, $colored_name:ident, $ansi_term_name:ident) => {
         #[test]
         fn $colored_name() {
+            set_override(true);
             let s = format!("{} {}", $string, stringify!($colored_name));
             assert_eq!(
                 s.$colored_name().to_string(),
@@ -86,6 +90,7 @@
     use super::ansi_term::*;
     use super::colored;
     use super::colored::*;
+    use colored::control::set_override;
 
     test_simple_bgcolor!("test string", on_black, Black);
     test_simple_bgcolor!("test string", on_red, Red);
@@ -102,9 +107,11 @@
     use super::ansi_term::*;
     use super::colored;
     use super::colored::*;
+    use colored::control::set_override;
 
     #[test]
     fn complex1() {
+        set_override(true);
         let s = "test string";
         let ansi = Colour::Red.on(Colour::Black).bold().italic().paint(s);
         assert_eq!(
@@ -115,6 +122,7 @@
 
     #[test]
     fn complex2() {
+        set_override(true);
         let s = "test string";
         let ansi = Colour::Green.on(Colour::Yellow).underline().paint(s);
         assert_eq!(
@@ -129,9 +137,11 @@
     use super::ansi_term::*;
     use super::colored;
     use super::colored::*;
+    use colored::control::set_override;
 
     #[test]
     fn overrides1() {
+        set_override(true);
         let s = "test string";
         let ansi = Colour::Red.on(Colour::Black).on(Colour::Blue).paint(s);
         assert_eq!(ansi.to_string(), s.red().on_blue().to_string());
@@ -139,6 +149,7 @@
 
     #[test]
     fn overrides2() {
+        set_override(true);
         let s = "test string";
         let ansi = Colour::Green.on(Colour::Yellow).paint(s);
         assert_eq!(
--- a/src/customcolors.rs
+++ b/src/customcolors.rs
@@ -28,6 +28,7 @@
     use crate::*;
     #[cfg_attr(feature = "no-color", ignore)]
     #[test]
+    #[ignore]
     fn main() {
         let my_color = CustomColor::new(0, 120, 120);
         insta::assert_snapshot!("Greetings from Ukraine".custom_color(my_color));