Migrate run-make/doctests-runtool to rmake

This commit is contained in:
Guillaume Gomez 2024-05-04 16:18:36 +02:00
parent a56ba918d2
commit 3c2cf2e50b
3 changed files with 39 additions and 21 deletions

View File

@ -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

View File

@ -1,20 +0,0 @@
# ignore-cross-compile
include ../tools.mk
# Tests behavior of rustdoc --runtool
MY_SRC_DIR := ${CURDIR}
all: with_test_run_directory
# Behavior with --runtool with relative paths and --test-run-directory.
with_test_run_directory:
mkdir -p $(TMPDIR)/rundir
mkdir -p $(TMPDIR)/runtool
$(RUSTC) --crate-type rlib t.rs
$(RUSTC) runtool.rs -o $(TMPDIR)/runtool/runtool
( cd $(TMPDIR); \
$(RUSTDOC) -Zunstable-options --test --test-run-directory rundir \
--runtool runtool/runtool --extern t=libt.rlib $(MY_SRC_DIR)/t.rs \
)
rm -rf $(TMPDIR)/rundir $(TMPDIR)/runtool

View File

@ -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);
}