11use std:: process:: Command ;
22
3+ use assert_cmd:: cargo_bin;
34use assert_cmd:: prelude:: * ;
45use predicates:: prelude:: * ;
56
67#[ test]
78fn stdout_string ( ) {
89 let expected = "hello\n " . to_owned ( ) ;
9- Command :: cargo_bin ( "bin_fixture" )
10- . unwrap ( )
10+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
1111 . env ( "stdout" , "hello" )
1212 . env ( "stderr" , "world" )
1313 . assert ( )
@@ -16,101 +16,88 @@ fn stdout_string() {
1616
1717#[ test]
1818fn trait_example ( ) {
19- let mut cmd = Command :: cargo_bin ( "bin_fixture" ) . unwrap ( ) ;
19+ let mut cmd = Command :: new ( cargo_bin ! ( "bin_fixture" ) ) ;
2020 cmd. assert ( ) . success ( ) ;
2121}
2222
2323#[ test]
2424fn trait_assert_example ( ) {
25- let mut cmd = Command :: cargo_bin ( "bin_fixture" ) . unwrap ( ) ;
25+ let mut cmd = Command :: new ( cargo_bin ! ( "bin_fixture" ) ) ;
2626 cmd. assert ( ) . success ( ) ;
2727}
2828
2929#[ test]
3030fn struct_example ( ) {
31- let mut cmd = Command :: cargo_bin ( "bin_fixture" ) . unwrap ( ) ;
31+ let mut cmd = Command :: new ( cargo_bin ! ( "bin_fixture" ) ) ;
3232 cmd. assert ( ) . success ( ) ;
3333}
3434
3535#[ test]
3636fn append_context_example ( ) {
37- Command :: cargo_bin ( "bin_fixture" )
38- . unwrap ( )
37+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
3938 . assert ( )
4039 . append_context ( "main" , "no args" )
4140 . success ( ) ;
4241}
4342
4443#[ test]
4544fn success_example ( ) {
46- Command :: cargo_bin ( "bin_fixture" )
47- . unwrap ( )
48- . assert ( )
49- . success ( ) ;
45+ Command :: new ( cargo_bin ! ( "bin_fixture" ) ) . assert ( ) . success ( ) ;
5046}
5147
5248#[ test]
5349fn failure_example ( ) {
54- Command :: cargo_bin ( "bin_fixture" )
55- . unwrap ( )
50+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
5651 . env ( "exit" , "1" )
5752 . assert ( )
5853 . failure ( ) ;
5954}
6055
6156#[ test]
6257fn code_example ( ) {
63- Command :: cargo_bin ( "bin_fixture" )
64- . unwrap ( )
58+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
6559 . env ( "exit" , "42" )
6660 . assert ( )
6761 . code ( predicate:: eq ( 42 ) ) ;
6862
69- Command :: cargo_bin ( "bin_fixture" )
70- . unwrap ( )
63+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
7164 . env ( "exit" , "42" )
7265 . assert ( )
7366 . code ( 42 ) ;
7467
75- Command :: cargo_bin ( "bin_fixture" )
76- . unwrap ( )
68+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
7769 . env ( "exit" , "42" )
7870 . assert ( )
7971 . code ( & [ 2 , 42 ] as & [ i32 ] ) ;
8072}
8173
8274#[ test]
8375fn stdout_example ( ) {
84- Command :: cargo_bin ( "bin_fixture" )
85- . unwrap ( )
76+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
8677 . env ( "stdout" , "hello" )
8778 . env ( "stderr" , "world" )
8879 . assert ( )
8980 . stdout ( predicate:: eq ( b"hello\n " as & [ u8 ] ) ) ;
9081
91- Command :: cargo_bin ( "bin_fixture" )
92- . unwrap ( )
82+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
9383 . env ( "stdout" , "hello" )
9484 . env ( "stderr" , "world" )
9585 . assert ( )
9686 . stdout ( predicate:: str:: diff ( "hello\n " ) ) ;
9787
98- Command :: cargo_bin ( "bin_fixture" )
99- . unwrap ( )
88+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
10089 . env ( "stdout" , "hello" )
10190 . env ( "stderr" , "world" )
10291 . assert ( )
10392 . stdout ( b"hello\n " as & [ u8 ] ) ;
10493
105- Command :: cargo_bin ( "bin_fixture" )
106- . unwrap ( )
94+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
10795 . env ( "stdout" , "hello" )
10896 . env ( "stderr" , "world" )
10997 . assert ( )
11098 . stdout ( vec ! [ b'h' , b'e' , b'l' , b'l' , b'o' , b'\n' ] ) ;
11199
112- Command :: cargo_bin ( "bin_fixture" )
113- . unwrap ( )
100+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
114101 . env ( "stdout" , "hello" )
115102 . env ( "stderr" , "world" )
116103 . assert ( )
@@ -119,36 +106,31 @@ fn stdout_example() {
119106
120107#[ test]
121108fn stderr_example ( ) {
122- Command :: cargo_bin ( "bin_fixture" )
123- . unwrap ( )
109+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
124110 . env ( "stdout" , "hello" )
125111 . env ( "stderr" , "world" )
126112 . assert ( )
127113 . stderr ( predicate:: eq ( b"world\n " as & [ u8 ] ) ) ;
128114
129- Command :: cargo_bin ( "bin_fixture" )
130- . unwrap ( )
115+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
131116 . env ( "stdout" , "hello" )
132117 . env ( "stderr" , "world" )
133118 . assert ( )
134119 . stderr ( predicate:: str:: diff ( "world\n " ) ) ;
135120
136- Command :: cargo_bin ( "bin_fixture" )
137- . unwrap ( )
121+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
138122 . env ( "stdout" , "hello" )
139123 . env ( "stderr" , "world" )
140124 . assert ( )
141125 . stderr ( b"world\n " as & [ u8 ] ) ;
142126
143- Command :: cargo_bin ( "bin_fixture" )
144- . unwrap ( )
127+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
145128 . env ( "stdout" , "hello" )
146129 . env ( "stderr" , "world" )
147130 . assert ( )
148131 . stderr ( vec ! [ b'w' , b'o' , b'r' , b'l' , b'd' , b'\n' ] ) ;
149132
150- Command :: cargo_bin ( "bin_fixture" )
151- . unwrap ( )
133+ Command :: new ( cargo_bin ! ( "bin_fixture" ) )
152134 . env ( "stdout" , "hello" )
153135 . env ( "stderr" , "world" )
154136 . assert ( )
0 commit comments