fix(embedded): Don't generate empty package names

This commit is contained in:
Ed Page 2023-07-11 14:37:44 -05:00
parent 87be661989
commit 7d4e39c4f5
2 changed files with 11 additions and 5 deletions

View file

@ -100,6 +100,9 @@ pub fn sanitize_package_name(name: &str, placeholder: char) -> String {
slug.push(placeholder);
}
}
if slug.is_empty() {
slug.push_str("package");
}
slug
}

View file

@ -574,13 +574,16 @@ fn test_name_is_number() {
p.cargo("-Zscript -v 42.rs")
.masquerade_as_nightly_cargo(&["script"])
.with_status(101)
.with_stdout(
r#"bin: [..]/debug/package[EXE]
args: []
"#,
)
.with_stderr(
r#"[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
[ERROR] failed to parse manifest at `[ROOT]/foo/42.rs`
Caused by:
package name cannot be an empty string
[COMPILING] package v0.0.0 ([ROOT]/foo)
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]s
[RUNNING] `[..]/debug/package[EXE]`
"#,
)
.run();