@@ -8,7 +8,10 @@ use std::io::IsTerminal;
88#[ test]
99fn test_more_no_arg ( ) {
1010 if std:: io:: stdout ( ) . is_terminal ( ) {
11- new_ucmd ! ( ) . fails ( ) . stderr_contains ( "more: bad usage" ) ;
11+ new_ucmd ! ( )
12+ . terminal_simulation ( true )
13+ . fails ( )
14+ . stderr_contains ( "more: bad usage" ) ;
1215 }
1316}
1417
@@ -21,44 +24,136 @@ fn test_valid_arg() {
2124 let file = "test_file" ;
2225 at. touch ( file) ;
2326
24- scene. ucmd ( ) . arg ( file) . arg ( "-c" ) . succeeds ( ) ;
25- scene. ucmd ( ) . arg ( file) . arg ( "--print-over" ) . succeeds ( ) ;
27+ scene
28+ . ucmd ( )
29+ . terminal_simulation ( true )
30+ . arg ( file)
31+ . arg ( "-c" )
32+ . succeeds ( ) ;
33+ scene
34+ . ucmd ( )
35+ . terminal_simulation ( true )
36+ . arg ( file)
37+ . arg ( "--print-over" )
38+ . succeeds ( ) ;
2639
27- scene. ucmd ( ) . arg ( file) . arg ( "-p" ) . succeeds ( ) ;
28- scene. ucmd ( ) . arg ( file) . arg ( "--clean-print" ) . succeeds ( ) ;
40+ scene
41+ . ucmd ( )
42+ . terminal_simulation ( true )
43+ . arg ( file)
44+ . arg ( "-p" )
45+ . succeeds ( ) ;
46+ scene
47+ . ucmd ( )
48+ . terminal_simulation ( true )
49+ . arg ( file)
50+ . arg ( "--clean-print" )
51+ . succeeds ( ) ;
2952
30- scene. ucmd ( ) . arg ( file) . arg ( "-s" ) . succeeds ( ) ;
31- scene. ucmd ( ) . arg ( file) . arg ( "--squeeze" ) . succeeds ( ) ;
53+ scene
54+ . ucmd ( )
55+ . terminal_simulation ( true )
56+ . arg ( file)
57+ . arg ( "-s" )
58+ . succeeds ( ) ;
59+ scene
60+ . ucmd ( )
61+ . terminal_simulation ( true )
62+ . arg ( file)
63+ . arg ( "--squeeze" )
64+ . succeeds ( ) ;
3265
33- scene. ucmd ( ) . arg ( file) . arg ( "-u" ) . succeeds ( ) ;
34- scene. ucmd ( ) . arg ( file) . arg ( "--plain" ) . succeeds ( ) ;
66+ scene
67+ . ucmd ( )
68+ . terminal_simulation ( true )
69+ . arg ( file)
70+ . arg ( "-u" )
71+ . succeeds ( ) ;
72+ scene
73+ . ucmd ( )
74+ . terminal_simulation ( true )
75+ . arg ( file)
76+ . arg ( "--plain" )
77+ . succeeds ( ) ;
3578
36- scene. ucmd ( ) . arg ( file) . arg ( "-n" ) . arg ( "10" ) . succeeds ( ) ;
37- scene. ucmd ( ) . arg ( file) . arg ( "--lines" ) . arg ( "0" ) . succeeds ( ) ;
38- scene. ucmd ( ) . arg ( file) . arg ( "--number" ) . arg ( "0" ) . succeeds ( ) ;
79+ scene
80+ . ucmd ( )
81+ . terminal_simulation ( true )
82+ . arg ( file)
83+ . arg ( "-n" )
84+ . arg ( "10" )
85+ . succeeds ( ) ;
86+ scene
87+ . ucmd ( )
88+ . terminal_simulation ( true )
89+ . arg ( file)
90+ . arg ( "--lines" )
91+ . arg ( "0" )
92+ . succeeds ( ) ;
93+ scene
94+ . ucmd ( )
95+ . terminal_simulation ( true )
96+ . arg ( file)
97+ . arg ( "--number" )
98+ . arg ( "0" )
99+ . succeeds ( ) ;
39100
40- scene. ucmd ( ) . arg ( file) . arg ( "-F" ) . arg ( "10" ) . succeeds ( ) ;
41101 scene
42102 . ucmd ( )
103+ . terminal_simulation ( true )
104+ . arg ( file)
105+ . arg ( "-F" )
106+ . arg ( "10" )
107+ . succeeds ( ) ;
108+ scene
109+ . ucmd ( )
110+ . terminal_simulation ( true )
43111 . arg ( file)
44112 . arg ( "--from-line" )
45113 . arg ( "0" )
46114 . succeeds ( ) ;
47115
48- scene. ucmd ( ) . arg ( file) . arg ( "-P" ) . arg ( "something" ) . succeeds ( ) ;
49- scene. ucmd ( ) . arg ( file) . arg ( "--pattern" ) . arg ( "-1" ) . succeeds ( ) ;
116+ scene
117+ . ucmd ( )
118+ . terminal_simulation ( true )
119+ . arg ( file)
120+ . arg ( "-P" )
121+ . arg ( "something" )
122+ . succeeds ( ) ;
123+ scene
124+ . ucmd ( )
125+ . terminal_simulation ( true )
126+ . arg ( file)
127+ . arg ( "--pattern" )
128+ . arg ( "-1" )
129+ . succeeds ( ) ;
50130 }
51131}
52132
53133#[ test]
54134fn test_invalid_arg ( ) {
55135 if std:: io:: stdout ( ) . is_terminal ( ) {
56- new_ucmd ! ( ) . arg ( "--invalid" ) . fails ( ) ;
136+ new_ucmd ! ( )
137+ . terminal_simulation ( true )
138+ . arg ( "--invalid" )
139+ . fails ( ) ;
57140
58- new_ucmd ! ( ) . arg ( "--lines" ) . arg ( "-10" ) . fails ( ) ;
59- new_ucmd ! ( ) . arg ( "--number" ) . arg ( "-10" ) . fails ( ) ;
141+ new_ucmd ! ( )
142+ . terminal_simulation ( true )
143+ . arg ( "--lines" )
144+ . arg ( "-10" )
145+ . fails ( ) ;
146+ new_ucmd ! ( )
147+ . terminal_simulation ( true )
148+ . arg ( "--number" )
149+ . arg ( "-10" )
150+ . fails ( ) ;
60151
61- new_ucmd ! ( ) . arg ( "--from-line" ) . arg ( "-10" ) . fails ( ) ;
152+ new_ucmd ! ( )
153+ . terminal_simulation ( true )
154+ . arg ( "--from-line" )
155+ . arg ( "-10" )
156+ . fails ( ) ;
62157 }
63158}
64159
@@ -75,6 +170,7 @@ fn test_argument_from_file() {
75170 // output all lines
76171 scene
77172 . ucmd ( )
173+ . terminal_simulation ( true )
78174 . arg ( "-F" )
79175 . arg ( "0" )
80176 . arg ( file)
@@ -86,6 +182,7 @@ fn test_argument_from_file() {
86182 // output only the second line
87183 scene
88184 . ucmd ( )
185+ . terminal_simulation ( true )
89186 . arg ( "-F" )
90187 . arg ( "2" )
91188 . arg ( file)
@@ -103,6 +200,7 @@ fn test_more_dir_arg() {
103200 // but I am leaving this for later
104201 if std:: io:: stdout ( ) . is_terminal ( ) {
105202 new_ucmd ! ( )
203+ . terminal_simulation ( true )
106204 . arg ( "." )
107205 . succeeds ( )
108206 . stderr_contains ( "'.' is a directory." ) ;
@@ -121,6 +219,7 @@ fn test_more_invalid_file_perms() {
121219 at. make_file ( "invalid-perms.txt" ) ;
122220 set_permissions ( at. plus ( "invalid-perms.txt" ) , permissions) . unwrap ( ) ;
123221 ucmd. arg ( "invalid-perms.txt" )
222+ . terminal_simulation ( true )
124223 . succeeds ( )
125224 . stderr_contains ( "permission denied" ) ;
126225 }
@@ -132,10 +231,12 @@ fn test_more_error_on_single_arg() {
132231 let ts = TestScenario :: new ( "more" ) ;
133232 ts. fixtures . mkdir_all ( "folder" ) ;
134233 ts. ucmd ( )
234+ . terminal_simulation ( true )
135235 . arg ( "folder" )
136236 . succeeds ( )
137237 . stderr_contains ( "is a directory" ) ;
138238 ts. ucmd ( )
239+ . terminal_simulation ( true )
139240 . arg ( "file1" )
140241 . succeeds ( )
141242 . stderr_contains ( "No such file or directory" ) ;
@@ -149,6 +250,7 @@ fn test_more_error_on_multiple_files() {
149250 ts. fixtures . mkdir_all ( "folder" ) ;
150251 ts. fixtures . make_file ( "file1" ) ;
151252 ts. ucmd ( )
253+ . terminal_simulation ( true )
152254 . arg ( "folder" )
153255 . arg ( "file2" )
154256 . arg ( "file1" )
@@ -178,6 +280,7 @@ fn test_more_pattern_found() {
178280 // output only the second line "line2"
179281 scene
180282 . ucmd ( )
283+ . terminal_simulation ( true )
181284 . arg ( "-P" )
182285 . arg ( "line2" )
183286 . arg ( file)
@@ -201,6 +304,7 @@ fn test_more_pattern_not_found() {
201304
202305 scene
203306 . ucmd ( )
307+ . terminal_simulation ( true )
204308 . arg ( "-P" )
205309 . arg ( "something" )
206310 . arg ( file)
0 commit comments