summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/tests/testsuite/minimal_versions.rs
blob: f814dcb70a6be8d7e9672481cc8d6c0ba1c0c7c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//! Tests for minimal-version resolution.
//!
//! Note: Some tests are located in the resolver-tests package.

use cargo_test_support::project;
use cargo_test_support::registry::Package;

// Ensure that the "-Z minimal-versions" CLI option works and the minimal
// version of a dependency ends up in the lock file.
#[cargo_test]
fn minimal_version_cli() {
    Package::new("dep", "1.0.0").publish();
    Package::new("dep", "1.1.0").publish();

    let p = project()
        .file(
            "Cargo.toml",
            r#"
                [package]
                name = "foo"
                authors = []
                version = "0.0.1"

                [dependencies]
                dep = "1.0"
            "#,
        )
        .file("src/main.rs", "fn main() {}")
        .build();

    p.cargo("generate-lockfile -Zminimal-versions")
        .masquerade_as_nightly_cargo(&["minimal-versions"])
        .run();

    let lock = p.read_lockfile();

    assert!(!lock.contains("1.1.0"));
}