Skip to content

Commit

Permalink
Unrolled build for rust-lang#126478
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#126478 - GuillaumeGomez:migrate-run-make-codegen-options-parsing, r=jieyouxu

Migrate `run-make/codegen-options-parsing` to `rmake.rs`

Part of rust-lang#121876.

r? `@jieyouxu`
  • Loading branch information
rust-timer authored Jun 15, 2024
2 parents 92af831 + 267ba9a commit c68a5d6
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 35 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ run-make/c-unwind-abi-catch-panic/Makefile
run-make/cat-and-grep-sanity-check/Makefile
run-make/cdylib-dylib-linkage/Makefile
run-make/cdylib-fewer-symbols/Makefile
run-make/codegen-options-parsing/Makefile
run-make/comment-section/Makefile
run-make/compiler-lookup-paths-2/Makefile
run-make/compiler-lookup-paths/Makefile
Expand Down
34 changes: 0 additions & 34 deletions tests/run-make/codegen-options-parsing/Makefile

This file was deleted.

56 changes: 56 additions & 0 deletions tests/run-make/codegen-options-parsing/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// This test intentionally feeds invalid inputs to codegen and checks if the error message outputs
// contain specific helpful indications.

//@ ignore-cross-compile

use run_make_support::regex::Regex;
use run_make_support::rustc;

fn main() {
// Option taking a number.
rustc()
.input("dummy.rs")
.arg("-Ccodegen-units")
.run_fail()
.assert_stderr_contains("codegen option `codegen-units` requires a number");
rustc().input("dummy.rs").arg("-Ccodegen-units=").run_fail().assert_stderr_contains(
"incorrect value `` for codegen option `codegen-units` - a number was expected",
);
rustc().input("dummy.rs").arg("-Ccodegen-units=foo").run_fail().assert_stderr_contains(
"incorrect value `foo` for codegen option `codegen-units` - a number was expected",
);
rustc().input("dummy.rs").arg("-Ccodegen-units=1").run();

// Option taking a string.
rustc()
.input("dummy.rs")
.arg("-Cextra-filename")
.run_fail()
.assert_stderr_contains("codegen option `extra-filename` requires a string");
rustc().input("dummy.rs").arg("-Cextra-filename=").run();
rustc().input("dummy.rs").arg("-Cextra-filename=foo").run();

// Option taking no argument.
rustc().input("dummy.rs").arg("-Clto=").run_fail().assert_stderr_contains(
"codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
`fat`, or omitted",
);
rustc().input("dummy.rs").arg("-Clto=1").run_fail().assert_stderr_contains(
"codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
`fat`, or omitted",
);
rustc().input("dummy.rs").arg("-Clto=foo").run_fail().assert_stderr_contains(
"codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
`fat`, or omitted",
);
rustc().input("dummy.rs").arg("-Clto").run();

let regex = Regex::new("--gc-sections|-z[^ ]* [^ ]*<ignore>|-dead_strip|/OPT:REF").unwrap();
// Should not link dead code...
let stdout = rustc().input("dummy.rs").print("link-args").run().stdout_utf8();
assert!(regex.is_match(&stdout));
// ... unless you specifically ask to keep it
let stdout =
rustc().input("dummy.rs").print("link-args").arg("-Clink-dead-code").run().stdout_utf8();
assert!(!regex.is_match(&stdout));
}

0 comments on commit c68a5d6

Please sign in to comment.