]> git.proxmox.com Git - cargo.git/blame - tests/testsuite/update.rs
Update upstream source from tag 'upstream/0.66.0'
[cargo.git] / tests / testsuite / update.rs
CommitLineData
83571aee
EH
1//! Tests for the `cargo update` command.
2
9115b2c3
AC
3use cargo_test_support::registry::Package;
4use cargo_test_support::{basic_manifest, project};
51d23560 5
0e0d9688 6#[cargo_test]
51d23560
AC
7fn minor_update_two_places() {
8 Package::new("log", "0.1.0").publish();
7fe2fbc8 9 let p = project()
51d23560
AC
10 .file(
11 "Cargo.toml",
12 r#"
13 [package]
14 name = "bar"
15 version = "0.0.1"
16 authors = []
17
18 [dependencies]
19 log = "0.1"
20 foo = { path = "foo" }
21 "#,
fecb7246
AC
22 )
23 .file("src/lib.rs", "")
51d23560
AC
24 .file(
25 "foo/Cargo.toml",
26 r#"
27 [package]
28 name = "foo"
29 version = "0.0.1"
30 authors = []
31
32 [dependencies]
33 log = "0.1"
34 "#,
fecb7246
AC
35 )
36 .file("foo/src/lib.rs", "")
51d23560
AC
37 .build();
38
85984a87 39 p.cargo("build").run();
51d23560
AC
40 Package::new("log", "0.1.1").publish();
41
4ae79d2f
EH
42 p.change_file(
43 "foo/Cargo.toml",
44 r#"
45 [package]
46 name = "foo"
47 version = "0.0.1"
48 authors = []
51d23560 49
4ae79d2f
EH
50 [dependencies]
51 log = "0.1.1"
52 "#,
53 );
51d23560 54
85984a87 55 p.cargo("build").run();
51d23560
AC
56}
57
0e0d9688 58#[cargo_test]
51d23560
AC
59fn transitive_minor_update() {
60 Package::new("log", "0.1.0").publish();
61 Package::new("serde", "0.1.0").dep("log", "0.1").publish();
62
7fe2fbc8 63 let p = project()
51d23560
AC
64 .file(
65 "Cargo.toml",
66 r#"
67 [package]
68 name = "bar"
69 version = "0.0.1"
70 authors = []
71
72 [dependencies]
73 serde = "0.1"
74 log = "0.1"
75 foo = { path = "foo" }
76 "#,
fecb7246
AC
77 )
78 .file("src/lib.rs", "")
51d23560
AC
79 .file(
80 "foo/Cargo.toml",
81 r#"
82 [package]
83 name = "foo"
84 version = "0.0.1"
85 authors = []
86
87 [dependencies]
88 serde = "0.1"
89 "#,
fecb7246
AC
90 )
91 .file("foo/src/lib.rs", "")
51d23560
AC
92 .build();
93
85984a87 94 p.cargo("build").run();
51d23560
AC
95
96 Package::new("log", "0.1.1").publish();
97 Package::new("serde", "0.1.1").dep("log", "0.1.1").publish();
98
99 // Note that `serde` isn't actually updated here! The default behavior for
100 // `update` right now is to as conservatively as possible attempt to satisfy
101 // an update. In this case we previously locked the dependency graph to `log
102 // 0.1.0`, but nothing on the command line says we're allowed to update
103 // that. As a result the update of `serde` here shouldn't update to `serde
104 // 0.1.1` as that would also force an update to `log 0.1.1`.
105 //
106 // Also note that this is probably counterintuitive and weird. We may wish
107 // to change this one day.
85984a87
DW
108 p.cargo("update -p serde")
109 .with_stderr(
51d23560 110 "\
41aa6fba 111[UPDATING] `[..]` index
51d23560 112",
fecb7246
AC
113 )
114 .run();
51d23560
AC
115}
116
0e0d9688 117#[cargo_test]
51d23560
AC
118fn conservative() {
119 Package::new("log", "0.1.0").publish();
120 Package::new("serde", "0.1.0").dep("log", "0.1").publish();
121
7fe2fbc8 122 let p = project()
51d23560
AC
123 .file(
124 "Cargo.toml",
125 r#"
126 [package]
127 name = "bar"
128 version = "0.0.1"
129 authors = []
130
131 [dependencies]
132 serde = "0.1"
133 log = "0.1"
134 foo = { path = "foo" }
135 "#,
fecb7246
AC
136 )
137 .file("src/lib.rs", "")
51d23560
AC
138 .file(
139 "foo/Cargo.toml",
140 r#"
141 [package]
142 name = "foo"
143 version = "0.0.1"
144 authors = []
145
146 [dependencies]
147 serde = "0.1"
148 "#,
fecb7246
AC
149 )
150 .file("foo/src/lib.rs", "")
51d23560
AC
151 .build();
152
85984a87 153 p.cargo("build").run();
51d23560
AC
154
155 Package::new("log", "0.1.1").publish();
156 Package::new("serde", "0.1.1").dep("log", "0.1").publish();
157
85984a87
DW
158 p.cargo("update -p serde")
159 .with_stderr(
51d23560 160 "\
41aa6fba 161[UPDATING] `[..]` index
51d23560
AC
162[UPDATING] serde v0.1.0 -> v0.1.1
163",
fecb7246
AC
164 )
165 .run();
51d23560
AC
166}
167
0e0d9688 168#[cargo_test]
51d23560
AC
169fn update_via_new_dep() {
170 Package::new("log", "0.1.0").publish();
7fe2fbc8 171 let p = project()
51d23560
AC
172 .file(
173 "Cargo.toml",
174 r#"
175 [package]
176 name = "bar"
177 version = "0.0.1"
178 authors = []
179
180 [dependencies]
181 log = "0.1"
182 # foo = { path = "foo" }
183 "#,
fecb7246
AC
184 )
185 .file("src/lib.rs", "")
51d23560
AC
186 .file(
187 "foo/Cargo.toml",
188 r#"
189 [package]
190 name = "foo"
191 version = "0.0.1"
192 authors = []
193
194 [dependencies]
195 log = "0.1.1"
196 "#,
fecb7246
AC
197 )
198 .file("foo/src/lib.rs", "")
51d23560
AC
199 .build();
200
85984a87 201 p.cargo("build").run();
51d23560
AC
202 Package::new("log", "0.1.1").publish();
203
204 p.uncomment_root_manifest();
782266aa 205 p.cargo("build").env("CARGO_LOG", "cargo=trace").run();
51d23560
AC
206}
207
0e0d9688 208#[cargo_test]
51d23560
AC
209fn update_via_new_member() {
210 Package::new("log", "0.1.0").publish();
7fe2fbc8 211 let p = project()
51d23560
AC
212 .file(
213 "Cargo.toml",
214 r#"
215 [package]
216 name = "bar"
217 version = "0.0.1"
218 authors = []
219
220 [workspace]
221 # members = [ "foo" ]
222
223 [dependencies]
224 log = "0.1"
225 "#,
fecb7246
AC
226 )
227 .file("src/lib.rs", "")
51d23560
AC
228 .file(
229 "foo/Cargo.toml",
230 r#"
231 [package]
232 name = "foo"
233 version = "0.0.1"
234 authors = []
235
236 [dependencies]
237 log = "0.1.1"
238 "#,
fecb7246
AC
239 )
240 .file("foo/src/lib.rs", "")
51d23560
AC
241 .build();
242
85984a87 243 p.cargo("build").run();
51d23560
AC
244 Package::new("log", "0.1.1").publish();
245
246 p.uncomment_root_manifest();
85984a87 247 p.cargo("build").run();
51d23560
AC
248}
249
0e0d9688 250#[cargo_test]
51d23560
AC
251fn add_dep_deep_new_requirement() {
252 Package::new("log", "0.1.0").publish();
7fe2fbc8 253 let p = project()
51d23560
AC
254 .file(
255 "Cargo.toml",
256 r#"
257 [package]
258 name = "bar"
259 version = "0.0.1"
260 authors = []
261
262 [dependencies]
263 log = "0.1"
264 # bar = "0.1"
265 "#,
fecb7246
AC
266 )
267 .file("src/lib.rs", "")
51d23560
AC
268 .build();
269
85984a87 270 p.cargo("build").run();
51d23560
AC
271
272 Package::new("log", "0.1.1").publish();
273 Package::new("bar", "0.1.0").dep("log", "0.1.1").publish();
274
275 p.uncomment_root_manifest();
85984a87 276 p.cargo("build").run();
51d23560
AC
277}
278
0e0d9688 279#[cargo_test]
51d23560
AC
280fn everything_real_deep() {
281 Package::new("log", "0.1.0").publish();
282 Package::new("foo", "0.1.0").dep("log", "0.1").publish();
7fe2fbc8 283 let p = project()
51d23560
AC
284 .file(
285 "Cargo.toml",
286 r#"
287 [package]
288 name = "bar"
289 version = "0.0.1"
290 authors = []
291
292 [dependencies]
293 foo = "0.1"
294 # bar = "0.1"
295 "#,
fecb7246
AC
296 )
297 .file("src/lib.rs", "")
51d23560
AC
298 .build();
299
85984a87 300 p.cargo("build").run();
51d23560
AC
301
302 Package::new("log", "0.1.1").publish();
303 Package::new("bar", "0.1.0").dep("log", "0.1.1").publish();
304
305 p.uncomment_root_manifest();
85984a87 306 p.cargo("build").run();
51d23560 307}
0deaae9e 308
0e0d9688 309#[cargo_test]
0deaae9e 310fn change_package_version() {
7fe2fbc8 311 let p = project()
0deaae9e
AC
312 .file(
313 "Cargo.toml",
314 r#"
315 [package]
316 name = "a-foo"
317 version = "0.2.0-alpha"
318 authors = []
319
320 [dependencies]
321 bar = { path = "bar", version = "0.2.0-alpha" }
322 "#,
fecb7246
AC
323 )
324 .file("src/lib.rs", "")
ab19c483 325 .file("bar/Cargo.toml", &basic_manifest("bar", "0.2.0-alpha"))
0deaae9e
AC
326 .file("bar/src/lib.rs", "")
327 .file(
328 "Cargo.lock",
329 r#"
330 [[package]]
331 name = "foo"
332 version = "0.2.0"
333 dependencies = ["bar 0.2.0"]
334
335 [[package]]
336 name = "bar"
337 version = "0.2.0"
338 "#,
fecb7246
AC
339 )
340 .build();
0deaae9e 341
85984a87 342 p.cargo("build").run();
0deaae9e 343}
1a26e86c 344
0e0d9688 345#[cargo_test]
1a26e86c 346fn update_precise() {
1a26e86c 347 Package::new("serde", "0.1.0").publish();
348 Package::new("serde", "0.2.1").publish();
349
7fe2fbc8 350 let p = project()
1a26e86c 351 .file(
352 "Cargo.toml",
353 r#"
354 [package]
355 name = "bar"
356 version = "0.0.1"
357 authors = []
358
359 [dependencies]
360 serde = "0.2"
361 foo = { path = "foo" }
362 "#,
fecb7246
AC
363 )
364 .file("src/lib.rs", "")
1a26e86c 365 .file(
366 "foo/Cargo.toml",
367 r#"
368 [package]
369 name = "foo"
370 version = "0.0.1"
371 authors = []
372
373 [dependencies]
374 serde = "0.1"
375 "#,
fecb7246
AC
376 )
377 .file("foo/src/lib.rs", "")
1a26e86c 378 .build();
379
85984a87 380 p.cargo("build").run();
1a26e86c 381
382 Package::new("serde", "0.2.0").publish();
383
85984a87
DW
384 p.cargo("update -p serde:0.2.1 --precise 0.2.0")
385 .with_stderr(
1a26e86c 386 "\
41aa6fba 387[UPDATING] `[..]` index
1a26e86c 388[UPDATING] serde v0.2.1 -> v0.2.0
389",
fecb7246
AC
390 )
391 .run();
1a26e86c 392}
851e20b2 393
64e39919 394#[cargo_test]
395fn update_precise_do_not_force_update_deps() {
396 Package::new("log", "0.1.0").publish();
397 Package::new("serde", "0.2.1").dep("log", "0.1").publish();
398
399 let p = project()
400 .file(
401 "Cargo.toml",
402 r#"
403 [package]
404 name = "bar"
405 version = "0.0.1"
406 authors = []
407
408 [dependencies]
409 serde = "0.2"
410 "#,
411 )
412 .file("src/lib.rs", "")
413 .build();
414
415 p.cargo("build").run();
416
417 Package::new("log", "0.1.1").publish();
418 Package::new("serde", "0.2.2").dep("log", "0.1").publish();
419
420 p.cargo("update -p serde:0.2.1 --precise 0.2.2")
421 .with_stderr(
422 "\
423[UPDATING] `[..]` index
424[UPDATING] serde v0.2.1 -> v0.2.2
425",
426 )
427 .run();
428}
429
f95deaaf 430#[cargo_test]
431fn update_precise_without_package() {
432 Package::new("serde", "0.2.0").publish();
433
434 let p = project()
435 .file(
436 "Cargo.toml",
437 r#"
438 [package]
439 name = "bar"
440 version = "0.0.1"
441 authors = []
442
443 [dependencies]
444 serde = "0.2"
445 "#,
446 )
447 .file("src/lib.rs", "")
448 .build();
449
450 p.cargo("build").run();
451
452 Package::new("serde", "0.2.1").publish();
453 Package::new("serde", "0.3.0").publish();
454
455 p.cargo("update --precise 0.3.0")
456 .with_stderr(
457 "\
458[WARNING] precise is only supported with \"--package <SPEC>\", this will become a hard error in a future release.
459[UPDATING] `[..]` index
460[UPDATING] serde v0.2.0 -> v0.2.1
a58489df 461",
462 )
463 .run();
464}
465
f0b5bdad 466#[cargo_test]
467fn update_aggressive() {
468 Package::new("log", "0.1.0").publish();
469 Package::new("serde", "0.2.1").dep("log", "0.1").publish();
470
471 let p = project()
472 .file(
473 "Cargo.toml",
474 r#"
475 [package]
476 name = "bar"
477 version = "0.0.1"
478 authors = []
479
480 [dependencies]
481 serde = "0.2"
482 "#,
483 )
484 .file("src/lib.rs", "")
485 .build();
486
487 p.cargo("build").run();
488
489 Package::new("log", "0.1.1").publish();
490 Package::new("serde", "0.2.2").dep("log", "0.1").publish();
491
492 p.cargo("update -p serde:0.2.1 --aggressive")
493 .with_stderr(
494 "\
495[UPDATING] `[..]` index
496[UPDATING] log v0.1.0 -> v0.1.1
497[UPDATING] serde v0.2.1 -> v0.2.2
498",
499 )
500 .run();
501}
502
a58489df 503#[cargo_test]
504fn update_aggressive_without_package() {
505 Package::new("serde", "0.2.0").publish();
506
507 let p = project()
508 .file(
509 "Cargo.toml",
510 r#"
511 [package]
512 name = "bar"
513 version = "0.0.1"
514 authors = []
515
516 [dependencies]
517 serde = "0.2"
518 "#,
519 )
520 .file("src/lib.rs", "")
521 .build();
522
523 p.cargo("build").run();
524
525 Package::new("serde", "0.2.1").publish();
526
527 p.cargo("update --aggressive")
528 .with_stderr(
529 "\
530[WARNING] aggressive is only supported with \"--package <SPEC>\", this will become a hard error in a future release.
531[UPDATING] `[..]` index
532[UPDATING] serde v0.2.0 -> v0.2.1
f95deaaf 533",
534 )
535 .run();
536}
537
f299d1c1
AH
538// cargo update should respect its arguments even without a lockfile.
539// See issue "Running cargo update without a Cargo.lock ignores arguments"
540// at <https://github.com/rust-lang/cargo/issues/6872>.
0e0d9688 541#[cargo_test]
f299d1c1
AH
542fn update_precise_first_run() {
543 Package::new("serde", "0.1.0").publish();
544 Package::new("serde", "0.2.0").publish();
545 Package::new("serde", "0.2.1").publish();
546
547 let p = project()
548 .file(
549 "Cargo.toml",
550 r#"
551 [package]
552 name = "bar"
553 version = "0.0.1"
554
555 [dependencies]
556 serde = "0.2"
557 "#,
558 )
559 .file("src/lib.rs", "")
560 .build();
561
562 p.cargo("update -p serde --precise 0.2.0")
563 .with_stderr(
564 "\
565[UPDATING] `[..]` index
1bcf7f11 566[UPDATING] serde v0.2.1 -> v0.2.0
f299d1c1
AH
567",
568 )
569 .run();
570
571 // Assert `cargo metadata` shows serde 0.2.0
572 p.cargo("metadata")
573 .with_json(
574 r#"{
575 "packages": [
576 {
577 "authors": [],
578 "categories": [],
f9a56257 579 "default_run": null,
58869e5c
AS
580 "dependencies": [
581 {
582 "features": [],
583 "kind": null,
584 "name": "serde",
585 "optional": false,
586 "registry": null,
587 "rename": null,
588 "req": "^0.2",
589 "source": "registry+https://github.com/rust-lang/crates.io-index",
590 "target": null,
591 "uses_default_features": true
592 }
593 ],
f299d1c1 594 "description": null,
72694e80 595 "documentation": null,
f299d1c1
AH
596 "edition": "2015",
597 "features": {},
72694e80 598 "homepage": null,
58869e5c 599 "id": "bar 0.0.1 (path+file://[..]/foo)",
f299d1c1
AH
600 "keywords": [],
601 "license": null,
602 "license_file": null,
603 "links": null,
58869e5c 604 "manifest_path": "[..]/foo/Cargo.toml",
f299d1c1 605 "metadata": null,
7d41d454 606 "publish": null,
58869e5c 607 "name": "bar",
f299d1c1
AH
608 "readme": null,
609 "repository": null,
390af271 610 "rust_version": null,
58869e5c 611 "source": null,
f299d1c1
AH
612 "targets": [
613 {
614 "crate_types": [
615 "lib"
616 ],
e831dd12 617 "doc": true,
e1d433d3 618 "doctest": true,
95b22d28 619 "test": true,
f299d1c1
AH
620 "edition": "2015",
621 "kind": [
622 "lib"
623 ],
58869e5c
AS
624 "name": "bar",
625 "src_path": "[..]/foo/src/lib.rs"
f299d1c1
AH
626 }
627 ],
58869e5c 628 "version": "0.0.1"
f299d1c1
AH
629 },
630 {
631 "authors": [],
632 "categories": [],
f9a56257 633 "default_run": null,
58869e5c 634 "dependencies": [],
f299d1c1 635 "description": null,
72694e80 636 "documentation": null,
f299d1c1
AH
637 "edition": "2015",
638 "features": {},
72694e80 639 "homepage": null,
58869e5c 640 "id": "serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
f299d1c1
AH
641 "keywords": [],
642 "license": null,
643 "license_file": null,
644 "links": null,
58869e5c 645 "manifest_path": "[..]/home/.cargo/registry/src/-[..]/serde-0.2.0/Cargo.toml",
f299d1c1 646 "metadata": null,
7d41d454 647 "publish": null,
58869e5c 648 "name": "serde",
f299d1c1
AH
649 "readme": null,
650 "repository": null,
390af271 651 "rust_version": null,
58869e5c 652 "source": "registry+https://github.com/rust-lang/crates.io-index",
f299d1c1
AH
653 "targets": [
654 {
655 "crate_types": [
656 "lib"
657 ],
e831dd12 658 "doc": true,
e1d433d3 659 "doctest": true,
f299d1c1
AH
660 "edition": "2015",
661 "kind": [
662 "lib"
663 ],
58869e5c 664 "name": "serde",
95b22d28
OS
665 "src_path": "[..]/home/.cargo/registry/src/-[..]/serde-0.2.0/src/lib.rs",
666 "test": true
f299d1c1
AH
667 }
668 ],
58869e5c 669 "version": "0.2.0"
f299d1c1
AH
670 }
671 ],
672 "resolve": {
673 "nodes": [
674 {
675 "dependencies": [
676 "serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)"
677 ],
678 "deps": [
679 {
a7faecc3
EH
680 "dep_kinds": [
681 {
682 "kind": null,
683 "target": null
684 }
685 ],
f299d1c1
AH
686 "name": "serde",
687 "pkg": "serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)"
688 }
689 ],
690 "features": [],
691 "id": "bar 0.0.1 (path+file://[..]/foo)"
692 },
693 {
694 "dependencies": [],
695 "deps": [],
696 "features": [],
697 "id": "serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)"
698 }
699 ],
700 "root": "bar 0.0.1 (path+file://[..]/foo)"
701 },
702 "target_directory": "[..]/foo/target",
703 "version": 1,
704 "workspace_members": [
705 "bar 0.0.1 (path+file://[..]/foo)"
706 ],
866d4316
BC
707 "workspace_root": "[..]/foo",
708 "metadata": null
f299d1c1
AH
709}"#,
710 )
711 .run();
712
713 p.cargo("update -p serde --precise 0.2.0")
714 .with_stderr(
715 "\
716[UPDATING] `[..]` index
717",
718 )
719 .run();
f299d1c1
AH
720}
721
0e0d9688 722#[cargo_test]
851e20b2
DW
723fn preserve_top_comment() {
724 let p = project().file("src/lib.rs", "").build();
725
726 p.cargo("update").run();
727
bd0e4a08
DW
728 let lockfile = p.read_lockfile();
729 assert!(lockfile.starts_with("# This file is automatically @generated by Cargo.\n# It is not intended for manual editing.\n"));
730
731 let mut lines = lockfile.lines().collect::<Vec<_>>();
732 lines.insert(2, "# some other comment");
733 let mut lockfile = lines.join("\n");
e58c544f 734 lockfile.push('\n'); // .lines/.join loses the last newline
851e20b2
DW
735 println!("saving Cargo.lock contents:\n{}", lockfile);
736
737 p.change_file("Cargo.lock", &lockfile);
738
739 p.cargo("update").run();
740
bd0e4a08 741 let lockfile2 = p.read_lockfile();
851e20b2
DW
742 println!("loaded Cargo.lock contents:\n{}", lockfile2);
743
bd0e4a08 744 assert_eq!(lockfile, lockfile2);
851e20b2 745}
7be09e3c 746
0e0d9688 747#[cargo_test]
7be09e3c
AK
748fn dry_run_update() {
749 Package::new("log", "0.1.0").publish();
750 Package::new("serde", "0.1.0").dep("log", "0.1").publish();
751
752 let p = project()
753 .file(
754 "Cargo.toml",
755 r#"
756 [package]
757 name = "bar"
758 version = "0.0.1"
759 authors = []
760
761 [dependencies]
762 serde = "0.1"
763 log = "0.1"
764 foo = { path = "foo" }
765 "#,
766 )
767 .file("src/lib.rs", "")
768 .file(
769 "foo/Cargo.toml",
770 r#"
771 [package]
772 name = "foo"
773 version = "0.0.1"
774 authors = []
775
776 [dependencies]
777 serde = "0.1"
778 "#,
779 )
780 .file("foo/src/lib.rs", "")
781 .build();
782
783 p.cargo("build").run();
4ae79d2f 784 let old_lockfile = p.read_lockfile();
7be09e3c
AK
785
786 Package::new("log", "0.1.1").publish();
787 Package::new("serde", "0.1.1").dep("log", "0.1").publish();
788
789 p.cargo("update -p serde --dry-run")
790 .with_stderr(
791 "\
792[UPDATING] `[..]` index
793[UPDATING] serde v0.1.0 -> v0.1.1
794[WARNING] not updating lockfile due to dry run
795",
796 )
797 .run();
4ae79d2f 798 let new_lockfile = p.read_lockfile();
7be09e3c
AK
799 assert_eq!(old_lockfile, new_lockfile)
800}
9589d2cb
CO
801
802#[cargo_test]
803fn workspace_only() {
804 let p = project().file("src/main.rs", "fn main() {}").build();
805 p.cargo("generate-lockfile").run();
806 let lock1 = p.read_lockfile();
807
808 p.change_file(
809 "Cargo.toml",
810 r#"
811 [package]
812 name = "foo"
813 authors = []
814 version = "0.0.2"
815 "#,
816 );
817 p.cargo("update --workspace").run();
818 let lock2 = p.read_lockfile();
819
820 assert_ne!(lock1, lock2);
821 assert!(lock1.contains("0.0.1"));
822 assert!(lock2.contains("0.0.2"));
823 assert!(!lock1.contains("0.0.2"));
824 assert!(!lock2.contains("0.0.1"));
825}
8fe3bde2
EH
826
827#[cargo_test]
828fn precise_with_build_metadata() {
829 // +foo syntax shouldn't be necessary with --precise
830 Package::new("bar", "0.1.0+extra-stuff.0").publish();
831 let p = project()
832 .file(
833 "Cargo.toml",
834 r#"
835 [package]
836 name = "foo"
837 version = "0.1.0"
838
839 [dependencies]
840 bar = "0.1"
841 "#,
842 )
843 .file("src/lib.rs", "")
844 .build();
845 p.cargo("generate-lockfile").run();
846 Package::new("bar", "0.1.1+extra-stuff.1").publish();
847 Package::new("bar", "0.1.2+extra-stuff.2").publish();
848
849 p.cargo("update -p bar --precise 0.1")
850 .with_status(101)
851 .with_stderr(
852 "\
853error: invalid version format for precise version `0.1`
854
855Caused by:
856 unexpected end of input while parsing minor version number
857",
858 )
859 .run();
860
861 p.cargo("update -p bar --precise 0.1.1+does-not-match")
862 .with_status(101)
863 .with_stderr(
864 "\
865[UPDATING] [..] index
866error: no matching package named `bar` found
867location searched: registry `crates-io`
868required by package `foo v0.1.0 ([ROOT]/foo)`
869",
870 )
871 .run();
872
873 p.cargo("update -p bar --precise 0.1.1")
874 .with_stderr(
875 "\
876[UPDATING] [..] index
877[UPDATING] bar v0.1.0+extra-stuff.0 -> v0.1.1+extra-stuff.1
878",
879 )
880 .run();
881
882 Package::new("bar", "0.1.3").publish();
883 p.cargo("update -p bar --precise 0.1.3+foo")
884 .with_status(101)
885 .with_stderr(
886 "\
887[UPDATING] [..] index
888error: no matching package named `bar` found
889location searched: registry `crates-io`
890required by package `foo v0.1.0 ([ROOT]/foo)`
891",
892 )
893 .run();
894
895 p.cargo("update -p bar --precise 0.1.3")
896 .with_stderr(
897 "\
898[UPDATING] [..] index
899[UPDATING] bar v0.1.1+extra-stuff.1 -> v0.1.3
900",
901 )
902 .run();
903}