-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for cargo add's rust-version behavior
- Loading branch information
1 parent
9ddcf9f
commit 4ae83b9
Showing
29 changed files
with
213 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
rust-version = "1.68" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use cargo_test_support::compare::assert_ui; | ||
use cargo_test_support::prelude::*; | ||
use cargo_test_support::Project; | ||
|
||
use crate::cargo_add::init_registry; | ||
use cargo_test_support::curr_dir; | ||
|
||
#[cargo_test(nightly, reason = "-Zmsrv-policy is unstable")] | ||
fn case() { | ||
init_registry(); | ||
|
||
cargo_test_support::registry::Package::new("rust-version-user", "0.1.0") | ||
.rust_version("1.66") | ||
.publish(); | ||
cargo_test_support::registry::Package::new("rust-version-user", "0.2.1") | ||
.rust_version("1.72") | ||
.publish(); | ||
|
||
let project = Project::from_template(curr_dir!().join("in")); | ||
let project_root = project.root(); | ||
let cwd = &project_root; | ||
|
||
snapbox::cmd::Command::cargo_ui() | ||
.arg("-Zmsrv-policy") | ||
.arg("add") | ||
.arg("--ignore-rust-version") | ||
.arg_line("rust-version-user") | ||
.current_dir(cwd) | ||
.masquerade_as_nightly_cargo(&["msrv-policy"]) | ||
.assert() | ||
.success() | ||
.stdout_matches_path(curr_dir!().join("stdout.log")) | ||
.stderr_matches_path(curr_dir!().join("stderr.log")); | ||
|
||
assert_ui().subset_matches(curr_dir!().join("out"), &project_root); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
rust-version = "1.68" | ||
|
||
[dependencies] | ||
rust-version-user = "0.2.1" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Updating `dummy-registry` index | ||
Adding rust-version-user v0.2.1 to dependencies. |
Empty file.
6 changes: 6 additions & 0 deletions
6
tests/testsuite/cargo_add/rust_version_incompatible/in/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
rust-version = "1.56" |
Empty file.
35 changes: 35 additions & 0 deletions
35
tests/testsuite/cargo_add/rust_version_incompatible/mod.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use cargo_test_support::compare::assert_ui; | ||
use cargo_test_support::prelude::*; | ||
use cargo_test_support::Project; | ||
|
||
use crate::cargo_add::init_registry; | ||
use cargo_test_support::curr_dir; | ||
|
||
#[cargo_test(nightly, reason = "-Zmsrv-policy is unstable")] | ||
fn case() { | ||
init_registry(); | ||
|
||
cargo_test_support::registry::Package::new("rust-version-user", "0.1.0") | ||
.rust_version("1.66") | ||
.publish(); | ||
cargo_test_support::registry::Package::new("rust-version-user", "0.2.1") | ||
.rust_version("1.72") | ||
.publish(); | ||
|
||
let project = Project::from_template(curr_dir!().join("in")); | ||
let project_root = project.root(); | ||
let cwd = &project_root; | ||
|
||
snapbox::cmd::Command::cargo_ui() | ||
.arg("-Zmsrv-policy") | ||
.arg("add") | ||
.arg_line("rust-version-user") | ||
.current_dir(cwd) | ||
.masquerade_as_nightly_cargo(&["msrv-policy"]) | ||
.assert() | ||
.failure() | ||
.stdout_matches_path(curr_dir!().join("stdout.log")) | ||
.stderr_matches_path(curr_dir!().join("stderr.log")); | ||
|
||
assert_ui().subset_matches(curr_dir!().join("out"), &project_root); | ||
} |
6 changes: 6 additions & 0 deletions
6
tests/testsuite/cargo_add/rust_version_incompatible/out/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
rust-version = "1.56" |
Empty file.
4 changes: 4 additions & 0 deletions
4
tests/testsuite/cargo_add/rust_version_incompatible/stderr.log
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Updating `dummy-registry` index | ||
error: could not find version of crate `rust-version-user` that satisfies this package's rust-version | ||
help: use `--ignore-rust-version` to override this behavior | ||
note: the lowest rust-version available for `rust-version-user` is 1.66 |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
rust-version = "1.72" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use cargo_test_support::compare::assert_ui; | ||
use cargo_test_support::prelude::*; | ||
use cargo_test_support::Project; | ||
|
||
use crate::cargo_add::init_registry; | ||
use cargo_test_support::curr_dir; | ||
|
||
#[cargo_test(nightly, reason = "-Zmsrv-policy is unstable")] | ||
fn case() { | ||
init_registry(); | ||
|
||
cargo_test_support::registry::Package::new("rust-version-user", "0.1.0") | ||
.rust_version("1.66") | ||
.publish(); | ||
cargo_test_support::registry::Package::new("rust-version-user", "0.2.1") | ||
.rust_version("1.72") | ||
.publish(); | ||
|
||
let project = Project::from_template(curr_dir!().join("in")); | ||
let project_root = project.root(); | ||
let cwd = &project_root; | ||
|
||
snapbox::cmd::Command::cargo_ui() | ||
.arg("-Zmsrv-policy") | ||
.arg("add") | ||
.arg_line("rust-version-user") | ||
.current_dir(cwd) | ||
.masquerade_as_nightly_cargo(&["msrv-policy"]) | ||
.assert() | ||
.success() | ||
.stdout_matches_path(curr_dir!().join("stdout.log")) | ||
.stderr_matches_path(curr_dir!().join("stderr.log")); | ||
|
||
assert_ui().subset_matches(curr_dir!().join("out"), &project_root); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
rust-version = "1.72" | ||
|
||
[dependencies] | ||
rust-version-user = "0.2.1" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Updating `dummy-registry` index | ||
Adding rust-version-user v0.2.1 to dependencies. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
rust-version = "1.70" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use cargo_test_support::compare::assert_ui; | ||
use cargo_test_support::prelude::*; | ||
use cargo_test_support::Project; | ||
|
||
use crate::cargo_add::init_registry; | ||
use cargo_test_support::curr_dir; | ||
|
||
#[cargo_test(nightly, reason = "-Zmsrv-policy is unstable")] | ||
fn case() { | ||
init_registry(); | ||
|
||
cargo_test_support::registry::Package::new("rust-version-user", "0.1.0") | ||
.rust_version("1.66") | ||
.publish(); | ||
cargo_test_support::registry::Package::new("rust-version-user", "0.2.1") | ||
.rust_version("1.72") | ||
.publish(); | ||
|
||
let project = Project::from_template(curr_dir!().join("in")); | ||
let project_root = project.root(); | ||
let cwd = &project_root; | ||
|
||
snapbox::cmd::Command::cargo_ui() | ||
.arg("-Zmsrv-policy") | ||
.arg("add") | ||
.arg_line("rust-version-user") | ||
.current_dir(cwd) | ||
.masquerade_as_nightly_cargo(&["msrv-policy"]) | ||
.assert() | ||
.success() | ||
.stdout_matches_path(curr_dir!().join("stdout.log")) | ||
.stderr_matches_path(curr_dir!().join("stderr.log")); | ||
|
||
assert_ui().subset_matches(curr_dir!().join("out"), &project_root); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[workspace] | ||
|
||
[package] | ||
name = "cargo-list-test-fixture" | ||
version = "0.0.0" | ||
rust-version = "1.70" | ||
|
||
[dependencies] | ||
rust-version-user = "0.1.0" |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Updating `dummy-registry` index | ||
warning: selecting older version of `rust-version-user` to satisfy this package's rust-version (use `--ignore-rust-version` to override) | ||
Adding rust-version-user v0.1.0 to dependencies. |
Empty file.