Skip to content

Commit 3d7a292

Browse files
Skglandrami3l
authored andcommitted
add a regression test
1 parent 4eb9b6b commit 3d7a292

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

tests/suite/cli_v2.rs

+33
Original file line numberDiff line numberDiff 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]
303336
fn bad_sha_on_installer() {
304337
setup(&|config| {

0 commit comments

Comments
 (0)