|
| 1 | +use run_make_support::rustc; |
| 2 | + |
| 3 | +fn main() { |
| 4 | + let unstable_print_requests = [ |
| 5 | + "all-target-specs-json", |
| 6 | + "check-cfg", |
| 7 | + "crate-root-lint-levels", |
| 8 | + "supported-crate-types", |
| 9 | + "target-spec-json", |
| 10 | + ]; |
| 11 | + let stable_print_requests = [ |
| 12 | + "calling-conventions", |
| 13 | + "cfg", |
| 14 | + "code-models", |
| 15 | + "crate-name", |
| 16 | + "deployment-target", |
| 17 | + "file-names", |
| 18 | + "host-tuple", |
| 19 | + "link-args", |
| 20 | + "native-static-libs", |
| 21 | + "relocation-models", |
| 22 | + "split-debuginfo", |
| 23 | + "stack-protector-strategies", |
| 24 | + "sysroot", |
| 25 | + "target-cpus", |
| 26 | + "target-features", |
| 27 | + "target-libdir", |
| 28 | + "target-list", |
| 29 | + "tls-models", |
| 30 | + ]; |
| 31 | + |
| 32 | + // For issue-138698 |
| 33 | + // Failed. In stable channel, only stable args are printed when an invalid arg is provided |
| 34 | + let output = rustc() |
| 35 | + .env("RUSTC_BOOTSTRAP", "-1") |
| 36 | + .cfg("force_stable") |
| 37 | + .print("xxx") |
| 38 | + .run_fail() |
| 39 | + .stderr_utf8(); |
| 40 | + for request in unstable_print_requests { |
| 41 | + assert!(!output.contains(request)); |
| 42 | + } |
| 43 | + |
| 44 | + // For issue-138698 |
| 45 | + // Failed. In unstable channel, all args are print when an invalid arg is provided |
| 46 | + let output = rustc().print("xxx").run_fail().stderr_utf8(); |
| 47 | + for request in unstable_print_requests { |
| 48 | + assert!(output.contains(request)); |
| 49 | + } |
| 50 | + |
| 51 | + // Other tests, for future improvements |
| 52 | + // Failed. In unstable channel, only stable args are print when a valid arg is provided |
| 53 | + let output = rustc() |
| 54 | + .print(unstable_print_requests[0]) |
| 55 | + .print(stable_print_requests[0]) |
| 56 | + .run_fail() |
| 57 | + .stderr_utf8(); |
| 58 | + assert!(output.contains( |
| 59 | + "error: the `-Z unstable-options` flag must also be \ |
| 60 | +passed to enable the `all-target-specs-json` print option" |
| 61 | + )); |
| 62 | + |
| 63 | + // Ok. In unstable channel, only unstable args are print |
| 64 | + // when a valid arg is provided with `-Z unstable-options` |
| 65 | + rustc() |
| 66 | + .arg("-Z") |
| 67 | + .arg("unstable-options") |
| 68 | + .print(unstable_print_requests[0]) |
| 69 | + .print(stable_print_requests[0]) |
| 70 | + .run(); |
| 71 | + |
| 72 | + // Failed. In stable channel, unstable args are reminded to add `-Z unstable-options` |
| 73 | + let output = rustc() |
| 74 | + .env("RUSTC_BOOTSTRAP", "-1") |
| 75 | + .cfg("force_stable") |
| 76 | + .print(unstable_print_requests[0]) |
| 77 | + .run_fail() |
| 78 | + .stderr_utf8(); |
| 79 | + assert!(output.contains( |
| 80 | + "error: the `-Z unstable-options` flag must also be passed to \ |
| 81 | +enable the `all-target-specs-json` print option" |
| 82 | + )); |
| 83 | + |
| 84 | + // Failed.In stable channel, unstable args are reminded to use a nightly compiler |
| 85 | + // when `-Z unstable-options` is provided |
| 86 | + let output = rustc() |
| 87 | + .env("RUSTC_BOOTSTRAP", "-1") |
| 88 | + .cfg("force_stable") |
| 89 | + .arg("-Z") |
| 90 | + .arg("unstable-options") |
| 91 | + .print(unstable_print_requests[0]) |
| 92 | + .print(stable_print_requests[0]) |
| 93 | + .run_fail() |
| 94 | + .stderr_utf8(); |
| 95 | + assert!(output.contains("error: the option `Z` is only accepted on the nightly compiler")); |
| 96 | +} |
0 commit comments