Skip to content

Commit 12fa410

Browse files
committed
Rewrite and rename issue-26092 to rmake
1 parent 178c493 commit 12fa410

File tree

13 files changed

+54
-55
lines changed

13 files changed

+54
-55
lines changed

src/tools/run-make-support/src/command.rs

+16
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,12 @@ impl Command {
116116
output
117117
}
118118

119+
/// Run the constructed command and return its output no matter what.
120+
#[track_caller]
121+
pub fn run_unchecked(&mut self) -> CompletedProcess {
122+
self.command_output()
123+
}
124+
119125
#[track_caller]
120126
fn command_output(&mut self) -> CompletedProcess {
121127
self.drop_bomb.defuse();
@@ -167,25 +173,35 @@ impl CompletedProcess {
167173
self
168174
}
169175

176+
/// Checks that trimmed `stdout` does not contain trimmed `content`.
170177
#[track_caller]
171178
pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
172179
assert_not_contains(&self.stdout_utf8(), needle.as_ref());
173180
self
174181
}
175182

183+
/// Checks that trimmed `stdout` contains trimmed `content`.
184+
#[track_caller]
185+
pub fn assert_stdout_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
186+
assert!(self.stdout_utf8().contains(needle.as_ref()));
187+
self
188+
}
189+
176190
/// Checks that trimmed `stderr` matches trimmed `content`.
177191
#[track_caller]
178192
pub fn assert_stderr_equals<S: AsRef<str>>(&self, content: S) -> &Self {
179193
assert_eq!(self.stderr_utf8().trim(), content.as_ref().trim());
180194
self
181195
}
182196

197+
/// Checks that trimmed `stderr` contains trimmed `content`.
183198
#[track_caller]
184199
pub fn assert_stderr_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
185200
assert!(self.stderr_utf8().contains(needle.as_ref()));
186201
self
187202
}
188203

