11use std:: process:: Command ;
22
3- use assert_cmd:: cargo_bin;
43use assert_cmd:: prelude:: * ;
54use predicates:: prelude:: * ;
65
76#[ test]
87fn stdout_string ( ) {
98 let expected = "hello\n " . to_owned ( ) ;
10- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
9+ Command :: cargo_bin ( "bin_fixture" )
10+ . unwrap ( )
1111 . env ( "stdout" , "hello" )
1212 . env ( "stderr" , "world" )
1313 . assert ( )
@@ -16,88 +16,101 @@ fn stdout_string() {
1616
1717#[ test]
1818fn trait_example ( ) {
19- let mut cmd = Command :: new ( cargo_bin ! ( "bin_fixture" ) ) ;
19+ let mut cmd = Command :: cargo_bin ( "bin_fixture" ) . unwrap ( ) ;
2020 cmd. assert ( ) . success ( ) ;
2121}
2222
2323#[ test]
2424fn trait_assert_example ( ) {
25- let mut cmd = Command :: new ( cargo_bin ! ( "bin_fixture" ) ) ;
25+ let mut cmd = Command :: cargo_bin ( "bin_fixture" ) . unwrap ( ) ;
2626 cmd. assert ( ) . success ( ) ;
2727}
2828
2929#[ test]
3030fn struct_example ( ) {
31- let mut cmd = Command :: new ( cargo_bin ! ( "bin_fixture" ) ) ;
31+ let mut cmd = Command :: cargo_bin ( "bin_fixture" ) . unwrap ( ) ;
3232 cmd. assert ( ) . success ( ) ;
3333}
3434
3535#[ test]
3636fn append_context_example ( ) {
37- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
37+ Command :: cargo_bin ( "bin_fixture" )
38+ . unwrap ( )
3839 . assert ( )
3940 . append_context ( "main" , "no args" )
4041 . success ( ) ;
4142}
4243
4344#[ test]
4445fn success_example ( ) {
45- Command :: new ( cargo_bin ! ( "bin_fixture" ) ) . assert ( ) . success ( ) ;
46+ Command :: cargo_bin ( "bin_fixture" )
47+ . unwrap ( )
48+ . assert ( )
49+ . success ( ) ;
4650}
4751
4852#[ test]
4953fn failure_example ( ) {
50- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
54+ Command :: cargo_bin ( "bin_fixture" )
55+ . unwrap ( )
5156 . env ( "exit" , "1" )
5257 . assert ( )
5358 . failure ( ) ;
5459}
5560
5661#[ test]
5762fn code_example ( ) {
58- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
63+ Command :: cargo_bin ( "bin_fixture" )
64+ . unwrap ( )
5965 . env ( "exit" , "42" )
6066 . assert ( )
6167 . code ( predicate:: eq ( 42 ) ) ;
6268
63- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
69+ Command :: cargo_bin ( "bin_fixture" )
70+ . unwrap ( )
6471 . env ( "exit" , "42" )
6572 . assert ( )
6673 . code ( 42 ) ;
6774
68- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
75+ Command :: cargo_bin ( "bin_fixture" )
76+ . unwrap ( )
6977 . env ( "exit" , "42" )
7078 . assert ( )
7179 . code ( & [ 2 , 42 ] as & [ i32 ] ) ;
7280}
7381
7482#[ test]
7583fn stdout_example ( ) {
76- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
84+ Command :: cargo_bin ( "bin_fixture" )
85+ . unwrap ( )
7786 . env ( "stdout" , "hello" )
7887 . env ( "stderr" , "world" )
7988 . assert ( )
8089 . stdout ( predicate:: eq ( b"hello\n " as & [ u8 ] ) ) ;
8190
82- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
91+ Command :: cargo_bin ( "bin_fixture" )
92+ . unwrap ( )
8393 . env ( "stdout" , "hello" )
8494 . env ( "stderr" , "world" )
8595 . assert ( )
8696 . stdout ( predicate:: str:: diff ( "hello\n " ) ) ;
8797
88- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
98+ Command :: cargo_bin ( "bin_fixture" )
99+ . unwrap ( )
89100 . env ( "stdout" , "hello" )
90101 . env ( "stderr" , "world" )
91102 . assert ( )
92103 . stdout ( b"hello\n " as & [ u8 ] ) ;
93104
94- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
105+ Command :: cargo_bin ( "bin_fixture" )
106+ . unwrap ( )
95107 . env ( "stdout" , "hello" )
96108 . env ( "stderr" , "world" )
97109 . assert ( )
98110 . stdout ( vec ! [ b'h' , b'e' , b'l' , b'l' , b'o' , b'\n' ] ) ;
99111
100- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
112+ Command :: cargo_bin ( "bin_fixture" )
113+ . unwrap ( )
101114 . env ( "stdout" , "hello" )
102115 . env ( "stderr" , "world" )
103116 . assert ( )
@@ -106,31 +119,36 @@ fn stdout_example() {
106119
107120#[ test]
108121fn stderr_example ( ) {
109- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
122+ Command :: cargo_bin ( "bin_fixture" )
123+ . unwrap ( )
110124 . env ( "stdout" , "hello" )
111125 . env ( "stderr" , "world" )
112126 . assert ( )
113127 . stderr ( predicate:: eq ( b"world\n " as & [ u8 ] ) ) ;
114128
115- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
129+ Command :: cargo_bin ( "bin_fixture" )
130+ . unwrap ( )
116131 . env ( "stdout" , "hello" )
117132 . env ( "stderr" , "world" )
118133 . assert ( )
119134 . stderr ( predicate:: str:: diff ( "world\n " ) ) ;
120135
121- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
136+ Command :: cargo_bin ( "bin_fixture" )
137+ . unwrap ( )
122138 . env ( "stdout" , "hello" )
123139 . env ( "stderr" , "world" )
124140 . assert ( )
125141 . stderr ( b"world\n " as & [ u8 ] ) ;
126142
127- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
143+ Command :: cargo_bin ( "bin_fixture" )
144+ . unwrap ( )
128145 . env ( "stdout" , "hello" )
129146 . env ( "stderr" , "world" )
130147 . assert ( )
131148 . stderr ( vec ! [ b'w' , b'o' , b'r' , b'l' , b'd' , b'\n' ] ) ;
132149
133- Command :: new ( cargo_bin ! ( "bin_fixture" ) )
150+ Command :: cargo_bin ( "bin_fixture" )
151+ . unwrap ( )
134152 . env ( "stdout" , "hello" )
135153 . env ( "stderr" , "world" )
136154 . assert ( )
0 commit comments