test(toml): Verify existing version-less behavior

This commit is contained in:
Ed Page 2023-10-04 13:00:37 -05:00
parent fcc3786d73
commit 5c9a126911
4 changed files with 144 additions and 0 deletions

View file

@ -1496,3 +1496,32 @@ fn check_unused_manifest_keys() {
)
.run();
}
#[cargo_test]
fn versionless_package() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
description = "foo"
"#,
)
.file("src/lib.rs", "")
.build();
p.cargo("check")
.with_stderr(
r#"error: failed to parse manifest at `[CWD]/Cargo.toml`
Caused by:
TOML parse error at line 2, column 17
|
2 | [package]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
missing field `version`
"#,
)
.with_status(101)
.run();
}

View file

@ -4257,3 +4257,58 @@ fn workspace_metadata_with_dependencies_no_deps_artifact() {
)
.run();
}
#[cargo_test]
fn versionless_packages() {
let p = project()
.file(
"Cargo.toml",
r#"
[workspace]
members = ["bar", "baz"]
"#,
)
.file(
"bar/Cargo.toml",
r#"
[package]
name = "bar"
[dependencies]
foobar = "0.0.1"
baz = { path = "../baz/" }
"#,
)
.file("bar/src/lib.rs", "")
.file(
"baz/Cargo.toml",
r#"
[package]
name = "baz"
[dependencies]
foobar = "0.0.1"
"#,
)
.file("baz/src/lib.rs", "")
.build();
Package::new("foobar", "0.0.1").publish();
p.cargo("metadata -q --format-version 1")
.with_stderr(
r#"error: failed to load manifest for workspace member `[CWD]/bar`
Caused by:
failed to parse manifest at `[CWD]/bar/Cargo.toml`
Caused by:
TOML parse error at line 2, column 17
|
2 | [package]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
missing field `version`
"#,
)
.with_status(101)
.run();
}

View file

@ -3095,3 +3095,33 @@ src/main.rs
&[],
);
}
#[cargo_test]
fn versionless_package() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
description = "foo"
"#,
)
.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
.build();
p.cargo("package")
.with_stderr(
r#"error: failed to parse manifest at `[CWD]/Cargo.toml`
Caused by:
TOML parse error at line 2, column 17
|
2 | [package]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
missing field `version`
"#,
)
.with_status(101)
.run();
}

View file

@ -3004,3 +3004,33 @@ Caused by:
.with_status(101)
.run();
}
#[cargo_test]
fn versionless_package() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
description = "foo"
"#,
)
.file("src/main.rs", r#"fn main() { println!("hello"); }"#)
.build();
p.cargo("publish")
.with_stderr(
r#"error: failed to parse manifest at `[CWD]/Cargo.toml`
Caused by:
TOML parse error at line 2, column 17
|
2 | [package]
| ^^^^^^^^^^^^^^^^^^^^^^^^^
missing field `version`
"#,
)
.with_status(101)
.run();
}