Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/testsuite/cargo_add/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,9 @@ mod rustc_incompatible;
mod rustc_latest;
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;
Expand Down
12 changes: 12 additions & 0 deletions tests/testsuite/cargo_add/script_escape/in/cargo-test-fixture.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---------
[package]
edition = "2015"
description = """
Header
------

Body
"""
---------

fn main() {}
39 changes: 39 additions & 0 deletions tests/testsuite/cargo_add/script_escape/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
15 changes: 15 additions & 0 deletions tests/testsuite/cargo_add/script_escape/out/cargo-test-fixture.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---------
[package]
edition = "2015"
description = """
Header
------

Body
"""

[dependencies]
my-package = "99999.0.0"
---------

fn main() {}
31 changes: 31 additions & 0 deletions tests/testsuite/cargo_add/script_escape/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
---

fn main() {}
39 changes: 39 additions & 0 deletions tests/testsuite/cargo_add/script_frontmatter_empty/mod.rs
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
[dependencies]
my-package = "99999.0.0"
---

fn main() {}
36 changes: 36 additions & 0 deletions tests/testsuite/cargo_add/script_frontmatter_empty/stderr.term.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading