|
| 1 | +// This test is to check if the warning is emitted when no space |
| 2 | +// between `-o` and arg is applied, see issue #142812 |
| 3 | +use run_make_support::rustc; |
| 4 | + |
| 5 | +fn main() { |
| 6 | + // test fake args |
| 7 | + rustc() |
| 8 | + .input("main.rs") |
| 9 | + .arg("-optimize") |
| 10 | + .run() |
| 11 | + .assert_stderr_contains( |
| 12 | + "warning: option `-o` has no space between flag name and value, which can be confusing", |
| 13 | + ) |
| 14 | + .assert_stderr_contains( |
| 15 | + "note: output filename `-o ptimize` is applied instead of a flag named `optimize`", |
| 16 | + ); |
| 17 | + rustc() |
| 18 | + .input("main.rs") |
| 19 | + .arg("-o0") |
| 20 | + .run() |
| 21 | + .assert_stderr_contains( |
| 22 | + "warning: option `-o` has no space between flag name and value, which can be confusing", |
| 23 | + ) |
| 24 | + .assert_stderr_contains( |
| 25 | + "note: output filename `-o 0` is applied instead of a flag named `o0`", |
| 26 | + ); |
| 27 | + rustc().input("main.rs").arg("-o1").run(); |
| 28 | + // test real args by iter optgroups |
| 29 | + rustc() |
| 30 | + .input("main.rs") |
| 31 | + .arg("-out-dir") |
| 32 | + .run() |
| 33 | + .assert_stderr_contains( |
| 34 | + "warning: option `-o` has no space between flag name and value, which can be confusing", |
| 35 | + ) |
| 36 | + .assert_stderr_contains( |
| 37 | + "note: output filename `-o ut-dir` is applied instead of a flag named `out-dir`", |
| 38 | + ) |
| 39 | + .assert_stderr_contains( |
| 40 | + "help: insert a space between `-o` and `ut-dir` if this is intentional: `-o ut-dir`", |
| 41 | + ); |
| 42 | + // test real args by iter CG_OPTIONS |
| 43 | + rustc() |
| 44 | + .input("main.rs") |
| 45 | + .arg("-opt_level") |
| 46 | + .run() |
| 47 | + .assert_stderr_contains( |
| 48 | + "warning: option `-o` has no space between flag name and value, which can be confusing", |
| 49 | + ) |
| 50 | + .assert_stderr_contains( |
| 51 | + "note: output filename `-o pt_level` is applied instead of a flag named `opt_level`", |
| 52 | + ) |
| 53 | + .assert_stderr_contains( |
| 54 | + "help: insert a space between `-o` and `pt_level` if this is intentional: `-o pt_level`" |
| 55 | + ); |
| 56 | + // separater in-sensitive |
| 57 | + rustc() |
| 58 | + .input("main.rs") |
| 59 | + .arg("-opt-level") |
| 60 | + .run() |
| 61 | + .assert_stderr_contains( |
| 62 | + "warning: option `-o` has no space between flag name and value, which can be confusing", |
| 63 | + ) |
| 64 | + .assert_stderr_contains( |
| 65 | + "note: output filename `-o pt-level` is applied instead of a flag named `opt-level`", |
| 66 | + ) |
| 67 | + .assert_stderr_contains( |
| 68 | + "help: insert a space between `-o` and `pt-level` if this is intentional: `-o pt-level`" |
| 69 | + ); |
| 70 | + rustc() |
| 71 | + .input("main.rs") |
| 72 | + .arg("-overflow-checks") |
| 73 | + .run() |
| 74 | + .assert_stderr_contains( |
| 75 | + "warning: option `-o` has no space between flag name and value, which can be confusing", |
| 76 | + ) |
| 77 | + .assert_stderr_contains( |
| 78 | + "note: output filename `-o verflow-checks` \ |
| 79 | + is applied instead of a flag named `overflow-checks`", |
| 80 | + ) |
| 81 | + .assert_stderr_contains( |
| 82 | + "help: insert a space between `-o` and `verflow-checks` \ |
| 83 | + if this is intentional: `-o verflow-checks`", |
| 84 | + ); |
| 85 | + |
| 86 | + // No warning for Z_OPTIONS |
| 87 | + rustc().input("main.rs").arg("-oom").run().assert_stderr_equals(""); |
| 88 | + |
| 89 | + // test no warning when there is space between `-o` and arg |
| 90 | + rustc().input("main.rs").arg("-o").arg("ptimize").run().assert_stderr_equals(""); |
| 91 | + rustc().input("main.rs").arg("--out-dir").arg("xxx").run().assert_stderr_equals(""); |
| 92 | + rustc().input("main.rs").arg("-o").arg("out-dir").run().assert_stderr_equals(""); |
| 93 | +} |
0 commit comments