]> git.proxmox.com Git - cargo.git/blame - tests/testsuite/update.rs
Add test for aggressive update
[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() {
347 Package::new("log", "0.1.0").publish();
348 Package::new("serde", "0.1.0").publish();
349 Package::new("serde", "0.2.1").publish();
350
7fe2fbc8 351 let p = project()
1a26e86c 352 .file(
353 "Cargo.toml",
354 r#"
355 [package]
356 name = "bar"
357 version = "0.0.1"
358 authors = []
359
360 [dependencies]
361 serde = "0.2"
362 foo = { path = "foo" }
363 "#,
fecb7246
AC
364 )
365 .file("src/lib.rs", "")
1a26e86c 366 .file(
367 "foo/Cargo.toml",
368 r#"
369 [package]
370 name = "foo"
371 version = "0.0.1"
372 authors = []
373
374 [dependencies]
375 serde = "0.1"
376 "#,
fecb7246
AC
377 )
378 .file("foo/src/lib.rs", "")
1a26e86c 379 .build();
380
85984a87 381 p.cargo("build").run();
1a26e86c 382
383 Package::new("serde", "0.2.0").publish();
384
85984a87
DW
385 p.cargo("update -p serde:0.2.1 --precise 0.2.0")
386 .with_stderr(
1a26e86c 387 "\
41aa6fba 388[UPDATING] `[..]` index
1a26e86c 389[UPDATING] serde v0.2.1 -> v0.2.0
390",
fecb7246
AC
391 )
392 .run();
1a26e86c 393}
851e20b2 394
f95deaaf 395#[cargo_test]
396fn update_precise_without_package() {
397 Package::new("serde", "0.2.0").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("serde", "0.2.1").publish();
418 Package::new("serde", "0.3.0").publish();
419
420 p.cargo("update --precise 0.3.0")
421 .with_stderr(
422 "\
423[WARNING] precise is only supported with \"--package <SPEC>\", this will become a hard error in a future release.
424[UPDATING] `[..]` index
425[UPDATING] serde v0.2.0 -> v0.2.1
a58489df 426",
427 )
428 .run();
429}
430
f0b5bdad 431#[cargo_test]
432fn update_aggressive() {
433 Package::new("log", "0.1.0").publish();
434 Package::new("serde", "0.2.1").dep("log", "0.1").publish();
435
436 let p = project()
437 .file(
438 "Cargo.toml",
439 r#"
440 [package]
441 name = "bar"
442 version = "0.0.1"
443 authors = []
444
445 [dependencies]
446 serde = "0.2"
447 "#,
448 )
449 .file("src/lib.rs", "")
450 .build();
451
452 p.cargo("build").run();
453
454 Package::new("log", "0.1.1").publish();
455 Package::new("serde", "0.2.2").dep("log", "0.1").publish();
456
457 p.cargo("update -p serde:0.2.1 --aggressive")
458 .with_stderr(
459 "\
460[UPDATING] `[..]` index
461[UPDATING] log v0.1.0 -> v0.1.1
462[UPDATING] serde v0.2.1 -> v0.2.2
463",
464 )
465 .run();
466}
467
a58489df 468#[cargo_test]
469fn update_aggressive_without_package() {
470 Package::new("serde", "0.2.0").publish();
471
472 let p = project()
473 .file(
474 "Cargo.toml",
475 r#"
476 [package]
477 name = "bar"
478 version = "0.0.1"
479 authors = []
480
481 [dependencies]
482 serde = "0.2"
483 "#,
484 )
485 .file("src/lib.rs", "")
486 .build();
487
488 p.cargo("build").run();
489
490 Package::new("serde", "0.2.1").publish();
491
492 p.cargo("update --aggressive")
493 .with_stderr(
494 "\
495[WARNING] aggressive is only supported with \"--package <SPEC>\", this will become a hard error in a future release.
496[UPDATING] `[..]` index
497[UPDATING] serde v0.2.0 -> v0.2.1
f95deaaf 498",
499 )
500 .run();
501}
502
f299d1c1
AH
503// cargo update should respect its arguments even without a lockfile.
504// See issue "Running cargo update without a Cargo.lock ignores arguments"
505// at <https://github.com/rust-lang/cargo/issues/6872>.
0e0d9688 506#[cargo_test]
f299d1c1
AH
507fn update_precise_first_run() {
508 Package::new("serde", "0.1.0").publish();
509 Package::new("serde", "0.2.0").publish();
510 Package::new("serde", "0.2.1").publish();
511
512 let p = project()
513 .file(
514 "Cargo.toml",
515 r#"
516 [package]
517 name = "bar"
518 version = "0.0.1"
519
520 [dependencies]
521 serde = "0.2"
522 "#,
523 )
524 .file("src/lib.rs", "")
525 .build();
526
527 p.cargo("update -p serde --precise 0.2.0")
528 .with_stderr(
529 "\
530[UPDATING] `[..]` index
1bcf7f11 531[UPDATING] serde v0.2.1 -> v0.2.0
f299d1c1
AH
532",
533 )
534 .run();
535
536 // Assert `cargo metadata` shows serde 0.2.0
537 p.cargo("metadata")
538 .with_json(
539 r#"{
540 "packages": [
541 {
542 "authors": [],
543 "categories": [],
f9a56257 544 "default_run": null,
58869e5c
AS
545 "dependencies": [
546 {
547 "features": [],
548 "kind": null,
549 "name": "serde",
550 "optional": false,
551 "registry": null,
552 "rename": null,
553 "req": "^0.2",
554 "source": "registry+https://github.com/rust-lang/crates.io-index",
555 "target": null,
556 "uses_default_features": true
557 }
558 ],
f299d1c1 559 "description": null,
72694e80 560 "documentation": null,
f299d1c1
AH
561 "edition": "2015",
562 "features": {},
72694e80 563 "homepage": null,
58869e5c 564 "id": "bar 0.0.1 (path+file://[..]/foo)",
f299d1c1
AH
565 "keywords": [],
566 "license": null,
567 "license_file": null,
568 "links": null,
58869e5c 569 "manifest_path": "[..]/foo/Cargo.toml",
f299d1c1 570 "metadata": null,
7d41d454 571 "publish": null,
58869e5c 572 "name": "bar",
f299d1c1
AH
573 "readme": null,
574 "repository": null,
390af271 575 "rust_version": null,
58869e5c 576 "source": null,
f299d1c1
AH
577 "targets": [
578 {
579 "crate_types": [
580 "lib"
581 ],
e831dd12 582 "doc": true,
e1d433d3 583 "doctest": true,
95b22d28 584 "test": true,
f299d1c1
AH
585 "edition": "2015",
586 "kind": [
587 "lib"
588 ],
58869e5c
AS
589 "name": "bar",
590 "src_path": "[..]/foo/src/lib.rs"
f299d1c1
AH
591 }
592 ],
58869e5c 593 "version": "0.0.1"
f299d1c1
AH
594 },
595 {
596 "authors": [],
597 "categories": [],
f9a56257 598 "default_run": null,
58869e5c 599 "dependencies": [],
f299d1c1 600 "description": null,
72694e80 601 "documentation": null,
f299d1c1
AH
602 "edition": "2015",
603 "features": {},
72694e80 604 "homepage": null,
58869e5c 605 "id": "serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
f299d1c1
AH
606 "keywords": [],
607 "license": null,
608 "license_file": null,
609 "links": null,
58869e5c 610 "manifest_path": "[..]/home/.cargo/registry/src/-[..]/serde-0.2.0/Cargo.toml",
f299d1c1 611 "metadata": null,
7d41d454 612 "publish": null,
58869e5c 613 "name": "serde",
f299d1c1
AH
614 "readme": null,
615 "repository": null,
390af271 616 "rust_version": null,
58869e5c 617 "source": "registry+https://github.com/rust-lang/crates.io-index",
f299d1c1
AH
618 "targets": [
619 {
620 "crate_types": [
621 "lib"
622 ],
e831dd12 623 "doc": true,
e1d433d3 624 "doctest": true,
f299d1c1
AH
625 "edition": "2015",
626 "kind": [
627 "lib"
628 ],
58869e5c 629 "name": "serde",
95b22d28
OS
630 "src_path": "[..]/home/.cargo/registry/src/-[..]/serde-0.2.0/src/lib.rs",
631 "test": true
f299d1c1
AH
632 }
633 ],
58869e5c 634 "version": "0.2.0"
f299d1c1
AH
635 }
636 ],
637 "resolve": {
638 "nodes": [
639 {
640 "dependencies": [
641 "serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)"
642 ],
643 "deps": [
644 {
a7faecc3
EH
645 "dep_kinds": [
646 {
647 "kind": null,
648 "target": null
649 }
650 ],
f299d1c1
AH
651 "name": "serde",
652 "pkg": "serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)"
653 }
654 ],
655 "features": [],
656 "id": "bar 0.0.1 (path+file://[..]/foo)"
657 },
658 {
659 "dependencies": [],
660 "deps": [],
661 "features": [],
662 "id": "serde 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)"
663 }
664 ],
665 "root": "bar 0.0.1 (path+file://[..]/foo)"
666 },
667 "target_directory": "[..]/foo/target",
668 "version": 1,
669 "workspace_members": [
670 "bar 0.0.1 (path+file://[..]/foo)"
671 ],
866d4316
BC
672 "workspace_root": "[..]/foo",
673 "metadata": null
f299d1c1
AH
674}"#,
675 )
676 .run();
677
678 p.cargo("update -p serde --precise 0.2.0")
679 .with_stderr(
680 "\
681[UPDATING] `[..]` index
682",
683 )
684 .run();
f299d1c1
AH
685}
686
0e0d9688 687#[cargo_test]
851e20b2
DW
688fn preserve_top_comment() {
689 let p = project().file("src/lib.rs", "").build();
690
691 p.cargo("update").run();
692
bd0e4a08
DW
693 let lockfile = p.read_lockfile();
694 assert!(lockfile.starts_with("# This file is automatically @generated by Cargo.\n# It is not intended for manual editing.\n"));
695
696 let mut lines = lockfile.lines().collect::<Vec<_>>();
697 lines.insert(2, "# some other comment");
698 let mut lockfile = lines.join("\n");
e58c544f 699 lockfile.push('\n'); // .lines/.join loses the last newline
851e20b2
DW
700 println!("saving Cargo.lock contents:\n{}", lockfile);
701
702 p.change_file("Cargo.lock", &lockfile);
703
704 p.cargo("update").run();
705
bd0e4a08 706 let lockfile2 = p.read_lockfile();
851e20b2
DW
707 println!("loaded Cargo.lock contents:\n{}", lockfile2);
708
bd0e4a08 709 assert_eq!(lockfile, lockfile2);
851e20b2 710}
7be09e3c 711
0e0d9688 712#[cargo_test]
7be09e3c
AK
713fn dry_run_update() {
714 Package::new("log", "0.1.0").publish();
715 Package::new("serde", "0.1.0").dep("log", "0.1").publish();
716
717 let p = project()
718 .file(
719 "Cargo.toml",
720 r#"
721 [package]
722 name = "bar"
723 version = "0.0.1"
724 authors = []
725
726 [dependencies]
727 serde = "0.1"
728 log = "0.1"
729 foo = { path = "foo" }
730 "#,
731 )
732 .file("src/lib.rs", "")
733 .file(
734 "foo/Cargo.toml",
735 r#"
736 [package]
737 name = "foo"
738 version = "0.0.1"
739 authors = []
740
741 [dependencies]
742 serde = "0.1"
743 "#,
744 )
745 .file("foo/src/lib.rs", "")
746 .build();
747
748 p.cargo("build").run();
4ae79d2f 749 let old_lockfile = p.read_lockfile();
7be09e3c
AK
750
751 Package::new("log", "0.1.1").publish();
752 Package::new("serde", "0.1.1").dep("log", "0.1").publish();
753
754 p.cargo("update -p serde --dry-run")
755 .with_stderr(
756 "\
757[UPDATING] `[..]` index
758[UPDATING] serde v0.1.0 -> v0.1.1
759[WARNING] not updating lockfile due to dry run
760",
761 )
762 .run();
4ae79d2f 763 let new_lockfile = p.read_lockfile();
7be09e3c
AK
764 assert_eq!(old_lockfile, new_lockfile)
765}
9589d2cb
CO
766
767#[cargo_test]
768fn workspace_only() {
769 let p = project().file("src/main.rs", "fn main() {}").build();
770 p.cargo("generate-lockfile").run();
771 let lock1 = p.read_lockfile();
772
773 p.change_file(
774 "Cargo.toml",
775 r#"
776 [package]
777 name = "foo"
778 authors = []
779 version = "0.0.2"
780 "#,
781 );
782 p.cargo("update --workspace").run();
783 let lock2 = p.read_lockfile();
784
785 assert_ne!(lock1, lock2);
786 assert!(lock1.contains("0.0.1"));
787 assert!(lock2.contains("0.0.2"));
788 assert!(!lock1.contains("0.0.2"));
789 assert!(!lock2.contains("0.0.1"));
790}
8fe3bde2
EH
791
792#[cargo_test]
793fn precise_with_build_metadata() {
794 // +foo syntax shouldn't be necessary with --precise
795 Package::new("bar", "0.1.0+extra-stuff.0").publish();
796 let p = project()
797 .file(
798 "Cargo.toml",
799 r#"
800 [package]
801 name = "foo"
802 version = "0.1.0"
803
804 [dependencies]
805 bar = "0.1"
806 "#,
807 )
808 .file("src/lib.rs", "")
809 .build();
810 p.cargo("generate-lockfile").run();
811 Package::new("bar", "0.1.1+extra-stuff.1").publish();
812 Package::new("bar", "0.1.2+extra-stuff.2").publish();
813
814 p.cargo("update -p bar --precise 0.1")
815 .with_status(101)
816 .with_stderr(
817 "\
818error: invalid version format for precise version `0.1`
819
820Caused by:
821 unexpected end of input while parsing minor version number
822",
823 )
824 .run();
825
826 p.cargo("update -p bar --precise 0.1.1+does-not-match")
827 .with_status(101)
828 .with_stderr(
829 "\
830[UPDATING] [..] index
831error: no matching package named `bar` found
832location searched: registry `crates-io`
833required by package `foo v0.1.0 ([ROOT]/foo)`
834",
835 )
836 .run();
837
838 p.cargo("update -p bar --precise 0.1.1")
839 .with_stderr(
840 "\
841[UPDATING] [..] index
842[UPDATING] bar v0.1.0+extra-stuff.0 -> v0.1.1+extra-stuff.1
843",
844 )
845 .run();
846
847 Package::new("bar", "0.1.3").publish();
848 p.cargo("update -p bar --precise 0.1.3+foo")
849 .with_status(101)
850 .with_stderr(
851 "\
852[UPDATING] [..] index
853error: no matching package named `bar` found
854location searched: registry `crates-io`
855required by package `foo v0.1.0 ([ROOT]/foo)`
856",
857 )
858 .run();
859
860 p.cargo("update -p bar --precise 0.1.3")
861 .with_stderr(
862 "\
863[UPDATING] [..] index
864[UPDATING] bar v0.1.1+extra-stuff.1 -> v0.1.3
865",
866 )
867 .run();
868}