204+
/// Checks that trimmed `stderr` does not contain trimmed `content`.
189205
#[track_caller]
190206
pub fn assert_stderr_not_contains<S: AsRef<str>>(&self, needle: S) -> &Self {
191207
assert_not_contains(&self.stdout_utf8(), needle.as_ref());

src/tools/run-make-support/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,12 @@ macro_rules! impl_common_helpers {
409409
self.cmd.run_fail()
410410
}
411411

412+
/// Run the constructed command and return its output no matter what.
413+
#[track_caller]
414+
pub fn run_unchecked(&mut self) -> crate::command::CompletedProcess {
415+
self.cmd.run_unchecked()
416+
}
417+
412418
/// Set the path where the command will be run.
413419
pub fn current_dir<P: AsRef<::std::path::Path>>(&mut self, path: P) -> &mut Self {
414420
self.cmd.current_dir(path);

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ run-make/issue-20626/Makefile
8888
run-make/issue-22131/Makefile
8989
run-make/issue-25581/Makefile
9090
run-make/issue-26006/Makefile
91-
run-make/issue-26092/Makefile
9291
run-make/issue-28595/Makefile
9392
run-make/issue-33329/Makefile
9493
run-make/issue-35164/Makefile

tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ fn main() {
1212

1313
let output =
1414
rustc().input("main.rs").emit("metadata").extern_("stable", "libstable.rmeta").run();
15-
1615
let version = fs_wrapper::read_to_string(source_root().join("src/version"));
1716
let expected_string = format!("stable since {}", version.trim());
1817
output.assert_stderr_contains(expected_string);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// When an empty output file is passed to rustc, the ensuing error message
2+
// should be clear. However, calling file_stem on an empty path returns None,
3+
// which, when unwrapped, causes a panic, stopping execution of rustc
4+
// and printing an obscure message instead of reaching the helpful
5+
// error message. This test checks that the panic does not occur.
6+
// See https://github.com/rust-lang/rust/pull/26199
7+
8+
use run_make_support::rustc;
9+
10+
fn main() {
11+
let output = rustc().output("").input("blank.rs").run_fail();
12+
output.assert_stderr_not_contains("panic");
13+
}

tests/run-make/issue-26092/Makefile

-6
This file was deleted.

tests/run-make/link-arg/rmake.rs

+9-14
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,13 @@
77
use run_make_support::rustc;
88

99
fn main() {
10-
let output = String::from_utf8(
11-
rustc()
12-
.input("empty.rs")
13-
.link_arg("-lfoo")
14-
.link_arg("-lbar")
15-
.print("link-args")
16-
.command_output()
17-
.stdout,
18-
)
19-
.unwrap();
20-
assert!(
21-
output.contains("lfoo") || output.contains("lbar"),
22-
"The output did not contain the expected \"lfoo\" or \"lbar\" strings."
23-
);
10+
// The original Makefile test did not check if rustc succeeded or failed.
11+
let out = rustc()
12+
.input("empty.rs")
13+
.link_arg("-lfoo")
14+
.link_arg("-lbar")
15+
.print("link-args")
16+
.run_unchecked();
17+
out.assert_stdout_contains("lfoo");
18+
out.assert_stdout_contains("lbar");
2419
}

tests/run-make/link-dedup/Makefile

-12
This file was deleted.

tests/run-make/link-dedup/rmake.rs

+10-18
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,18 @@
77

88
//@ ignore-msvc
99

10+
use run_make_support::rustc;
11+
1012
fn main() {
1113
rustc().input("depa.rs").run();
1214
rustc().input("depb.rs").run();
1315
rustc().input("depc.rs").run();
14-
let output =
15-
String::from_utf8(rustc().input("empty.rs").cfg("bar").command_output().stderr).unwrap();
16-
let pos_a1 =
17-
output.find("-ltesta").expect("empty.rs, compiled with --cfg, should contain -ltesta");
18-
let pos_b = output[pos_a1..]
19-
.find("-ltestb")
20-
.map(|pos| pos + pos_a1)
21-
.expect("empty.rs, compiled with --cfg, should contain -ltestb");
22-
let _ = output[pos_b..]
23-
.find("-ltesta")
24-
.map(|pos| pos + pos_b)
25-
.expect("empty.rs, compiled with --cfg, should contain a second -ltesta");
26-
let output = String::from_utf8(rustc().input("empty.rs").command_output().stderr).unwrap();
27-
assert!(output.contains("-ltesta"));
28-
let output = String::from_utf8(rustc().input("empty.rs").command_output().stderr).unwrap();
29-
assert!(!output.contains("-ltestb"));
30-
let output = String::from_utf8(rustc().input("empty.rs").command_output().stderr).unwrap();
31-
assert_eq!(output.matches("-ltesta").count, 1);
16+
let output = rustc().input("empty.rs").cfg("bar").run_fail();
17+
output.assert_stderr_contains("\"-ltesta\" \"-ltestb\" \"-ltesta\"");
18+
let output = rustc().input("empty.rs").run_fail();
19+
output.assert_stderr_contains("\"-ltesta\"");
20+
let output = rustc().input("empty.rs").run_fail();
21+
output.assert_stderr_not_contains("\"-ltestb\"");
22+
let output = rustc().input("empty.rs").run_fail();
23+
output.assert_stderr_not_contains("\"-ltesta\" \"-ltesta\" \"-ltesta\"");
3224
}

tests/run-make/rustdoc-error-lines/rmake.rs

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use run_make_support::rustdoc;
55

66
fn main() {
77
let output = rustdoc().input("input.rs").arg("--test").run_fail().stdout_utf8();
8-
98
let should_contain = &[
109
"input.rs - foo (line 5)",
1110
"input.rs:7:15",

tests/run-make/rustdoc-scrape-examples-macros/rmake.rs

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ fn main() {
1616
.arg("-")
1717
.run()
1818
.stdout_utf8();
19-
2019
rustc()
2120
.input("src/proc.rs")
2221
.crate_name(proc_crate_name)

tests/run-make/rustdoc-shared-flags/rmake.rs

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use run_make_support::{rustc, rustdoc, Diff};
33
fn compare_outputs(args: &[&str]) {
44
let rustc_output = rustc().args(args).run().stdout_utf8();
55
let rustdoc_output = rustdoc().args(args).run().stdout_utf8();
6-
76
Diff::new().expected_text("rustc", rustc_output).actual_text("rustdoc", rustdoc_output).run();
87
}
98

0 commit comments

Comments
 (0)