3
3
4
4
use rustup:: for_host;
5
5
use rustup:: test:: {
6
- mock:: clitools:: { self , set_current_dist_date, with_update_server , CliTestContext , Scenario } ,
6
+ mock:: clitools:: { self , set_current_dist_date, CliTestContext , Scenario } ,
7
7
this_host_triple,
8
8
} ;
9
9
@@ -39,25 +39,27 @@ info: default toolchain set to 'nightly-{0}'
39
39
fn update_once_and_check_self_update ( ) {
40
40
let test_version = "2.0.0" ;
41
41
let mut cx = CliTestContext :: from ( Scenario :: SimpleV2 ) ;
42
- with_update_server ( & mut cx. config , test_version, & |config| {
43
- config. expect_ok ( & [ "rustup-init" , "-y" , "--no-modify-path" ] ) ;
44
- config. expect_ok ( & [ "rustup" , "set" , "auto-self-update" , "check-only" ] ) ;
45
- let current_version = env ! ( "CARGO_PKG_VERSION" ) ;
42
+ let _dist_guard = cx. with_update_server ( test_version) ;
43
+ cx. config
44
+ . expect_ok ( & [ "rustup-init" , "-y" , "--no-modify-path" ] ) ;
45
+ cx. config
46
+ . expect_ok ( & [ "rustup" , "set" , "auto-self-update" , "check-only" ] ) ;
47
+ let current_version = env ! ( "CARGO_PKG_VERSION" ) ;
46
48
47
- config. expect_ok_ex (
48
- & [ "rustup" , "update" , "nightly" ] ,
49
- & format ! (
50
- r"
49
+ cx . config . expect_ok_ex (
50
+ & [ "rustup" , "update" , "nightly" ] ,
51
+ & format ! (
52
+ r"
51
53
nightly-{} installed - 1.3.0 (hash-nightly-2)
52
54
53
55
rustup - Update available : {} -> {}
54
56
" ,
55
- & this_host_triple( ) ,
56
- current_version,
57
- test_version
58
- ) ,
59
- for_host ! (
60
- r"info: syncing channel updates for 'nightly-{0}'
57
+ & this_host_triple( ) ,
58
+ current_version,
59
+ test_version
60
+ ) ,
61
+ for_host ! (
62
+ r"info: syncing channel updates for 'nightly-{0}'
61
63
info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2)
62
64
info: downloading component 'cargo'
63
65
info: downloading component 'rust-docs'
@@ -68,28 +70,29 @@ info: installing component 'rust-docs'
68
70
info: installing component 'rust-std'
69
71
info: installing component 'rustc'
70
72
"
71
- ) ,
72
- ) ;
73
- } )
73
+ ) ,
74
+ ) ;
74
75
}
75
76
76
77
#[ test]
77
78
fn update_once_and_self_update ( ) {
78
79
let test_version = "2.0.0" ;
79
80
let mut cx = CliTestContext :: from ( Scenario :: SimpleV2 ) ;
80
- with_update_server ( & mut cx. config , test_version, & |config| {
81
- config. expect_ok ( & [ "rustup-init" , "-y" , "--no-modify-path" ] ) ;
82
- config. expect_ok ( & [ "rustup" , "set" , "auto-self-update" , "enable" ] ) ;
83
- config. expect_ok_ex (
84
- & [ "rustup" , "update" , "nightly" ] ,
85
- for_host ! (
86
- r"
81
+ let _dist_guard = cx. with_update_server ( test_version) ;
82
+ cx. config
83
+ . expect_ok ( & [ "rustup-init" , "-y" , "--no-modify-path" ] ) ;
84
+ cx. config
85
+ . expect_ok ( & [ "rustup" , "set" , "auto-self-update" , "enable" ] ) ;
86
+ cx. config . expect_ok_ex (
87
+ & [ "rustup" , "update" , "nightly" ] ,
88
+ for_host ! (
89
+ r"
87
90
nightly-{0} installed - 1.3.0 (hash-nightly-2)
88
91
89
92
"
90
- ) ,
91
- for_host ! (
92
- r"info: syncing channel updates for 'nightly-{0}'
93
+ ) ,
94
+ for_host ! (
95
+ r"info: syncing channel updates for 'nightly-{0}'
93
96
info: latest update on 2015-01-02, rust version 1.3.0 (hash-nightly-2)
94
97
info: downloading component 'cargo'
95
98
info: downloading component 'rust-docs'
@@ -102,9 +105,8 @@ info: installing component 'rustc'
102
105
info: checking for self-update
103
106
info: downloading self-update
104
107
"
105
- ) ,
106
- ) ;
107
- } ) ;
108
+ ) ,
109
+ ) ;
108
110
}
109
111
110
112
#[ test]
@@ -182,32 +184,30 @@ nightly-{0} - Update available : 1.2.0 (hash-nightly-1) -> 1.3.0 (hash-nightly-2
182
184
fn check_updates_self ( ) {
183
185
let test_version = "2.0.0" ;
184
186
let mut cx = CliTestContext :: from ( Scenario :: SimpleV2 ) ;
185
- with_update_server ( & mut cx. config , test_version, & |config| {
186
- let current_version = env ! ( "CARGO_PKG_VERSION" ) ;
187
+ let _dist_guard = cx. with_update_server ( test_version) ;
188
+ let current_version = env ! ( "CARGO_PKG_VERSION" ) ;
187
189
188
- config. expect_stdout_ok (
189
- & [ "rustup" , "check" ] ,
190
- & format ! (
191
- r"rustup - Update available : {current_version} -> {test_version}
190
+ cx . config . expect_stdout_ok (
191
+ & [ "rustup" , "check" ] ,
192
+ & format ! (
193
+ r"rustup - Update available : {current_version} -> {test_version}
192
194
"
193
- ) ,
194
- ) ;
195
- } ) ;
195
+ ) ,
196
+ ) ;
196
197
}
197
198
198
199
#[ test]
199
200
fn check_updates_self_no_change ( ) {
200
201
let current_version = env ! ( "CARGO_PKG_VERSION" ) ;
201
202
let mut cx = CliTestContext :: from ( Scenario :: SimpleV2 ) ;
202
- with_update_server ( & mut cx. config , current_version, & |config| {
203
- config. expect_stdout_ok (
204
- & [ "rustup" , "check" ] ,
205
- & format ! (
206
- r"rustup - Up to date : {current_version}
203
+ let _dist_guard = cx. with_update_server ( current_version) ;
204
+ cx . config . expect_stdout_ok (
205
+ & [ "rustup" , "check" ] ,
206
+ & format ! (
207
+ r"rustup - Up to date : {current_version}
207
208
"
208
- ) ,
209
- ) ;
210
- } ) ;
209
+ ) ,
210
+ ) ;
211
211
}
212
212
213
213
#[ test]
0 commit comments