@@ -6,7 +6,7 @@ extern crate rustup_utils;
66extern crate tempdir;
77
88use rustup_mock:: clitools:: {
9- self , expect_err, expect_ok, expect_ok_ex, expect_stderr_ok, expect_stdout_ok,
9+ self , expect_err, expect_ok, expect_ok_ex, expect_stderr_ok, expect_stdout_ok, run ,
1010 set_current_dist_date, this_host_triple, Config , Scenario ,
1111} ;
1212use rustup_utils:: raw;
@@ -1557,3 +1557,83 @@ fn docs_with_path() {
15571557 assert ! ( String :: from_utf8( out. stdout) . unwrap( ) . contains( "nightly" ) ) ;
15581558 } ) ;
15591559}
1560+
1561+ #[ cfg( unix) ]
1562+ #[ test]
1563+ fn non_utf8_arg ( ) {
1564+ use std:: ffi:: OsStr ;
1565+ use std:: os:: unix:: ffi:: OsStrExt ;
1566+
1567+ setup ( & |config| {
1568+ expect_ok ( config, & [ "rustup" , "default" , "nightly" ] ) ;
1569+ let out = run (
1570+ config,
1571+ "rustc" ,
1572+ & [
1573+ OsStr :: new ( "--echo-args" ) ,
1574+ OsStr :: new ( "echoed non-utf8 arg:" ) ,
1575+ OsStr :: from_bytes ( b"\xc3 \x28 " ) ,
1576+ ] ,
1577+ & [ ( "RUST_BACKTRACE" , "1" ) ] ,
1578+ ) ;
1579+ assert ! ( out. stderr. contains( "echoed non-utf8 arg" ) ) ;
1580+ } ) ;
1581+ }
1582+
1583+ #[ cfg( windows) ]
1584+ #[ test]
1585+ fn non_utf8_arg ( ) {
1586+ use std:: ffi:: OsString ;
1587+ use std:: os:: windows:: ffi:: OsStringExt ;
1588+
1589+ setup ( & |config| {
1590+ expect_ok ( config, & [ "rustup" , "default" , "nightly" ] ) ;
1591+ let out = run (
1592+ config,
1593+ "rustc" ,
1594+ & [
1595+ OsString :: from ( "--echo-args" . to_string ( ) ) ,
1596+ OsString :: from ( "echoed non-utf8 arg:" . to_string ( ) ) ,
1597+ OsString :: from_wide ( & [ 0xd801 , 0xd801 ] ) ,
1598+ ] ,
1599+ & [ ( "RUST_BACKTRACE" , "1" ) ] ,
1600+ ) ;
1601+ assert ! ( out. stderr. contains( "echoed non-utf8 arg" ) ) ;
1602+ } ) ;
1603+ }
1604+
1605+ #[ cfg( unix) ]
1606+ #[ test]
1607+ fn non_utf8_toolchain ( ) {
1608+ use std:: ffi:: OsStr ;
1609+ use std:: os:: unix:: ffi:: OsStrExt ;
1610+
1611+ setup ( & |config| {
1612+ expect_ok ( config, & [ "rustup" , "default" , "nightly" ] ) ;
1613+ let out = run (
1614+ config,
1615+ "rustc" ,
1616+ & [ OsStr :: from_bytes ( b"+\xc3 \x28 " ) ] ,
1617+ & [ ( "RUST_BACKTRACE" , "1" ) ] ,
1618+ ) ;
1619+ assert ! ( out. stderr. contains( "toolchain '�(' is not installed" ) ) ;
1620+ } ) ;
1621+ }
1622+
1623+ #[ cfg( windows) ]
1624+ #[ test]
1625+ fn non_utf8_toolchain ( ) {
1626+ use std:: ffi:: OsString ;
1627+ use std:: os:: windows:: ffi:: OsStringExt ;
1628+
1629+ setup ( & |config| {
1630+ expect_ok ( config, & [ "rustup" , "default" , "nightly" ] ) ;
1631+ let out = run (
1632+ config,
1633+ "rustc" ,
1634+ & [ OsString :: from_wide ( & [ u16:: from ( '+' as u8 ) , 0xd801 , 0xd801 ] ) ] ,
1635+ & [ ( "RUST_BACKTRACE" , "1" ) ] ,
1636+ ) ;
1637+ assert ! ( out. stderr. contains( "toolchain '��' is not installed" ) ) ;
1638+ } ) ;
1639+ }
0 commit comments