summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/tests/testsuite/advanced_env.rs
blob: 8aab528ead7356a47f34145cf06cdf54d325e049 (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
//! -Zadvanced-env tests

use cargo_test_support::{paths, project, registry::Package};

#[cargo_test]
fn source_config_env() {
    // Try to define [source] with environment variables.
    let p = project()
        .file(
            "Cargo.toml",
            r#"
            [package]
            name = "foo"
            version = "0.1.0"

            [dependencies]
            somedep = "1.0"
            "#,
        )
        .file("src/lib.rs", "")
        .build();

    Package::new("somedep", "1.0.0")
        .local(true)
        .file("src/lib.rs", "")
        .publish();

    let path = paths::root().join("registry");

    p.cargo("check -Zadvanced-env")
        .masquerade_as_nightly_cargo(&["advanced-env"])
        .env("CARGO_SOURCE_crates-io_REPLACE_WITH", "my-local-source")
        .env("CARGO_SOURCE_my-local-source_LOCAL_REGISTRY", path)
        .run();
}