44pub mod mock;
55
66use crate :: mock:: clitools:: {
7- self , expect_err_ex, expect_ok, expect_ok_ex, this_host_triple, Config , Scenario ,
7+ self , expect_err_ex, expect_ok, expect_ok_ex, expect_stdout_ok, set_current_dist_date,
8+ this_host_triple, Config , Scenario ,
89} ;
910
1011macro_rules! for_host {
@@ -14,7 +15,7 @@ macro_rules! for_host {
1415}
1516
1617fn setup ( f : & dyn Fn ( & mut Config ) ) {
17- clitools:: setup ( Scenario :: SimpleV2 , f) ;
18+ clitools:: setup ( Scenario :: ArchivesV2 , f) ;
1819}
1920
2021#[ test]
@@ -31,7 +32,7 @@ fn update() {
3132 ) ,
3233 for_host ! (
3334 r"info: syncing channel updates for 'nightly-{0}'
34- info: latest update on 2015-01-02, rust version 1.3.0
35+ info: latest update on 2015-01-02, rust version 1.3.0 (hash-n-2)
3536info: downloading component 'rustc'
3637info: downloading component 'cargo'
3738info: downloading component 'rust-std'
@@ -68,6 +69,89 @@ fn update_again() {
6869 } ) ;
6970}
7071
72+ #[ test]
73+ fn check_updates_none ( ) {
74+ setup ( & |config| {
75+ set_current_dist_date ( config, "2015-01-01" ) ;
76+ expect_ok ( config, & [ "rustup" , "update" , "stable" , "--no-self-update" ] ) ;
77+ expect_ok ( config, & [ "rustup" , "update" , "beta" , "--no-self-update" ] ) ;
78+ expect_ok ( config, & [ "rustup" , "update" , "nightly" , "--no-self-update" ] ) ;
79+ expect_stdout_ok (
80+ config,
81+ & [ "rustup" , "check" ] ,
82+ for_host ! (
83+ r"stable-{0} - Up to date : 1.0.0 (hash-s-1)
84+ beta-{0} - Up to date : 1.1.0 (hash-b-1)
85+ nightly-{0} - Up to date : 1.2.0 (hash-n-1)
86+ "
87+ ) ,
88+ ) ;
89+ } )
90+ }
91+
92+ #[ test]
93+ fn check_updates_some ( ) {
94+ setup ( & |config| {
95+ set_current_dist_date ( config, "2015-01-01" ) ;
96+ expect_ok ( config, & [ "rustup" , "update" , "stable" , "--no-self-update" ] ) ;
97+ expect_ok ( config, & [ "rustup" , "update" , "beta" , "--no-self-update" ] ) ;
98+ expect_ok ( config, & [ "rustup" , "update" , "nightly" , "--no-self-update" ] ) ;
99+ set_current_dist_date ( config, "2015-01-02" ) ;
100+ expect_stdout_ok (
101+ config,
102+ & [ "rustup" , "check" ] ,
103+ for_host ! (
104+ r"stable-{0} - Update available : 1.0.0 (hash-s-1) -> 1.1.0 (hash-s-2)
105+ beta-{0} - Update available : 1.1.0 (hash-b-1) -> 1.2.0 (hash-b-2)
106+ nightly-{0} - Update available : 1.2.0 (hash-n-1) -> 1.3.0 (hash-n-2)
107+ "
108+ ) ,
109+ ) ;
110+ } )
111+ }
112+
113+ #[ test]
114+ fn check_updates_with_update ( ) {
115+ setup ( & |config| {
116+ set_current_dist_date ( config, "2015-01-01" ) ;
117+ expect_ok ( config, & [ "rustup" , "update" , "stable" , "--no-self-update" ] ) ;
118+ expect_ok ( config, & [ "rustup" , "update" , "beta" , "--no-self-update" ] ) ;
119+ expect_ok ( config, & [ "rustup" , "update" , "nightly" , "--no-self-update" ] ) ;
120+ expect_stdout_ok (
121+ config,
122+ & [ "rustup" , "check" ] ,
123+ for_host ! (
124+ r"stable-{0} - Up to date : 1.0.0 (hash-s-1)
125+ beta-{0} - Up to date : 1.1.0 (hash-b-1)
126+ nightly-{0} - Up to date : 1.2.0 (hash-n-1)
127+ "
128+ ) ,
129+ ) ;
130+ set_current_dist_date ( config, "2015-01-02" ) ;
131+ expect_stdout_ok (
132+ config,
133+ & [ "rustup" , "check" ] ,
134+ for_host ! (
135+ r"stable-{0} - Update available : 1.0.0 (hash-s-1) -> 1.1.0 (hash-s-2)
136+ beta-{0} - Update available : 1.1.0 (hash-b-1) -> 1.2.0 (hash-b-2)
137+ nightly-{0} - Update available : 1.2.0 (hash-n-1) -> 1.3.0 (hash-n-2)
138+ "
139+ ) ,
140+ ) ;
141+ expect_ok ( config, & [ "rustup" , "update" , "beta" , "--no-self-update" ] ) ;
142+ expect_stdout_ok (
143+ config,
144+ & [ "rustup" , "check" ] ,
145+ for_host ! (
146+ r"stable-{0} - Update available : 1.0.0 (hash-s-1) -> 1.1.0 (hash-s-2)
147+ beta-{0} - Up to date : 1.2.0 (hash-b-2)
148+ nightly-{0} - Update available : 1.2.0 (hash-n-1) -> 1.3.0 (hash-n-2)
149+ "
150+ ) ,
151+ ) ;
152+ } )
153+ }
154+
71155#[ test]
72156fn default ( ) {
73157 setup ( & |config| {
@@ -82,7 +166,7 @@ fn default() {
82166 ) ,
83167 for_host ! (
84168 r"info: syncing channel updates for 'nightly-{0}'
85- info: latest update on 2015-01-02, rust version 1.3.0
169+ info: latest update on 2015-01-02, rust version 1.3.0 (hash-n-2)
86170info: downloading component 'rustc'
87171info: downloading component 'cargo'
88172info: downloading component 'rust-std'
@@ -342,7 +426,7 @@ fn update_invalid_toolchain() {
342426 & [ "rustup" , "update" , "nightly-2016-03-1" ] ,
343427 r"" ,
344428 r"info: syncing channel updates for 'nightly-2016-03-1'
345- info: latest update on 2015-01-02, rust version 1.3.0
429+ info: latest update on 2015-01-02, rust version 1.3.0 (hash-n-2)
346430error: target '2016-03-1' not found in channel. Perhaps check https://forge.rust-lang.org/platform-support.html for available targets
347431" ,
348432 ) ;
@@ -357,7 +441,7 @@ fn default_invalid_toolchain() {
357441 & [ "rustup" , "default" , "nightly-2016-03-1" ] ,
358442 r"" ,
359443 r"info: syncing channel updates for 'nightly-2016-03-1'
360- info: latest update on 2015-01-02, rust version 1.3.0
444+ info: latest update on 2015-01-02, rust version 1.3.0 (hash-n-2)
361445error: target '2016-03-1' not found in channel. Perhaps check https://forge.rust-lang.org/platform-support.html for available targets
362446" ,
363447 ) ;
0 commit comments