File tree Expand file tree Collapse file tree 4 files changed +22
-15
lines changed
Expand file tree Collapse file tree 4 files changed +22
-15
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
2828 let error = match e. kind ( ) {
2929 clap:: error:: ErrorKind :: DisplayHelp => command. print_help ( ) ,
3030 clap:: error:: ErrorKind :: DisplayVersion => {
31- writeln ! ( std:: io:: stdout( ) , "{}" , command. render_version( ) )
31+ write ! ( std:: io:: stdout( ) , "{}" , command. render_version( ) )
3232 }
3333 _ => Ok ( ( ) ) ,
3434 } ;
Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
2222 let error = match e. kind ( ) {
2323 clap:: error:: ErrorKind :: DisplayHelp => command. print_help ( ) ,
2424 clap:: error:: ErrorKind :: DisplayVersion => {
25- writeln ! ( std:: io:: stdout( ) , "{}" , command. render_version( ) )
25+ write ! ( std:: io:: stdout( ) , "{}" , command. render_version( ) )
2626 }
2727 _ => Ok ( ( ) ) ,
2828 } ;
Original file line number Diff line number Diff line change 22//
33// For the full copyright and license information, please view the LICENSE
44// file that was distributed with this source code.
5+
56use crate :: common:: util:: TestScenario ;
7+ use regex:: Regex ;
8+
69#[ cfg( any( target_os = "linux" , target_os = "freebsd" , target_os = "netbsd" ) ) ]
710use std:: fs:: OpenOptions ;
811
912#[ test]
10- fn test_exit_code ( ) {
11- new_ucmd ! ( ) . fails ( ) ;
13+ fn test_no_args ( ) {
14+ new_ucmd ! ( ) . fails ( ) . no_output ( ) ;
1215}
1316
1417#[ test]
1518fn test_version ( ) {
16- new_ucmd ! ( )
17- . args ( & [ "--version" ] )
18- . fails ( )
19- . stdout_contains ( "false" ) ;
19+ let re = Regex :: new ( r"^false .*\d+\.\d+\.\d+\n$" ) . unwrap ( ) ;
20+
21+ new_ucmd ! ( ) . args ( & [ "--version" ] ) . fails ( ) . stdout_matches ( & re) ;
2022}
2123
2224#[ test]
@@ -30,7 +32,7 @@ fn test_help() {
3032#[ test]
3133fn test_short_options ( ) {
3234 for option in [ "-h" , "-V" ] {
33- new_ucmd ! ( ) . arg ( option) . fails ( ) . stdout_is ( "" ) ;
35+ new_ucmd ! ( ) . arg ( option) . fails ( ) . no_output ( ) ;
3436 }
3537}
3638
@@ -39,7 +41,7 @@ fn test_conflict() {
3941 new_ucmd ! ( )
4042 . args ( & [ "--help" , "--version" ] )
4143 . fails ( )
42- . stdout_is ( "" ) ;
44+ . no_output ( ) ;
4345}
4446
4547#[ test]
Original file line number Diff line number Diff line change 22//
33// For the full copyright and license information, please view the LICENSE
44// file that was distributed with this source code.
5+
56use crate :: common:: util:: TestScenario ;
7+ use regex:: Regex ;
8+
69#[ cfg( any( target_os = "linux" , target_os = "freebsd" , target_os = "netbsd" ) ) ]
710use std:: fs:: OpenOptions ;
811
912#[ test]
10- fn test_exit_code ( ) {
11- new_ucmd ! ( ) . succeeds ( ) ;
13+ fn test_no_args ( ) {
14+ new_ucmd ! ( ) . succeeds ( ) . no_output ( ) ;
1215}
1316
1417#[ test]
1518fn test_version ( ) {
19+ let re = Regex :: new ( r"^true .*\d+\.\d+\.\d+\n$" ) . unwrap ( ) ;
20+
1621 new_ucmd ! ( )
1722 . args ( & [ "--version" ] )
1823 . succeeds ( )
19- . stdout_contains ( "true" ) ;
24+ . stdout_matches ( & re ) ;
2025}
2126
2227#[ test]
@@ -30,7 +35,7 @@ fn test_help() {
3035#[ test]
3136fn test_short_options ( ) {
3237 for option in [ "-h" , "-V" ] {
33- new_ucmd ! ( ) . arg ( option) . succeeds ( ) . stdout_is ( "" ) ;
38+ new_ucmd ! ( ) . arg ( option) . succeeds ( ) . no_output ( ) ;
3439 }
3540}
3641
@@ -39,7 +44,7 @@ fn test_conflict() {
3944 new_ucmd ! ( )
4045 . args ( & [ "--help" , "--version" ] )
4146 . succeeds ( )
42- . stdout_is ( "" ) ;
47+ . no_output ( ) ;
4348}
4449
4550#[ test]
You can’t perform that action at this time.
0 commit comments