mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
test(add): Ensure an empty frontmatter is handled properly
There are corner cases with empty frontmatters, so I wanted to ensure this case works now and going forward
This commit is contained in:
parent
865dfe26d1
commit
b54b92cc5f
@ -149,6 +149,7 @@ mod rustc_older;
|
||||
mod script_bare;
|
||||
mod script_escape;
|
||||
mod script_frontmatter;
|
||||
mod script_frontmatter_empty;
|
||||
mod script_shebang;
|
||||
mod sorted_table_with_dotted_item;
|
||||
mod symlink;
|
||||
|
@ -0,0 +1,4 @@
|
||||
---
|
||||
---
|
||||
|
||||
fn main() {}
|
39
tests/testsuite/cargo_add/script_frontmatter_empty/mod.rs
Normal file
39
tests/testsuite/cargo_add/script_frontmatter_empty/mod.rs
Normal file
@ -0,0 +1,39 @@
|
||||
use crate::prelude::*;
|
||||
use cargo_test_support::Project;
|
||||
use cargo_test_support::compare::assert_ui;
|
||||
use cargo_test_support::current_dir;
|
||||
use cargo_test_support::file;
|
||||
use cargo_test_support::str;
|
||||
|
||||
#[cargo_test]
|
||||
fn case() {
|
||||
cargo_test_support::registry::init();
|
||||
for ver in [
|
||||
"0.1.1+my-package",
|
||||
"0.2.0+my-package",
|
||||
"0.2.3+my-package",
|
||||
"0.4.1+my-package",
|
||||
"20.0.0+my-package",
|
||||
"99999.0.0+my-package",
|
||||
"99999.0.0-alpha.1+my-package",
|
||||
] {
|
||||
cargo_test_support::registry::Package::new("my-package", ver).publish();
|
||||
}
|
||||
|
||||
let project = Project::from_template(current_dir!().join("in"));
|
||||
let project_root = project.root();
|
||||
let cwd = &project_root;
|
||||
|
||||
snapbox::cmd::Command::cargo_ui()
|
||||
.masquerade_as_nightly_cargo(&["script"])
|
||||
.arg("-Zscript")
|
||||
.arg("add")
|
||||
.arg_line("--manifest-path cargo-test-fixture.rs my-package")
|
||||
.current_dir(cwd)
|
||||
.assert()
|
||||
.success()
|
||||
.stdout_eq(str![""])
|
||||
.stderr_eq(file!["stderr.term.svg"]);
|
||||
|
||||
assert_ui().subset_matches(current_dir!().join("out"), &project_root);
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
[dependencies]
|
||||
my-package = "99999.0.0"
|
||||
---
|
||||
|
||||
fn main() {}
|
@ -0,0 +1,36 @@
|
||||
<svg width="740px" height="128px" xmlns="http://www.w3.org/2000/svg">
|
||||
<style>
|
||||
.fg { fill: #AAAAAA }
|
||||
.bg { background: #000000 }
|
||||
.fg-green { fill: #00AA00 }
|
||||
.fg-yellow { fill: #AA5500 }
|
||||
.container {
|
||||
padding: 0 10px;
|
||||
line-height: 18px;
|
||||
}
|
||||
.bold { font-weight: bold; }
|
||||
tspan {
|
||||
font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
|
||||
white-space: pre;
|
||||
line-height: 18px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<rect width="100%" height="100%" y="0" rx="4.5" class="bg" />
|
||||
|
||||
<text xml:space="preserve" class="container fg">
|
||||
<tspan x="10px" y="28px"><tspan class="fg-yellow bold">warning</tspan><tspan class="bold">:</tspan><tspan> `package.edition` is unspecified, defaulting to `2024`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="46px"><tspan class="fg-green bold"> Updating</tspan><tspan> `dummy-registry` index</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="64px"><tspan class="fg-green bold"> Adding</tspan><tspan> my-package v99999.0.0 to dependencies</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="82px"><tspan class="fg-yellow bold">warning</tspan><tspan class="bold">:</tspan><tspan> `package.edition` is unspecified, defaulting to `2024`</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="100px"><tspan class="fg-green bold"> Locking</tspan><tspan> 1 package to latest Rust [..] compatible version</tspan>
|
||||
</tspan>
|
||||
<tspan x="10px" y="118px">
|
||||
</tspan>
|
||||
</text>
|
||||
|
||||
</svg>
|
After Width: | Height: | Size: 1.4 KiB |
Loading…
x
Reference in New Issue
Block a user