|
1 | 1 | //! Tests for the `cargo vendor` command.
|
| 2 | +//! |
| 3 | +//! Note that every test here uses `--respect-source-config` so that the |
| 4 | +//! "fake" crates.io is used. Otherwise `vendor` would download the crates.io |
| 5 | +//! index from the network. |
2 | 6 |
|
3 | 7 | use cargo_test_support::git;
|
4 | 8 | use cargo_test_support::registry::Package;
|
@@ -584,3 +588,46 @@ fn ignore_hidden() {
|
584 | 588 | .iter()
|
585 | 589 | .all(|status| status.status() == git2::Status::CURRENT));
|
586 | 590 | }
|
| 591 | + |
| 592 | +#[cargo_test] |
| 593 | +fn config_instructions_works() { |
| 594 | + // Check that the config instructions work for all dependency kinds. |
| 595 | + Package::new("dep", "0.1.0").publish(); |
| 596 | + Package::new("altdep", "0.1.0").alternative(true).publish(); |
| 597 | + let git_project = git::new("gitdep", |project| { |
| 598 | + project |
| 599 | + .file("Cargo.toml", &basic_lib_manifest("gitdep")) |
| 600 | + .file("src/lib.rs", "") |
| 601 | + }); |
| 602 | + let p = project() |
| 603 | + .file( |
| 604 | + "Cargo.toml", |
| 605 | + &format!( |
| 606 | + r#" |
| 607 | + [package] |
| 608 | + name = "foo" |
| 609 | + version = "0.1.0" |
| 610 | +
|
| 611 | + [dependencies] |
| 612 | + dep = "0.1" |
| 613 | + altdep = {{version="0.1", registry="alternative"}} |
| 614 | + gitdep = {{git='{}'}} |
| 615 | + "#, |
| 616 | + git_project.url() |
| 617 | + ), |
| 618 | + ) |
| 619 | + .file("src/lib.rs", "") |
| 620 | + .build(); |
| 621 | + let output = p |
| 622 | + .cargo("vendor --respect-source-config") |
| 623 | + .exec_with_output() |
| 624 | + .unwrap(); |
| 625 | + let output = String::from_utf8(output.stdout).unwrap(); |
| 626 | + p.change_file(".cargo/config", &output); |
| 627 | + |
| 628 | + p.cargo("check -v") |
| 629 | + .with_stderr_contains("[..]foo/vendor/dep/src/lib.rs[..]") |
| 630 | + .with_stderr_contains("[..]foo/vendor/altdep/src/lib.rs[..]") |
| 631 | + .with_stderr_contains("[..]foo/vendor/gitdep/src/lib.rs[..]") |
| 632 | + .run(); |
| 633 | +} |
0 commit comments