Skip to content

Commit

Permalink
Auto merge of rust-lang#124711 - GuillaumeGomez:migrate-doctests-runt…
Browse files Browse the repository at this point in the history
…ool, r=jieyouxu

Migrate `run-make/doctests-runtool` to rmake

Part of rust-lang#121876.

The first commit is making the `edition` method common to `Rustc` and `Rustdoc` as I'll need it for the doctest in rust-lang#123974.

r? `@jieyouxu`
  • Loading branch information
bors committed May 5, 2024
2 parents 3fbeedb + a64ba04 commit 2e0982d
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 21 deletions.
7 changes: 7 additions & 0 deletions src/tools/run-make-support/src/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,13 @@ impl Rustdoc {
}
}

/// Specify the edition year.
pub fn edition(&mut self, edition: &str) -> &mut Self {
self.cmd.arg("--edition");
self.cmd.arg(edition);
self
}

#[track_caller]
pub fn run_fail_assert_exit_code(&mut self, code: i32) -> Output {
let caller_location = std::panic::Location::caller();
Expand Down
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 @@ -44,7 +44,6 @@ run-make/dep-graph/Makefile
run-make/dep-info-doesnt-run-much/Makefile
run-make/dep-info-spaces/Makefile
run-make/dep-info/Makefile
run-make/doctests-runtool/Makefile
run-make/dump-ice-to-disk/Makefile
run-make/dump-mono-stats/Makefile
run-make/duplicate-output-flavors/Makefile
Expand Down
20 changes: 0 additions & 20 deletions tests/run-make/doctests-runtool/Makefile

This file was deleted.

39 changes: 39 additions & 0 deletions tests/run-make/doctests-runtool/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Tests behavior of rustdoc `--runtool`.

use run_make_support::{rustc, rustdoc, tmp_dir};
use std::env::current_dir;
use std::fs::{create_dir, remove_dir_all};
use std::path::PathBuf;

fn mkdir(name: &str) -> PathBuf {
let dir = tmp_dir().join(name);
create_dir(&dir).expect("failed to create doctests folder");
dir
}

// Behavior with --runtool with relative paths and --test-run-directory.
fn main() {
let run_dir_name = "rundir";
let run_dir = mkdir(run_dir_name);
let run_tool = mkdir("runtool");
let run_tool_binary = run_tool.join("runtool");

rustc().input("t.rs").crate_type("rlib").run();
rustc().input("runtool.rs").arg("-o").arg(&run_tool_binary).run();

rustdoc()
.input(current_dir().unwrap().join("t.rs"))
.arg("-Zunstable-options")
.arg("--test")
.arg("--test-run-directory")
.arg(run_dir_name)
.arg("--runtool")
.arg(&run_tool_binary)
.arg("--extern")
.arg("t=libt.rlib")
.current_dir(tmp_dir())
.run();

remove_dir_all(run_dir);
remove_dir_all(run_tool);
}

0 comments on commit 2e0982d

Please sign in to comment.