File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
test-framework/sudo-compliance-tests/src/sudo Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -81,11 +81,11 @@ fn sudo_process() -> Result<(), Error> {
8181 match SudoAction :: from_env ( ) {
8282 Ok ( action) => match action {
8383 SudoAction :: Help ( _) => {
84- eprintln_ignore_io_error ! ( "{}" , long_help( ) ) ;
84+ println_ignore_io_error ! ( "{}" , long_help( ) ) ;
8585 std:: process:: exit ( 0 ) ;
8686 }
8787 SudoAction :: Version ( _) => {
88- eprintln_ignore_io_error ! ( "sudo-rs {VERSION}" ) ;
88+ println_ignore_io_error ! ( "sudo-rs {VERSION}" ) ;
8989 std:: process:: exit ( 0 ) ;
9090 }
9191 SudoAction :: RemoveTimestamp ( _) => {
Original file line number Diff line number Diff line change @@ -16,3 +16,22 @@ fn does_not_panic_on_io_errors() -> Result<()> {
1616
1717 Ok ( ( ) )
1818}
19+
20+ #[ test]
21+ fn prints_on_stdout ( ) -> Result < ( ) > {
22+ let env = Env ( "" ) . build ( ) ;
23+
24+ let output = Command :: new ( "sudo" ) . args ( [ "--version" ] ) . output ( & env) ;
25+
26+ let output = output. stdout ( ) ;
27+ assert_starts_with ! (
28+ output,
29+ if sudo_test:: is_original_sudo( ) {
30+ "sudo - execute a command as another user"
31+ } else {
32+ "sudo - run commands as another user"
33+ }
34+ ) ;
35+
36+ Ok ( ( ) )
37+ }
Original file line number Diff line number Diff line change @@ -19,3 +19,22 @@ fn does_not_panic_on_io_errors() -> Result<()> {
1919
2020 Ok ( ( ) )
2121}
22+
23+ #[ test]
24+ fn prints_on_stdout ( ) -> Result < ( ) > {
25+ let env = Env ( "" ) . build ( ) ;
26+
27+ let output = Command :: new ( "sudo" ) . args ( [ "--version" ] ) . output ( & env) ;
28+
29+ let output = output. stdout ( ) ;
30+ assert_starts_with ! (
31+ output,
32+ if sudo_test:: is_original_sudo( ) {
33+ "Sudo version"
34+ } else {
35+ "sudo-rs"
36+ }
37+ ) ;
38+
39+ Ok ( ( ) )
40+ }
You can’t perform that action at this time.
0 commit comments