summaryrefslogtreecommitdiffstats
path: root/src/tools/cargo/tests/testsuite/cargo_targets.rs
blob: fcf2930193fa73a9cf4cabed3dfd1402d7a74cce (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
59
60
61
62
63
64
65
66
67
68
//! Tests specifically related to target handling (lib, bins, examples, tests, benches).

use cargo_test_support::project;

#[cargo_test]
fn warn_unmatched_target_filters() {
    let p = project()
        .file(
            "Cargo.toml",
            r#"
        [package]
        name = "foo"
        version = "0.1.0"

        [lib]
        test = false
        bench = false
        "#,
        )
        .file("src/lib.rs", r#"fn main() {}"#)
        .build();

    p.cargo("check --tests --bins --examples --benches")
        .with_stderr(
            "\
[WARNING] Target filters `bins`, `tests`, `examples`, `benches` specified, \
but no targets matched. This is a no-op
[FINISHED][..]
",
        )
        .run();
}

#[cargo_test]
fn reserved_windows_target_name() {
    let p = project()
        .file(
            "Cargo.toml",
            r#"
            [package]
            name = "foo"
            version = "0.1.0"

            [[bin]]
            name = "con"
            path = "src/main.rs"
            "#,
        )
        .file("src/main.rs", "fn main() {}")
        .build();

    if cfg!(windows) {
        p.cargo("check")
            .with_stderr(
                "\
[WARNING] binary target `con` is a reserved Windows filename, \
this target will not work on Windows platforms
[CHECKING] foo[..]
[FINISHED][..]
",
            )
            .run();
    } else {
        p.cargo("check")
            .with_stderr("[CHECKING] foo[..]\n[FINISHED][..]")
            .run();
    }
}