Skip to content

Commit 48ab82e

Browse files
committed
test(resolve): Show update/generate-lockfile behavior
1 parent 6f1cdae commit 48ab82e

File tree

1 file changed

+112
-0
lines changed

1 file changed

+112
-0
lines changed

tests/testsuite/rust_version.rs

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,118 @@ fn workspace_with_mixed_rust_version() {
504504
.run();
505505
}
506506

507+
#[cargo_test]
508+
fn generate_lockfile_msrv_resolve() {
509+
Package::new("bar", "1.5.0")
510+
.rust_version("1.55.0")
511+
.file("src/lib.rs", "fn other_stuff() {}")
512+
.publish();
513+
Package::new("bar", "1.6.0")
514+
.rust_version("1.65.0")
515+
.file("src/lib.rs", "fn other_stuff() {}")
516+
.publish();
517+
518+
let p = project()
519+
.file(
520+
"Cargo.toml",
521+
r#"
522+
[package]
523+
name = "foo"
524+
version = "0.0.1"
525+
edition = "2015"
526+
authors = []
527+
rust-version = "1.60.0"
528+
[dependencies]
529+
bar = "1.0.0"
530+
"#,
531+
)
532+
.file("src/main.rs", "fn main(){}")
533+
.build();
534+
535+
p.cargo("generate-lockfile --ignore-rust-version")
536+
.arg("-Zmsrv-policy")
537+
.masquerade_as_nightly_cargo(&["msrv-policy"])
538+
.with_status(1)
539+
.with_stderr(
540+
"\
541+
error: unexpected argument '--ignore-rust-version' found
542+
543+
Usage: cargo generate-lockfile [OPTIONS]
544+
545+
For more information, try '--help'.
546+
",
547+
)
548+
.run();
549+
p.cargo("generate-lockfile")
550+
.arg("-Zmsrv-policy")
551+
.masquerade_as_nightly_cargo(&["msrv-policy"])
552+
.with_stderr(
553+
"\
554+
[UPDATING] `dummy-registry` index
555+
[LOCKING] 2 packages
556+
[ADDING] bar v1.5.0 (latest: v1.6.0)
557+
",
558+
)
559+
.run();
560+
}
561+
562+
#[cargo_test]
563+
fn update_msrv_resolve() {
564+
Package::new("bar", "1.5.0")
565+
.rust_version("1.55.0")
566+
.file("src/lib.rs", "fn other_stuff() {}")
567+
.publish();
568+
Package::new("bar", "1.6.0")
569+
.rust_version("1.65.0")
570+
.file("src/lib.rs", "fn other_stuff() {}")
571+
.publish();
572+
573+
let p = project()
574+
.file(
575+
"Cargo.toml",
576+
r#"
577+
[package]
578+
name = "foo"
579+
version = "0.0.1"
580+
edition = "2015"
581+
authors = []
582+
rust-version = "1.60.0"
583+
[dependencies]
584+
bar = "1.0.0"
585+
"#,
586+
)
587+
.file("src/main.rs", "fn main(){}")
588+
.build();
589+
590+
p.cargo("update")
591+
.arg("-Zmsrv-policy")
592+
.masquerade_as_nightly_cargo(&["msrv-policy"])
593+
.with_stderr(
594+
"\
595+
[UPDATING] `dummy-registry` index
596+
[LOCKING] 2 packages
597+
[ADDING] bar v1.5.0 (latest: v1.6.0)
598+
",
599+
)
600+
.run();
601+
p.cargo("update --ignore-rust-version")
602+
.arg("-Zmsrv-policy")
603+
.masquerade_as_nightly_cargo(&["msrv-policy"])
604+
.with_status(1)
605+
.with_stderr(
606+
"\
607+
error: unexpected argument '--ignore-rust-version' found
608+
609+
tip: to pass '--ignore-rust-version' as a value, use '-- --ignore-rust-version'
610+
611+
Usage: cargo update [OPTIONS] [SPEC]...
612+
613+
For more information, try '--help'.
614+
",
615+
)
616+
.run();
617+
}
618+
507619
#[cargo_test]
508620
fn rust_version_older_than_edition() {
509621
project()

0 commit comments

Comments
 (0)