@@ -8,6 +8,7 @@ extern crate tempdir;
8
8
use multirust_mock:: clitools:: { self , Config , Scenario ,
9
9
expect_ok, expect_ok_ex,
10
10
expect_stdout_ok,
11
+ expect_err_ex,
11
12
set_current_dist_date} ;
12
13
13
14
pub fn setup ( f : & Fn ( & Config ) ) {
@@ -222,3 +223,79 @@ fn link() {
222
223
"hash-c-1" ) ;
223
224
} ) ;
224
225
}
226
+
227
+ #[ test]
228
+ fn show_toolchain_none ( ) {
229
+ setup ( & |config| {
230
+ expect_ok_ex ( config, & [ "rustup" , "show" ] ,
231
+ r"no active toolchain
232
+ " ,
233
+ r"" ) ;
234
+ } ) ;
235
+ }
236
+
237
+ #[ test]
238
+ fn show_toolchain_default ( ) {
239
+ setup ( & |config| {
240
+ expect_ok ( config, & [ "rustup" , "default" , "nightly" ] ) ;
241
+ expect_ok_ex ( config, & [ "rustup" , "show" ] ,
242
+ r"nightly (default toolchain)
243
+ " ,
244
+ r"" ) ;
245
+ } ) ;
246
+ }
247
+
248
+ #[ test]
249
+ fn show_toolchain_override ( ) {
250
+ setup ( & |config| {
251
+ let cwd = :: std:: env:: current_dir ( ) . unwrap ( ) ;
252
+ expect_ok ( config, & [ "rustup" , "override" , "add" , "nightly" ] ) ;
253
+ expect_ok_ex ( config, & [ "rustup" , "show" ] ,
254
+ & format ! ( r"nightly (directory override for '{}')
255
+ " , cwd. display( ) ) ,
256
+ r"" ) ;
257
+ } ) ;
258
+ }
259
+
260
+ #[ test]
261
+ fn show_toolchain_override_not_installed ( ) {
262
+ setup ( & |config| {
263
+ expect_ok ( config, & [ "rustup" , "override" , "add" , "nightly" ] ) ;
264
+ expect_ok ( config, & [ "rustup" , "toolchain" , "remove" , "nightly" ] ) ;
265
+ // I'm not sure this should really be erroring when the toolchain
266
+ // is not installed; just capturing the behavior.
267
+ expect_err_ex ( config, & [ "rustup" , "show" ] ,
268
+ r"" ,
269
+ r"error: toolchain 'nightly' is not installed
270
+ " ) ;
271
+ } ) ;
272
+ }
273
+
274
+ #[ test]
275
+ fn show_toolchain_env ( ) {
276
+ setup ( & |config| {
277
+ expect_ok ( config, & [ "rustup" , "default" , "nightly" ] ) ;
278
+ let mut cmd = clitools:: cmd ( config, "rustup" , & [ "show" ] ) ;
279
+ clitools:: env ( config, & mut cmd) ;
280
+ cmd. env ( "MULTIRUST_TOOLCHAIN" , "nightly" ) ;
281
+ let out = cmd. output ( ) . unwrap ( ) ;
282
+ assert ! ( out. status. success( ) ) ;
283
+ let stdout = String :: from_utf8 ( out. stdout ) . unwrap ( ) ;
284
+ assert ! ( stdout == "nightly (environment override by MULTIRUST_TOOLCHAIN)\n " ) ;
285
+ } ) ;
286
+ }
287
+
288
+ #[ test]
289
+ fn show_toolchain_env_not_installed ( ) {
290
+ setup ( & |config| {
291
+ let mut cmd = clitools:: cmd ( config, "rustup" , & [ "show" ] ) ;
292
+ clitools:: env ( config, & mut cmd) ;
293
+ cmd. env ( "MULTIRUST_TOOLCHAIN" , "nightly" ) ;
294
+ let out = cmd. output ( ) . unwrap ( ) ;
295
+ // I'm not sure this should really be erroring when the toolchain
296
+ // is not installed; just capturing the behavior.
297
+ assert ! ( !out. status. success( ) ) ;
298
+ let stderr = String :: from_utf8 ( out. stderr ) . unwrap ( ) ;
299
+ assert ! ( stderr == "error: toolchain 'nightly' is not installed\n " ) ;
300
+ } ) ;
301
+ }
0 commit comments