about summary refs log tree commit diff
path: root/tests/run-make/option-output-no-space/rmake.rs
blob: 2c42f15aa89a6abf6a19e4c7a433f4ceaa02aad1 (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
// This test is to check if the warning is emitted when no space
// between `-o` and arg is applied, see issue #142812

//@ ignore-cross-compile
use run_make_support::rustc;

fn main() {
    // test fake args
    rustc()
        .input("main.rs")
        .arg("-optimize")
        .run()
        .assert_stderr_contains(
            "warning: option `-o` has no space between flag name and value, which can be confusing",
        )
        .assert_stderr_contains(
            "note: output filename `-o ptimize` is applied instead of a flag named `optimize`",
        );
    rustc()
        .input("main.rs")
        .arg("-o0")
        .run()
        .assert_stderr_contains(
            "warning: option `-o` has no space between flag name and value, which can be confusing",
        )
        .assert_stderr_contains(
            "note: output filename `-o 0` is applied instead of a flag named `o0`",
        );
    rustc().input("main.rs").arg("-o1").run();
    // test real args by iter optgroups
    rustc()
        .input("main.rs")
        .arg("-out-dir")
        .run()
        .assert_stderr_contains(
            "warning: option `-o` has no space between flag name and value, which can be confusing",
        )
        .assert_stderr_contains(
            "note: output filename `-o ut-dir` is applied instead of a flag named `out-dir`",
        )
        .assert_stderr_contains(
            "help: insert a space between `-o` and `ut-dir` if this is intentional: `-o ut-dir`",
        );
    // test real args by iter CG_OPTIONS
    rustc()
        .input("main.rs")
        .arg("-opt_level")
        .run()
        .assert_stderr_contains(
            "warning: option `-o` has no space between flag name and value, which can be confusing",
        )
        .assert_stderr_contains(
            "note: output filename `-o pt_level` is applied instead of a flag named `opt_level`",
        )
        .assert_stderr_contains(
            "help: insert a space between `-o` and `pt_level` if this is intentional: `-o pt_level`"
        );
    // separater in-sensitive
    rustc()
        .input("main.rs")
        .arg("-opt-level")
        .run()
        .assert_stderr_contains(
            "warning: option `-o` has no space between flag name and value, which can be confusing",
        )
        .assert_stderr_contains(
            "note: output filename `-o pt-level` is applied instead of a flag named `opt-level`",
        )
        .assert_stderr_contains(
            "help: insert a space between `-o` and `pt-level` if this is intentional: `-o pt-level`"
        );
    rustc()
        .input("main.rs")
        .arg("-overflow-checks")
        .run()
        .assert_stderr_contains(
            "warning: option `-o` has no space between flag name and value, which can be confusing",
        )
        .assert_stderr_contains(
            "note: output filename `-o verflow-checks` \
            is applied instead of a flag named `overflow-checks`",
        )
        .assert_stderr_contains(
            "help: insert a space between `-o` and `verflow-checks` \
            if this is intentional: `-o verflow-checks`",
        );

    // No warning for Z_OPTIONS
    rustc().input("main.rs").arg("-oom").run().assert_stderr_equals("");

    // test no warning when there is space between `-o` and arg
    rustc().input("main.rs").arg("-o").arg("ptimize").run().assert_stderr_equals("");
    rustc().input("main.rs").arg("--out-dir").arg("xxx").run().assert_stderr_equals("");
    rustc().input("main.rs").arg("-o").arg("out-dir").run().assert_stderr_equals("");
}