Skip to content

Commit b345e18

Browse files
committed
rustdoc: Coalesce some run_test args as one LangString arg
1 parent 6bda5b3 commit b345e18

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

src/librustdoc/doctest.rs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -293,14 +293,11 @@ fn run_test(
293293
crate_name: &str,
294294
line: usize,
295295
options: Options,
296-
should_panic: bool,
296+
mut lang_string: LangString,
297297
no_run: bool,
298-
as_test_harness: bool,
299298
runtool: Option<String>,
300299
runtool_args: Vec<String>,
301300
target: TargetTriple,
302-
compile_fail: bool,
303-
mut error_codes: Vec<String>,
304301
opts: &TestOptions,
305302
edition: Edition,
306303
outdir: DirState,
@@ -309,7 +306,7 @@ fn run_test(
309306
report_unused_externs: impl Fn(UnusedExterns),
310307
) -> Result<(), TestFailure> {
311308
let (test, line_offset, supports_color) =
312-
make_test(test, Some(crate_name), as_test_harness, opts, edition, Some(test_id));
309+
make_test(test, Some(crate_name), lang_string.test_harness, opts, edition, Some(test_id));
313310

314311
let output_file = outdir.path().join("rust_out");
315312

@@ -329,10 +326,10 @@ fn run_test(
329326
compiler.env("UNSTABLE_RUSTDOC_TEST_PATH", path);
330327
compiler.env("UNSTABLE_RUSTDOC_TEST_LINE", format!("{}", line as isize - line_offset as isize));
331328
compiler.arg("-o").arg(&output_file);
332-
if as_test_harness {
329+
if lang_string.test_harness {
333330
compiler.arg("--test");
334331
}
335-
if options.json_unused_externs && !compile_fail {
332+
if options.json_unused_externs && !lang_string.compile_fail {
336333
compiler.arg("--error-format=json");
337334
compiler.arg("--json").arg("unused-externs");
338335
compiler.arg("-Z").arg("unstable-options");
@@ -351,7 +348,7 @@ fn run_test(
351348
for debugging_option_str in &options.debugging_opts_strs {
352349
compiler.arg("-Z").arg(&debugging_option_str);
353350
}
354-
if no_run && !compile_fail && options.persist_doctests.is_none() {
351+
if no_run && !lang_string.compile_fail && options.persist_doctests.is_none() {
355352
compiler.arg("--emit=metadata");
356353
}
357354
compiler.arg("--target").arg(match target {
@@ -418,20 +415,20 @@ fn run_test(
418415

419416
let out = out_lines.join("\n");
420417
let _bomb = Bomb(&out);
421-
match (output.status.success(), compile_fail) {
418+
match (output.status.success(), lang_string.compile_fail) {
422419
(true, true) => {
423420
return Err(TestFailure::UnexpectedCompilePass);
424421
}
425422
(true, false) => {}
426423
(false, true) => {
427-
if !error_codes.is_empty() {
424+
if !lang_string.error_codes.is_empty() {
428425
// We used to check if the output contained "error[{}]: " but since we added the
429426
// colored output, we can't anymore because of the color escape characters before
430427
// the ":".
431-
error_codes.retain(|err| !out.contains(&format!("error[{}]", err)));
428+
lang_string.error_codes.retain(|err| !out.contains(&format!("error[{}]", err)));
432429

433-
if !error_codes.is_empty() {
434-
return Err(TestFailure::MissingErrorCodes(error_codes));
430+
if !lang_string.error_codes.is_empty() {
431+
return Err(TestFailure::MissingErrorCodes(lang_string.error_codes));
435432
}
436433
}
437434
}
@@ -470,9 +467,9 @@ fn run_test(
470467
match result {
471468
Err(e) => return Err(TestFailure::ExecutionError(e)),
472469
Ok(out) => {
473-
if should_panic && out.status.success() {
470+
if lang_string.should_panic && out.status.success() {
474471
return Err(TestFailure::UnexpectedRunPass);
475-
} else if !should_panic && !out.status.success() {
472+
} else if !lang_string.should_panic && !out.status.success() {
476473
return Err(TestFailure::ExecutionFailure(out));
477474
}
478475
}
@@ -966,14 +963,11 @@ impl Tester for Collector {
966963
&crate_name,
967964
line,
968965
options,
969-
config.should_panic,
966+
config,
970967
no_run,
971-
config.test_harness,
972968
runtool,
973969
runtool_args,
974970
target,
975-
config.compile_fail,
976-
config.error_codes,
977971
&opts,
978972
edition,
979973
outdir,

0 commit comments

Comments
 (0)