File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -299,6 +299,39 @@ fn bad_sha_on_manifest() {
299299 } ) ;
300300}
301301
302+ #[ test]
303+ fn bad_manifest ( ) {
304+ // issue #3851
305+ setup ( & |config| {
306+ // install some toolchain
307+ config. expect_ok ( & [ "rustup" , "update" , "nightly" ] ) ;
308+ let path = format ! (
309+ "toolchains/nightly-{}/lib/rustlib/multirust-channel-manifest.toml" ,
310+ this_host_triple( ) ,
311+ ) ;
312+ assert ! ( config. rustupdir. has( & path) ) ;
313+ let path = config. rustupdir . join ( & path) ;
314+
315+ // corrupt the manifest file by inserting a NUL byte at some position
316+ let old = fs:: read_to_string ( & path) . unwrap ( ) ;
317+ let pattern = "[[pkg.rust.targ" ;
318+ let ( prefix, suffix) = old. split_once ( pattern) . unwrap ( ) ;
319+ let new = format ! ( "{prefix}{pattern}\u{0} {suffix}" ) ;
320+ fs:: write ( & path, new) . unwrap ( ) ;
321+
322+ // run some commands that try to load the manifest and
323+ // check that the manifest parsing error includes the manifest file path
324+ config. expect_err (
325+ & [ "rustup" , "check" ] ,
326+ & format ! ( "error: could not parse manifest file: '{}'" , path. display( ) ) ,
327+ ) ;
328+ config. expect_err (
329+ & [ "cargo" , "--help" ] ,
330+ & format ! ( "error: could not parse manifest file: '{}'" , path. display( ) ) ,
331+ ) ;
332+ } ) ;
333+ }
334+
302335#[ test]
303336fn bad_sha_on_installer ( ) {
304337 setup ( & |config| {
You can’t perform that action at this time.
0 commit comments