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 cf683e9

Browse files
committedJun 14, 2024
Migrate run-make/codegen-options-parsing to rmake.rs
1 parent d2ad293 commit cf683e9

File tree

3 files changed

+47
-35
lines changed

3 files changed

+47
-35
lines changed
 

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

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ run-make/c-unwind-abi-catch-panic/Makefile
1212
run-make/cat-and-grep-sanity-check/Makefile
1313
run-make/cdylib-dylib-linkage/Makefile
1414
run-make/cdylib-fewer-symbols/Makefile
15-
run-make/codegen-options-parsing/Makefile
1615
run-make/comment-section/Makefile
1716
run-make/compiler-lookup-paths-2/Makefile
1817
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,47 @@
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("codegen option `lto` - either a boolean (`yes`, `no`, `on`, `off`, etc), `thin`, `fat`, or omitted");
35+
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");
36+
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");
37+
rustc().input("dummy.rs").arg("-Clto").run();
38+
39+
let regex = Regex::new("--gc-sections|-z[^ ]* [^ ]*<ignore>|-dead_strip|/OPT:REF").unwrap();
40+
// Should not link dead code...
41+
let stdout = rustc().input("dummy.rs").print("link-args").run().stdout_utf8();
42+
assert!(regex.is_match(&stdout));
43+
// ... unless you specifically ask to keep it
44+
let stdout =
45+
rustc().input("dummy.rs").print("link-args").arg("-Clink-dead-code").run().stdout_utf8();
46+
assert!(!regex.is_match(&stdout));
47+
}

0 commit comments

Comments
 (0)
Failed to load comments.