summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/tests/testsuite/version.rs
blob: 110e6100327ce64a0bca84aa7fc0a66a9d4f6c42 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Tests for displaying the cargo version.

use cargo_test_support::{cargo_process, project};

#[cargo_test]
fn simple() {
    let p = project().build();

    p.cargo("version")
        .with_stdout(&format!("cargo {}\n", cargo::version()))
        .run();

    p.cargo("--version")
        .with_stdout(&format!("cargo {}\n", cargo::version()))
        .run();

    p.cargo("-V")
        .with_stdout(&format!("cargo {}\n", cargo::version()))
        .run();
}

#[cargo_test]
fn version_works_without_rustc() {
    let p = project().build();
    p.cargo("version").env("PATH", "").run();
}

#[cargo_test]
fn version_works_with_bad_config() {
    let p = project().file(".cargo/config", "this is not toml").build();
    p.cargo("version").run();
}

#[cargo_test]
fn version_works_with_bad_target_dir() {
    let p = project()
        .file(
            ".cargo/config",
            r#"
                [build]
                target-dir = 4
            "#,
        )
        .build();
    p.cargo("version").run();
}

#[cargo_test]
fn verbose() {
    // This is mainly to check that it doesn't explode.
    cargo_process("-vV")
        .with_stdout_contains(&format!("cargo {}", cargo::version()))
        .with_stdout_contains("host: [..]")
        .with_stdout_contains("libgit2: [..]")
        .with_stdout_contains("libcurl: [..]")
        .with_stdout_contains("os: [..]")
        .run();
}