Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1f076c2

Browse files
authoredJun 15, 2024
Rollup merge of #126478 - GuillaumeGomez:migrate-run-make-codegen-options-parsing, r=jieyouxu
Migrate `run-make/codegen-options-parsing` to `rmake.rs` Part of #121876. r? `@jieyouxu`
2 parents be1d427 + 267ba9a commit 1f076c2

File tree

3 files changed

+56
-35
lines changed

3 files changed

+56
-35
lines changed
 

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ run-make/c-unwind-abi-catch-panic/Makefile
1111
run-make/cat-and-grep-sanity-check/Makefile
1212
run-make/cdylib-dylib-linkage/Makefile
1313
run-make/cdylib-fewer-symbols/Makefile
14-
run-make/codegen-options-parsing/Makefile
1514
run-make/comment-section/Makefile
1615
run-make/compiler-lookup-paths-2/Makefile
1716
run-make/compiler-lookup-paths/Makefile

‎tests/run-make/codegen-options-parsing/Makefile

-34
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
// This test intentionally feeds invalid inputs to codegen and checks if the error message outputs
2+
// contain specific helpful indications.
3+
4+
//@ ignore-cross-compile
5+
6+
use run_make_support::regex::Regex;
7+
use run_make_support::rustc;
8+
9+
fn main() {
10+
// Option taking a number.
11+
rustc()
12+
.input("dummy.rs")
13+
.arg("-Ccodegen-units")
14+
.run_fail()
15+
.assert_stderr_contains("codegen option `codegen-units` requires a number");
16+
rustc().input("dummy.rs").arg("-Ccodegen-units=").run_fail().assert_stderr_contains(
17+
"incorrect value `` for codegen option `codegen-units` - a number was expected",
18+
);
19+
rustc().input("dummy.rs").arg("-Ccodegen-units=foo").run_fail().assert_stderr_contains(
20+
"incorrect value `foo` for codegen option `codegen-units` - a number was expected",
21+
);
22+
rustc().input("dummy.rs").arg("-Ccodegen-units=1").run();
23+
24+
// Option taking a string.
25+
rustc()
26+
.input("dummy.rs")
27+
.arg("-Cextra-filename")
28+
.run_fail()
29+
.assert_stderr_contains("codegen option `extra-filename` requires a string");
30+
rustc().input("dummy.rs").arg("-Cextra-filename=").run();
31+
rustc().input("dummy.rs").arg("-Cextra-filename=foo").run();
32+
33+
// Option taking no argument.
34+
rustc().input("dummy.rs").arg("-Clto=").run_fail().assert_stderr_contains(
35+
"codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
36+
`fat`, or omitted",
37+
);
38+
rustc().input("dummy.rs").arg("-Clto=1").run_fail().assert_stderr_contains(
39+
"codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
40+
`fat`, or omitted",
41+
);
42+
rustc().input("dummy.rs").arg("-Clto=foo").run_fail().assert_stderr_contains(
43+
"codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, \
44+
`fat`, or omitted",
45+
);
46+
rustc().input("dummy.rs").arg("-Clto").run();
47+
48+
let regex = Regex::new("--gc-sections|-z[^ ]* [^ ]*<ignore>|-dead_strip|/OPT:REF").unwrap();
49+
// Should not link dead code...
50+
let stdout = rustc().input("dummy.rs").print("link-args").run().stdout_utf8();
51+
assert!(regex.is_match(&stdout));
52+
// ... unless you specifically ask to keep it
53+
let stdout =
54+
rustc().input("dummy.rs").print("link-args").arg("-Clink-dead-code").run().stdout_utf8();
55+
assert!(!regex.is_match(&stdout));
56+
}

0 commit comments

Comments
 (0)
Failed to load comments.