@@ -8,23 +8,30 @@ use escargot::CargoBuild;
8
8
use predicates:: prelude:: * ;
9
9
10
10
#[ cfg( test) ]
11
- fn build_crate ( name : & str ) -> Command {
11
+ fn build_crate (
12
+ name : & str ,
13
+ modify_command_callback : impl FnOnce ( & mut std:: process:: Command ) ,
14
+ ) -> Command {
12
15
let multivers_manifest = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) ) . join ( "Cargo.toml" ) ;
13
16
let test_manifest = Path :: new ( env ! ( "CARGO_MANIFEST_DIR" ) )
14
17
. join ( "tests" )
15
18
. join ( name)
16
19
. join ( "Cargo.toml" ) ;
17
20
18
- let assert = CargoBuild :: new ( )
21
+ let mut command = CargoBuild :: new ( )
19
22
. manifest_path ( multivers_manifest)
20
23
. run ( )
21
24
. unwrap ( )
22
- . command ( )
25
+ . command ( ) ;
26
+
27
+ command
23
28
. arg ( "multivers" )
24
29
. arg ( "--manifest-path" )
25
- . arg ( test_manifest)
26
- . assert ( )
27
- . success ( ) ;
30
+ . arg ( test_manifest) ;
31
+
32
+ modify_command_callback ( & mut command) ;
33
+
34
+ let assert = command. assert ( ) . success ( ) ;
28
35
29
36
// Until we output json like cargo we need to parse the output manually
30
37
let output = assert. get_output ( ) ;
@@ -41,14 +48,17 @@ fn build_crate(name: &str) -> Command {
41
48
/// It should build without a runner since every build leads to the same binary.
42
49
#[ test]
43
50
fn crate_that_does_nothing ( ) {
44
- build_crate ( "test-nothing" ) . assert ( ) . success ( ) . stdout ( "" ) ;
51
+ build_crate ( "test-nothing" , |_| ( ) )
52
+ . assert ( )
53
+ . success ( )
54
+ . stdout ( "" ) ;
45
55
}
46
56
47
57
/// Checks that we can build a crate that prints its argv and that works as expected
48
58
#[ test]
49
59
fn crate_that_prints_argv ( ) {
50
60
let expected_args = [ "z" , "foo2" , "''" ] ;
51
- build_crate ( "test-argv" )
61
+ build_crate ( "test-argv" , |_| ( ) )
52
62
. args ( expected_args)
53
63
. assert ( )
54
64
. success ( )
@@ -64,7 +74,7 @@ fn crate_that_prints_argv() {
64
74
#[ test]
65
75
fn crate_within_workspace ( ) {
66
76
let expected_args = [ "workspace" , "abc" , "0987" ] ;
67
- build_crate ( "test-workspace" )
77
+ build_crate ( "test-workspace" , |_| ( ) )
68
78
. args ( expected_args)
69
79
. assert ( )
70
80
. success ( )
@@ -73,3 +83,21 @@ fn crate_within_workspace() {
73
83
expected_args. join( " " )
74
84
) ) ) ;
75
85
}
86
+
87
+ /// Checks that we can build a crate with `CARGO_UNSTABLE_BUILD_STD=std`.
88
+ ///
89
+ /// Regression test (see #7).
90
+ #[ test]
91
+ fn rebuild_std_env ( ) {
92
+ let expected_args = [ "z" , "foo2" , "''" ] ;
93
+ build_crate ( "test-argv" , |command| {
94
+ command. env ( "CARGO_UNSTABLE_BUILD_STD" , "std" ) ;
95
+ } )
96
+ . args ( expected_args)
97
+ . assert ( )
98
+ . success ( )
99
+ . stdout ( predicate:: str:: ends_with ( format ! (
100
+ "{}\n " ,
101
+ expected_args. join( " " )
102
+ ) ) ) ;
103
+ }
0 commit comments