Skip to content

Commit 226b53e

Browse files
committed
test(resolver): Verify some more msrv cases
1 parent 39b8f17 commit 226b53e

File tree

1 file changed

+96
-1
lines changed

1 file changed

+96
-1
lines changed

tests/testsuite/rust_version.rs

Lines changed: 96 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Tests for targets with `rust-version`.
22
3-
use cargo_test_support::{project, registry::Package};
3+
use cargo_test_support::{cargo_process, project, registry::Package};
44

55
#[cargo_test]
66
fn rust_version_satisfied() {
@@ -605,6 +605,57 @@ See https://github.com/rust-lang/cargo/issues/9930 for more information about th
605605
.run();
606606
}
607607

608+
#[cargo_test]
609+
fn update_precise_overrides_msrv_resolver() {
610+
Package::new("bar", "1.5.0")
611+
.rust_version("1.55.0")
612+
.file("src/lib.rs", "fn other_stuff() {}")
613+
.publish();
614+
Package::new("bar", "1.6.0")
615+
.rust_version("1.65.0")
616+
.file("src/lib.rs", "fn other_stuff() {}")
617+
.publish();
618+
619+
let p = project()
620+
.file(
621+
"Cargo.toml",
622+
r#"
623+
[package]
624+
name = "foo"
625+
version = "0.0.1"
626+
edition = "2015"
627+
authors = []
628+
rust-version = "1.60.0"
629+
[dependencies]
630+
bar = "1.0.0"
631+
"#,
632+
)
633+
.file("src/main.rs", "fn main(){}")
634+
.build();
635+
636+
p.cargo("update")
637+
.arg("-Zmsrv-policy")
638+
.masquerade_as_nightly_cargo(&["msrv-policy"])
639+
.with_stderr(
640+
"\
641+
[UPDATING] `dummy-registry` index
642+
[LOCKING] 2 packages to latest Rust 1.60.0 compatible versions
643+
[ADDING] bar v1.5.0 (latest: v1.6.0)
644+
",
645+
)
646+
.run();
647+
p.cargo("update --precise 1.6.0 bar")
648+
.arg("-Zmsrv-policy")
649+
.masquerade_as_nightly_cargo(&["msrv-policy"])
650+
.with_stderr(
651+
"\
652+
[UPDATING] `dummy-registry` index
653+
[UPDATING] bar v1.5.0 -> v1.6.0
654+
",
655+
)
656+
.run();
657+
}
658+
608659
#[cargo_test]
609660
fn check_msrv_resolve() {
610661
Package::new("only-newer", "1.6.0")
@@ -693,3 +744,47 @@ foo v0.0.1 ([CWD])
693744
)
694745
.run();
695746
}
747+
748+
#[cargo_test]
749+
fn cargo_install_ignores_msrv_config() {
750+
Package::new("dep", "1.0.0")
751+
.rust_version("1.50")
752+
.file("src/lib.rs", "fn hello() {}")
753+
.publish();
754+
Package::new("dep", "1.1.0")
755+
.rust_version("1.70")
756+
.file("src/lib.rs", "fn hello() {}")
757+
.publish();
758+
Package::new("foo", "0.0.1")
759+
.rust_version("1.60")
760+
.file("src/main.rs", "fn main() {}")
761+
.dep("dep", "1")
762+
.publish();
763+
764+
cargo_process("install foo")
765+
.env(
766+
"CARGO_RESOLVER_SOMETHING_LIKE_PRECEDENCE",
767+
"something-like-rust-version",
768+
)
769+
.arg("-Zmsrv-policy")
770+
.masquerade_as_nightly_cargo(&["msrv-policy"])
771+
.with_stderr(
772+
"\
773+
[UPDATING] `[..]` index
774+
[DOWNLOADING] crates ...
775+
[DOWNLOADED] foo v0.0.1 (registry [..])
776+
[INSTALLING] foo v0.0.1
777+
[LOCKING] 2 packages to latest Rust 1.60 compatible versions
778+
[ADDING] dep v1.0.0 (latest: v1.1.0)
779+
[DOWNLOADING] crates ...
780+
[DOWNLOADED] dep v1.0.0 (registry [..])
781+
[COMPILING] dep v1.0.0
782+
[COMPILING] foo v0.0.1
783+
[FINISHED] `release` profile [optimized] target(s) in [..]
784+
[INSTALLING] [CWD]/home/.cargo/bin/foo[EXE]
785+
[INSTALLED] package `foo v0.0.1` (executable `foo[EXE]`)
786+
[WARNING] be sure to add `[..]` to your PATH to be able to run the installed binaries
787+
",
788+
)
789+
.run();
790+
}

0 commit comments

Comments
 (0)