Remove all usages of `tmp_dir` from tests

This commit is contained in:
Jakub Beránek 2024-06-06 21:34:34 +02:00
parent 94ccb9b34d
commit d86c981908
No known key found for this signature in database
GPG Key ID: 909CD0D26483516B
64 changed files with 182 additions and 210 deletions

View File

@ -1,9 +1,7 @@
use std::path::Path;
use std::process::Command;
use crate::{
bin_name, cygpath_windows, env_var, handle_failed_output, is_msvc, is_windows, tmp_dir, uname,
};
use crate::{bin_name, cygpath_windows, env_var, handle_failed_output, is_msvc, is_windows, uname};
/// Construct a new platform-specific C compiler invocation.
///

View File

@ -1,7 +1,7 @@
use std::path::Path;
use std::process::Command;
use crate::{bin_name, env_var, handle_failed_output, tmp_dir};
use crate::{bin_name, env_var, handle_failed_output};
/// Construct a new `clang` invocation. `clang` is not always available for all targets.
pub fn clang() -> Clang {

View File

@ -171,6 +171,11 @@ pub fn bin_name(name: &str) -> String {
if is_windows() { format!("{name}.exe") } else { name.to_string() }
}
/// Return the current working directory.
pub fn cwd() -> PathBuf {
env::current_dir().unwrap()
}
/// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is
/// available on the platform!
#[track_caller]

View File

@ -10,11 +10,11 @@ use run_make_support::{aux_build, rustc};
fn main() {
aux_build().input("stable.rs").emit("metadata").run();
let mut stable_path = PathBuf::from(env!("TMPDIR"));
stable_path.push("libstable.rmeta");
let output =
rustc().input("main.rs").emit("metadata").extern_("stable", &stable_path).command_output();
let output = rustc()
.input("main.rs")
.emit("metadata")
.extern_("stable", "libstable.rmeta")
.command_output();
let stderr = String::from_utf8_lossy(&output.stderr);
let version = include_str!(concat!(env!("S"), "/src/version"));

View File

@ -5,17 +5,15 @@
//
// Fixes: rust-lang/rust#123234
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn main() {
let inc_dir = tmp_dir();
for _ in 0..=1 {
rustc()
.input("lib.rs")
.crate_type("lib")
.emit("asm,dep-info,link,mir,llvm-ir,llvm-bc")
.incremental(&inc_dir)
.incremental("incremental")
.run();
}
}

View File

@ -7,17 +7,15 @@
// Also see discussion at
// <https://internals.rust-lang.org/t/interaction-between-incremental-compilation-and-emit/20551>
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn main() {
let inc_dir = tmp_dir();
for _ in 0..=1 {
rustc()
.input("lib.rs")
.crate_type("lib")
.emit("obj,asm,dep-info,link,mir,llvm-ir,llvm-bc")
.incremental(&inc_dir)
.incremental("incremental")
.run();
}
}

View File

@ -5,9 +5,9 @@
// This test checks that this bug does not resurface.
// See https://github.com/rust-lang/rust/issues/28766
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn main() {
rustc().opt().input("foo.rs").run();
rustc().opt().library_search_path(tmp_dir()).input("main.rs").run();
rustc().opt().input("main.rs").run();
}

View File

@ -5,29 +5,23 @@
use std::fs::remove_file;
use run_make_support::{
cc, dynamic_lib_extension, is_msvc, read_dir, run, run_fail, rustc, tmp_dir,
};
use run_make_support::{cc, cwd, dynamic_lib_extension, is_msvc, read_dir, run, run_fail, rustc};
fn main() {
rustc().input("foo.rs").run();
if is_msvc() {
let lib = tmp_dir().join("foo.dll.lib");
let lib = "foo.dll.lib";
cc().input("bar.c").arg(lib).out_exe("bar").run();
} else {
cc().input("bar.c")
.arg("-lfoo")
.output(tmp_dir().join("bar"))
.library_search_path(tmp_dir())
.run();
cc().input("bar.c").arg("-lfoo").output("bar").library_search_path(cwd()).run();
}
run("bar");
let expected_extension = dynamic_lib_extension();
read_dir(tmp_dir(), |path| {
read_dir(std::env::current_dir().unwrap(), |path| {
if path.is_file()
&& path.extension().is_some_and(|ext| ext == expected_extension)
&& path.file_name().and_then(|name| name.to_str()).is_some_and(|name| {

View File

@ -12,20 +12,16 @@
use std::fs::remove_file;
use run_make_support::{cc, dynamic_lib, is_msvc, run, rustc, tmp_dir};
use run_make_support::{cc, cwd, dynamic_lib, is_msvc, run, rustc};
fn main() {
rustc().input("bar.rs").run();
rustc().input("foo.rs").run();
if is_msvc() {
cc().input("foo.c").arg(tmp_dir().join("foo.dll.lib")).out_exe("foo").run();
cc().input("foo.c").arg("foo.dll.lib").out_exe("foo").run();
} else {
cc().input("foo.c")
.arg("-lfoo")
.output(tmp_dir().join("foo"))
.library_search_path(tmp_dir())
.run();
cc().input("foo.c").arg("-lfoo").library_search_path(cwd()).output("foo").run();
}
run("foo");

View File

@ -0,0 +1,7 @@
[package]
name = "scratch"
version = "0.1.0"
edition = "2021"
[lib]
path = "lib.rs"

View File

@ -0,0 +1 @@
#![no_std]

View File

@ -20,29 +20,17 @@ use run_make_support::object::ObjectSection;
use run_make_support::object::ObjectSymbol;
use run_make_support::object::RelocationTarget;
use run_make_support::set_host_rpath;
use run_make_support::tmp_dir;
use run_make_support::{env_var, object};
use std::collections::HashSet;
const MANIFEST: &str = r#"
[package]
name = "scratch"
version = "0.1.0"
edition = "2021"
[lib]
path = "lib.rs""#;
use std::path::PathBuf;
fn main() {
let target_dir = tmp_dir().join("target");
let target_dir = PathBuf::from("target");
let target = env_var("TARGET");
println!("Testing compiler_builtins for {}", target);
// Set up the tiniest Cargo project: An empty no_std library. Just enough to run -Zbuild-std.
let manifest_path = tmp_dir().join("Cargo.toml");
std::fs::write(&manifest_path, MANIFEST.as_bytes()).unwrap();
std::fs::write(tmp_dir().join("lib.rs"), b"#![no_std]").unwrap();
let manifest_path = PathBuf::from("Cargo.toml");
let path = env_var("PATH");
let rustc = env_var("RUSTC");

View File

@ -2,12 +2,12 @@
use std::fs;
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn main() {
rustc().input("input.rs").run_fail_assert_exit_code(1);
for entry in fs::read_dir(tmp_dir()).unwrap() {
for entry in fs::read_dir(std::env::current_dir().unwrap()).unwrap() {
let entry = entry.unwrap();
let path = entry.path();

View File

@ -2,7 +2,7 @@
// when the no_global_oom_handling feature is turned on.
// See https://github.com/rust-lang/rust/pull/110649
use run_make_support::{rustc, source_root, tmp_dir};
use run_make_support::{rustc, source_root};
fn main() {
rustc()
@ -10,7 +10,7 @@ fn main() {
.arg("-Dwarnings")
.crate_type("rlib")
.input(source_root().join("library/core/src/lib.rs"))
.sysroot(tmp_dir().join("fakeroot"))
.sysroot("fakeroot")
.cfg("no_global_oom_handling")
.run();
}

View File

@ -3,7 +3,7 @@
//@ needs-matching-clang
//@ needs-llvm-components riscv
use run_make_support::{bin_name, clang, llvm_readobj, rustc, tmp_dir};
use run_make_support::{bin_name, clang, llvm_readobj, rustc};
use std::{
env,
path::PathBuf,
@ -30,11 +30,11 @@ fn check_target(target: &str, clang_target: &str, carch: &str, is_double_float:
.no_stdlib()
.out_exe("riscv-xlto")
.input("cstart.c")
.input(tmp_dir().join("libriscv_xlto.rlib"))
.input("libriscv_xlto.rlib")
.run();
// Check that the built binary has correct float abi
let executable = tmp_dir().join(bin_name("riscv-xlto"));
let executable = bin_name("riscv-xlto");
let output = llvm_readobj().input(&executable).file_header().run();
let stdout = String::from_utf8_lossy(&output.stdout);
eprintln!("obj:\n{}", stdout);

View File

@ -7,10 +7,10 @@
//@ ignore-cross-compile
use run_make_support::{rustc, rustdoc, tmp_dir};
use run_make_support::{cwd, rustc, rustdoc};
fn main() {
rustc().input("foo.rs").run();
rustc().input("bar.rs").run();
rustdoc().input("baz.rs").library_search_path(tmp_dir()).output(tmp_dir()).run();
rustdoc().input("baz.rs").library_search_path(cwd()).output(cwd()).run();
}

View File

@ -1,15 +1,15 @@
// Check that valid binaries are persisted by running them, regardless of whether the
// --run or --no-run option is used.
use run_make_support::{run, rustc, rustdoc, tmp_dir};
use run_make_support::{run, rustc, rustdoc};
use std::fs::{create_dir, remove_dir_all};
use std::path::Path;
fn setup_test_env<F: FnOnce(&Path, &Path)>(callback: F) {
let out_dir = tmp_dir().join("doctests");
let out_dir = Path::new("doctests");
create_dir(&out_dir).expect("failed to create doctests folder");
rustc().input("t.rs").crate_type("rlib").run();
callback(&out_dir, &tmp_dir().join("libt.rlib"));
callback(&out_dir, Path::new("libt.rlib"));
remove_dir_all(out_dir);
}
@ -44,19 +44,17 @@ fn main() {
});
// Behavior with --test-run-directory with relative paths.
setup_test_env(|_out_dir, extern_path| {
let run_dir = "rundir";
let run_dir_path = tmp_dir().join("rundir");
let run_dir_path = Path::new("rundir");
create_dir(&run_dir_path).expect("failed to create rundir folder");
rustdoc()
.current_dir(tmp_dir())
.input(std::env::current_dir().unwrap().join("t.rs"))
.input("t.rs")
.arg("-Zunstable-options")
.arg("--test")
.arg("--persist-doctests")
.arg("doctests")
.arg("--test-run-directory")
.arg(run_dir)
.arg(run_dir_path)
.extern_("t", "libt.rlib")
.run();

View File

@ -1,12 +1,11 @@
// Tests behavior of rustdoc `--runtool`.
use run_make_support::{rustc, rustdoc, tmp_dir};
use std::env::current_dir;
use run_make_support::{rustc, rustdoc};
use std::fs::{create_dir, remove_dir_all};
use std::path::PathBuf;
fn mkdir(name: &str) -> PathBuf {
let dir = tmp_dir().join(name);
let dir = PathBuf::from(name);
create_dir(&dir).expect("failed to create doctests folder");
dir
}
@ -22,7 +21,7 @@ fn main() {
rustc().input("runtool.rs").output(&run_tool_binary).run();
rustdoc()
.input(current_dir().unwrap().join("t.rs"))
.input("t.rs")
.arg("-Zunstable-options")
.arg("--test")
.arg("--test-run-directory")
@ -30,7 +29,6 @@ fn main() {
.arg("--runtool")
.arg(&run_tool_binary)
.extern_("t", "libt.rlib")
.current_dir(tmp_dir())
.run();
remove_dir_all(run_dir);

View File

@ -1,7 +1,7 @@
use std::fs::create_dir;
use std::path::Path;
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn emit_and_check(out_dir: &Path, out_file: &str, format: &str) {
let out_file = out_dir.join(out_file);
@ -10,7 +10,7 @@ fn emit_and_check(out_dir: &Path, out_file: &str, format: &str) {
}
fn main() {
let out_dir = tmp_dir().join("emit");
let out_dir = Path::new("emit");
create_dir(&out_dir).unwrap();

View File

@ -1,6 +1,6 @@
// Test that we exit with the correct exit code for successful / unsuccessful / ICE compilations
use run_make_support::{rustc, rustdoc, tmp_dir};
use run_make_support::{rustc, rustdoc};
fn main() {
rustc().arg("success.rs").run();
@ -15,7 +15,7 @@ fn main() {
.arg("compile-error.rs")
.run_fail_assert_exit_code(101);
rustdoc().arg("success.rs").output(tmp_dir().join("exit-code")).run();
rustdoc().arg("success.rs").output("exit-code").run();
rustdoc().arg("--invalid-arg-foo").run_fail_assert_exit_code(1);

View File

@ -4,9 +4,9 @@
// and cause the test to fail.
// See https://github.com/rust-lang/rust/issues/53964
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn main() {
rustc().input("panic.rs").run();
rustc().input("app.rs").panic("abort").emit("obj").library_search_path(tmp_dir()).run();
rustc().input("app.rs").panic("abort").emit("obj").run();
}

View File

@ -13,15 +13,15 @@
//@ ignore-nvptx64-nvidia-cuda
// FIXME: can't find crate for `std`
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
use std::fs;
fn main() {
// FIXME(Oneirical): Use run_make_support::fs_wrapper here.
fs::create_dir(tmp_dir().join("src")).unwrap();
fs::create_dir(tmp_dir().join("incr")).unwrap();
fs::copy("a.rs", tmp_dir().join("src/main.rs")).unwrap();
rustc().incremental(tmp_dir().join("incr")).input(tmp_dir().join("src/main.rs")).run();
fs::copy("b.rs", tmp_dir().join("src/main.rs")).unwrap();
rustc().incremental(tmp_dir().join("incr")).input(tmp_dir().join("src/main.rs")).run();
fs::create_dir("src").unwrap();
fs::create_dir("incr").unwrap();
fs::copy("a.rs", "src/main.rs").unwrap();
rustc().incremental("incr").input("src/main.rs").run();
fs::copy("b.rs", "src/main.rs").unwrap();
rustc().incremental("incr").input("src/main.rs").run();
}

View File

@ -3,7 +3,7 @@
#[cfg(unix)]
extern crate libc;
use run_make_support::{aux_build, tmp_dir};
use run_make_support::aux_build;
use std::fs;
#[cfg(unix)]
use std::os::unix::fs::PermissionsExt;
@ -16,7 +16,7 @@ fn main() {
}
aux_build().arg("foo.rs").run();
verify(&tmp_dir().join("libfoo.rlib"));
verify(Path::new("libfoo.rlib"));
}
fn verify(path: &Path) {

View File

@ -6,7 +6,7 @@
// make compiletest annotations reproduce the ICE with the minimizations from issues #125474 and
// #125484.
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn main() {
// The dependency is not itself significant, apart from sharing a name with one of main's
@ -14,5 +14,5 @@ fn main() {
rustc().crate_name("same").crate_type("rlib").input("dependency.rs").run();
// Here, an ICE would happen when building the linker command.
rustc().input("main.rs").extern_("same", tmp_dir().join("libsame.rlib")).run();
rustc().input("main.rs").extern_("same", "libsame.rlib").run();
}

View File

@ -1,6 +1,7 @@
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
use std::path::Path;
fn main() {
rustc().input("bar.rs").crate_name("foo").run();
assert!(tmp_dir().join("libfoo.rlib").is_file());
assert!(Path::new("libfoo.rlib").is_file());
}

View File

@ -12,7 +12,7 @@
//@ ignore-cross-compile
use run_make_support::{rustc, tmp_dir, run_in_tmpdir};
use run_make_support::{run_in_tmpdir, rustc};
use std::fs;
fn main() {

View File

@ -5,13 +5,13 @@
//@ ignore-cross-compile
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
use std::fs;
fn main() {
rustc().crate_type("rlib").arg("--test").input("foo.rs").run();
assert!(
fs::remove_file(tmp_dir().join("foo.bc")).is_err(),
fs::remove_file("foo.bc").is_err(),
"An unwanted .bc file was created by run-make/no-intermediate-extras."
);
}

View File

@ -7,13 +7,13 @@
//@ ignore-cross-compile
//@ only-linux
use run_make_support::{cc, run, rustc, tmp_dir};
use run_make_support::{cc, cwd, run, rustc};
fn main() {
rustc().input("foo.rs").run();
cc().input("foo.c")
.arg("-lfoo")
.library_search_path(tmp_dir())
.library_search_path(cwd())
.arg("-Wl,--gc-sections")
.arg("-lpthread")
.arg("-ldl")
@ -22,7 +22,7 @@ fn main() {
run("foo");
cc().input("foo.c")
.arg("-lfoo")
.library_search_path(tmp_dir())
.library_search_path(cwd())
.arg("-Wl,--gc-sections")
.arg("-lpthread")
.arg("-ldl")

View File

@ -1,21 +1,21 @@
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn main() {
#[cfg(unix)]
let non_unicode: &std::ffi::OsStr = std::os::unix::ffi::OsStrExt::from_bytes(&[0xFF]);
#[cfg(windows)]
let non_unicode: std::ffi::OsString = std::os::windows::ffi::OsStringExt::from_wide(&[0xD800]);
match std::fs::create_dir(tmp_dir().join(&non_unicode)) {
match std::fs::create_dir(&non_unicode) {
// If an error occurs, check if creating a directory with a valid Unicode name would
// succeed.
Err(e) if std::fs::create_dir(tmp_dir().join("valid_unicode")).is_ok() => {
Err(e) if std::fs::create_dir("valid_unicode").is_ok() => {
// Filesystem doesn't appear support non-Unicode paths.
return;
}
Err(e) => panic!("error creating non-Unicode directory: {e}"),
_ => {}
}
let incr_dir = tmp_dir().join("incr-dir");
let incr_dir = "incr-dir";
rustc().input("foo.rs").incremental(&incr_dir).run();
for crate_dir in std::fs::read_dir(&incr_dir).unwrap() {
std::fs::create_dir(crate_dir.unwrap().path().join(&non_unicode)).unwrap();

View File

@ -6,11 +6,9 @@
// See <https://internals.rust-lang.org/t/easier-access-to-files-generated-by-emit-foo/20477>
extern crate run_make_support;
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn main() {
let inc_dir = tmp_dir();
// With single codegen unit files are renamed to match the source file name
for _ in 0..=1 {
let output = rustc()
@ -19,7 +17,7 @@ fn main() {
.codegen_units(1)
.json("artifacts")
.error_format("json")
.incremental(&inc_dir)
.incremental(&std::env::current_dir().unwrap())
.run();
let stderr = String::from_utf8_lossy(&output.stderr);
for file in &["lib.o", "lib.ll", "lib.bc", "lib.s"] {
@ -35,7 +33,7 @@ fn main() {
.codegen_units(2)
.json("artifacts")
.error_format("json")
.incremental(&inc_dir)
.incremental(&std::env::current_dir().unwrap())
.run();
let stderr = String::from_utf8_lossy(&output.stderr);
for file in &["rcgu.o", "rcgu.ll", "rcgu.bc", "rcgu.s"] {

View File

@ -6,14 +6,9 @@
// function in the crate.
// See https://github.com/rust-lang/rust/pull/50338
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn main() {
rustc().input("panic-impl-provider.rs").run();
rustc()
.input("panic-impl-consumer.rs")
.panic("abort")
.emit("llvm-ir")
.library_search_path(tmp_dir())
.run();
rustc().input("panic-impl-consumer.rs").panic("abort").emit("llvm-ir").run();
}

View File

@ -7,10 +7,10 @@
use std::collections::HashSet;
use std::ffi::OsString;
use std::io::BufRead;
use std::iter::FromIterator;
use std::path::PathBuf;
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
struct PrintCfg {
target: &'static str,
@ -91,7 +91,7 @@ fn check(PrintCfg { target, includes, disallow }: PrintCfg) {
// --print=cfg=PATH
{
let tmp_path = tmp_dir().join(format!("{target}.cfg"));
let tmp_path = PathBuf::from(format!("{target}.cfg"));
let mut print_arg = OsString::from("--print=cfg=");
print_arg.push(tmp_path.as_os_str());

View File

@ -2,8 +2,9 @@
//! output to a file (instead of stdout)
use std::ffi::OsString;
use std::path::PathBuf;
use run_make_support::{rustc, target, tmp_dir};
use run_make_support::{rustc, target};
struct Option<'a> {
target: &'a str,
@ -46,7 +47,7 @@ fn check(args: Option) {
// --print={option}=PATH
let output = {
let tmp_path = tmp_dir().join(format!("{}.txt", args.option));
let tmp_path = PathBuf::from(format!("{}.txt", args.option));
let mut print_arg = OsString::from(format!("--print={}=", args.option));
print_arg.push(tmp_path.as_os_str());

View File

@ -1,15 +1,15 @@
//@ ignore-windows
// This test should be replaced with one in tests/debuginfo once GDB or LLDB support 128-bit enums.
use gimli::{AttributeValue, Dwarf, EndianRcSlice, Reader, RunTimeEndian};
use gimli::{AttributeValue, EndianRcSlice, Reader, RunTimeEndian};
use object::{Object, ObjectSection};
use run_make_support::{gimli, object, rustc, tmp_dir};
use std::borrow::Cow;
use run_make_support::{gimli, object, rustc};
use std::collections::HashMap;
use std::path::PathBuf;
use std::rc::Rc;
fn main() {
let output = tmp_dir().join("repr128");
let output = PathBuf::from("repr128");
rustc().input("main.rs").output(&output).arg("-Cdebuginfo=2").run();
// Mach-O uses packed debug info
let dsym_location = output

View File

@ -7,12 +7,12 @@
//@ ignore-cross-compile
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
use std::fs;
fn compile(output_file: &str, emit: Option<&str>) {
let mut rustc = rustc();
let rustc = rustc.codegen_units(4).output(tmp_dir().join(output_file)).input("foo.rs");
let rustc = rustc.codegen_units(4).output(output_file).input("foo.rs");
if let Some(emit) = emit {
rustc.emit(emit);
}

View File

@ -5,12 +5,11 @@
// the renamed library.
// See https://github.com/rust-lang/rust/pull/49253
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
use std::fs;
fn main() {
rustc().extra_filename("-hash").input("foo.rs").run();
rustc().input("bar.rs").run();
fs::rename(tmp_dir().join("libfoo-hash.rlib"), tmp_dir().join("libfoo-another-hash.rlib"))
.unwrap();
fs::rename("libfoo-hash.rlib", "libfoo-another-hash.rlib").unwrap();
rustc().input("baz.rs").run();
}

View File

@ -1,14 +1,15 @@
// Assert that the search index is generated deterministically, regardless of the
// order that crates are documented in.
use run_make_support::{diff, rustdoc, tmp_dir};
use run_make_support::{diff, rustdoc};
use std::path::Path;
fn main() {
let foo_first = tmp_dir().join("foo_first");
let foo_first = Path::new("foo_first");
rustdoc().input("foo.rs").output(&foo_first).run();
rustdoc().input("bar.rs").output(&foo_first).run();
let bar_first = tmp_dir().join("bar_first");
let bar_first = Path::new("bar_first");
rustdoc().input("bar.rs").output(&bar_first).run();
rustdoc().input("foo.rs").output(&bar_first).run();

View File

@ -1,7 +1,7 @@
use run_make_support::{python_command, rustdoc, tmp_dir};
use run_make_support::{python_command, rustdoc};
fn main() {
let out_dir = tmp_dir().join("out");
let out_dir = "out";
rustdoc()
.input("foo.rs")
.arg("-Zunstable-options")

View File

@ -1,9 +1,10 @@
// Checks that if the output folder doesn't exist, rustdoc will create it.
use run_make_support::{rustdoc, tmp_dir};
use run_make_support::rustdoc;
use std::path::Path;
fn main() {
let out_dir = tmp_dir().join("foo/bar/doc");
let out_dir = Path::new("foo/bar/doc");
rustdoc().input("foo.rs").output(&out_dir).run();
assert!(out_dir.exists());
}

View File

@ -1,11 +1,10 @@
//@ ignore-cross-compile
use run_make_support::{htmldocck, rustc, rustdoc, tmp_dir};
use run_make_support::{htmldocck, rustc, rustdoc};
fn main() {
let tmp_dir = tmp_dir();
let out_dir = tmp_dir.join("rustdoc");
let ex_dir = tmp_dir.join("ex.calls");
let out_dir = "rustdoc";
let ex_dir = "ex.calls";
let proc_crate_name = "foobar_macro";
let crate_name = "foobar";
@ -41,8 +40,8 @@ fn main() {
.crate_name("ex")
.crate_type("bin")
.output(&out_dir)
.extern_(crate_name, tmp_dir.join(format!("lib{crate_name}.rlib")))
.extern_(proc_crate_name, tmp_dir.join(dylib_name.trim()))
.extern_(crate_name, format!("lib{crate_name}.rlib"))
.extern_(proc_crate_name, dylib_name.trim())
.arg("-Zunstable-options")
.arg("--scrape-examples-output-path")
.arg(&ex_dir)

View File

@ -1,10 +1,9 @@
use run_make_support::{htmldocck, rustc, rustdoc, source_root, tmp_dir};
use run_make_support::{htmldocck, rustc, rustdoc, source_root};
use std::fs::read_dir;
use std::path::Path;
pub fn scrape(extra_args: &[&str]) {
let lib_dir = tmp_dir();
let out_dir = tmp_dir().join("rustdoc");
let out_dir = Path::new("rustdoc");
let crate_name = "foobar";
let deps = read_dir("examples")
.unwrap()
@ -23,7 +22,7 @@ pub fn scrape(extra_args: &[&str]) {
.crate_name(&dep_stem)
.crate_type("bin")
.output(&out_dir)
.extern_(crate_name, lib_dir.join(format!("lib{crate_name}.rmeta")))
.extern_(crate_name, format!("lib{crate_name}.rmeta"))
.arg("-Zunstable-options")
.arg("--scrape-examples-output-path")
.arg(&out_example)

View File

@ -1,14 +1,14 @@
// Test that rustdoc will properly canonicalize the target spec json path just like rustc.
use run_make_support::{rustc, rustdoc, tmp_dir};
use run_make_support::{cwd, rustc, rustdoc};
fn main() {
let out_dir = tmp_dir().join("rustdoc-target-spec-json-path");
let out_dir = "rustdoc-target-spec-json-path";
rustc().crate_type("lib").input("dummy_core.rs").target("target.json").run();
rustdoc()
.input("my_crate.rs")
.output(out_dir)
.library_search_path(tmp_dir())
.library_search_path(cwd())
.target("target.json")
.run();
}

View File

@ -1,4 +1,4 @@
use run_make_support::{rustdoc, tmp_dir};
use run_make_support::rustdoc;
use std::path::Path;
use std::{fs, iter};
@ -8,8 +8,8 @@ fn generate_a_lot_of_cfgs(path: &Path) {
}
fn main() {
let arg_file = tmp_dir().join("args");
let arg_file = Path::new("args");
generate_a_lot_of_cfgs(&arg_file);
rustdoc().out_dir(tmp_dir()).input("foo.rs").arg_file(&arg_file).arg("--test").run();
rustdoc().input("foo.rs").arg_file(&arg_file).arg("--test").run();
}

View File

@ -1,10 +1,11 @@
// Test that rustdoc will properly load in a theme file and display it in the theme selector.
use run_make_support::{htmldocck, rustdoc, source_root, tmp_dir};
use run_make_support::{htmldocck, rustdoc, source_root};
use std::path::Path;
fn main() {
let out_dir = tmp_dir().join("rustdoc-themes");
let test_css = out_dir.join("test.css");
let out_dir = Path::new("rustdoc-themes");
let test_css = "test.css";
let no_script =
std::fs::read_to_string(source_root().join("src/librustdoc/html/static/css/noscript.css"))

View File

@ -1,7 +1,7 @@
use std::fs::copy;
use std::path::{Path, PathBuf};
use run_make_support::{copy_dir_all, recursive_diff, rustdoc, tmp_dir};
use run_make_support::{copy_dir_all, recursive_diff, rustdoc};
#[derive(PartialEq)]
enum JsonOutput {
@ -19,8 +19,8 @@ fn generate_docs(out_dir: &Path, json_output: JsonOutput) {
}
fn main() {
let out_dir = tmp_dir().join("rustdoc");
let tmp_out_dir = tmp_dir().join("tmp-rustdoc");
let out_dir = PathBuf::from("rustdoc");
let tmp_out_dir = PathBuf::from("tmp-rustdoc");
// Generate HTML docs.
generate_docs(&out_dir, JsonOutput::No);

View File

@ -1,7 +1,7 @@
use run_make_support::{htmldocck, rustdoc, tmp_dir};
use run_make_support::{htmldocck, rustdoc};
fn main() {
let out_dir = tmp_dir().join("rustdoc");
let out_dir = "rustdoc";
rustdoc().input("src/lib.rs").crate_name("foobar").crate_type("lib").output(&out_dir).run();
assert!(htmldocck().arg(out_dir).arg("src/lib.rs").status().unwrap().success());
}

View File

@ -1,7 +1,7 @@
use run_make_support::{htmldocck, rustdoc, tmp_dir};
use run_make_support::{htmldocck, rustdoc};
fn main() {
let out_dir = tmp_dir().join("rustdoc");
let out_dir = "rustdoc";
rustdoc()
.input("src/lib.rs")

View File

@ -1,7 +1,7 @@
use run_make_support::{htmldocck, rustdoc, tmp_dir};
use run_make_support::{htmldocck, rustdoc};
fn main() {
let out_dir = tmp_dir().join("rustdoc");
let out_dir = "rustdoc";
rustdoc()
.input("src/lib.rs")

View File

@ -1,6 +1,7 @@
//! This test checks rustc `-` (stdin) support
use run_make_support::{is_windows, rustc, tmp_dir};
use run_make_support::{is_windows, rustc};
use std::path::PathBuf;
const HELLO_WORLD: &str = r#"
fn main() {
@ -11,12 +12,12 @@ fn main() {
const NOT_UTF8: &[u8] = &[0xff, 0xff, 0xff];
fn main() {
let out_dir = tmp_dir();
// echo $HELLO_WORLD | rustc -
rustc().arg("-").stdin(HELLO_WORLD).run();
assert!(
out_dir.join(if !is_windows() { "rust_out" } else { "rust_out.exe" }).try_exists().unwrap()
PathBuf::from(if !is_windows() { "rust_out" } else { "rust_out.exe" })
.try_exists()
.unwrap()
);
// echo $NOT_UTF8 | rustc -

View File

@ -1,6 +1,7 @@
//! This test checks rustdoc `-` (stdin) handling
use run_make_support::{rustdoc, tmp_dir};
use run_make_support::rustdoc;
use std::path::PathBuf;
static INPUT: &str = r#"
//! ```
@ -10,8 +11,7 @@ pub struct F;
"#;
fn main() {
let tmp_dir = tmp_dir();
let out_dir = tmp_dir.join("doc");
let out_dir = PathBuf::from("doc");
// rustdoc -
rustdoc().arg("-").out_dir(&out_dir).stdin(INPUT).run();

View File

@ -1,14 +1,14 @@
//@ only-wasm32-wasip1
//@ needs-wasmtime
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
use std::path::Path;
use std::process::Command;
fn main() {
rustc().input("foo.rs").target("wasm32-wasip1").run();
let file = tmp_dir().join("foo.wasm");
let file = PathBuf::from("foo.wasm");
run(&file, "return_two_i32", "1\n2\n");
run(&file, "return_two_i64", "3\n4\n");

View File

@ -1,13 +1,13 @@
//@ only-wasm32-wasip1
use run_make_support::{rustc, tmp_dir, wasmparser};
use run_make_support::{rustc, wasmparser};
use std::collections::HashMap;
fn main() {
rustc().input("foo.rs").target("wasm32-wasip1").run();
rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run();
let file = std::fs::read(&tmp_dir().join("bar.wasm")).unwrap();
let file = std::fs::read("bar.wasm").unwrap();
let mut custom = HashMap::new();
for payload in wasmparser::Parser::new(0).parse_all(&file) {

View File

@ -1,13 +1,13 @@
//@ only-wasm32-wasip1
use run_make_support::{rustc, tmp_dir, wasmparser};
use run_make_support::{rustc, wasmparser};
use std::collections::HashMap;
use std::path::Path;
fn main() {
rustc().input("foo.rs").target("wasm32-wasip1").opt().run();
verify(&tmp_dir().join("foo.wasm"));
verify(&Path::new("foo.wasm"));
}
fn verify(path: &Path) {

View File

@ -1,6 +1,6 @@
//@ only-wasm32-wasip1
use run_make_support::{rustc, tmp_dir, wasmparser};
use run_make_support::{rustc, wasmparser};
use std::collections::HashMap;
use std::path::Path;
use wasmparser::ExternalKind::*;
@ -18,12 +18,9 @@ fn test(args: &[&str]) {
rustc().input("foo.rs").target("wasm32-wasip1").args(args).run();
rustc().input("main.rs").target("wasm32-wasip1").args(args).run();
verify_exports(Path::new("foo.wasm"), &[("foo", Func), ("FOO", Global), ("memory", Memory)]);
verify_exports(
&tmp_dir().join("foo.wasm"),
&[("foo", Func), ("FOO", Global), ("memory", Memory)],
);
verify_exports(
&tmp_dir().join("main.wasm"),
Path::new("main.wasm"),
&[
("foo", Func),
("FOO", Global),

View File

@ -1,6 +1,6 @@
//@ only-wasm32-wasip1
use run_make_support::{rustc, tmp_dir, wasmparser};
use run_make_support::{rustc, wasmparser};
use std::collections::HashMap;
use wasmparser::TypeRef::Func;
@ -8,7 +8,7 @@ fn main() {
rustc().input("foo.rs").target("wasm32-wasip1").run();
rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run();
let file = std::fs::read(&tmp_dir().join("bar.wasm")).unwrap();
let file = std::fs::read("bar.wasm").unwrap();
let mut imports = HashMap::new();
for payload in wasmparser::Parser::new(0).parse_all(&file) {

View File

@ -1,7 +1,7 @@
//@ only-wasm32-wasip1
#![deny(warnings)]
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn main() {
test("a");
@ -15,7 +15,7 @@ fn test(cfg: &str) {
rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").opt().cfg(cfg).run();
let bytes = std::fs::read(&tmp_dir().join("foo.wasm")).unwrap();
let bytes = std::fs::read("foo.wasm").unwrap();
println!("{}", bytes.len());
assert!(bytes.len() < 40_000);
}

View File

@ -1,6 +1,6 @@
//@ only-wasm32-wasip1
use run_make_support::{rustc, tmp_dir, wasmparser};
use run_make_support::{rustc, wasmparser};
use std::collections::HashMap;
fn main() {
@ -13,7 +13,7 @@ fn main() {
.arg("-Copt-level=z")
.run();
let file = std::fs::read(&tmp_dir().join("main.wasm")).unwrap();
let file = std::fs::read("main.wasm").unwrap();
let mut imports = HashMap::new();
for payload in wasmparser::Parser::new(0).parse_all(&file) {

View File

@ -1,12 +1,12 @@
//@ only-wasm32-wasip1
#![deny(warnings)]
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
fn main() {
rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").opt().run();
let bytes = std::fs::read(&tmp_dir().join("foo.wasm")).unwrap();
let bytes = std::fs::read("foo.wasm").unwrap();
println!("{}", bytes.len());
assert!(bytes.len() < 50_000);
}

View File

@ -1,6 +1,6 @@
//@ only-wasm32-wasip1
use run_make_support::{rustc, tmp_dir, wasmparser};
use run_make_support::{rustc, wasmparser};
use std::collections::{HashMap, HashSet};
fn main() {
@ -22,7 +22,7 @@ fn test(file: &str, args: &[&str], expected_imports: &[(&str, &[&str])]) {
rustc().input(file).target("wasm32-wasip1").args(args).run();
let file = std::fs::read(&tmp_dir().join(file).with_extension("wasm")).unwrap();
let file = std::fs::read(Path::new(file).with_extension("wasm")).unwrap();
let mut imports = HashMap::new();
for payload in wasmparser::Parser::new(0).parse_all(&file) {

View File

@ -1,18 +1,18 @@
//@ only-wasm32-wasip1
use run_make_support::{rustc, tmp_dir, wasmparser};
use run_make_support::{rustc, wasmparser};
use std::path::Path;
fn main() {
rustc().input("foo.rs").target("wasm32-wasip1").run();
verify_symbols(&tmp_dir().join("foo.wasm"));
verify_symbols(Path::new("foo.wasm"));
rustc().input("foo.rs").target("wasm32-wasip1").opt().run();
verify_symbols(&tmp_dir().join("foo.wasm"));
verify_symbols(Path::new("foo.wasm"));
rustc().input("bar.rs").target("wasm32-wasip1").run();
verify_symbols(&tmp_dir().join("bar.wasm"));
verify_symbols(Path::new("bar.wasm"));
rustc().input("bar.rs").target("wasm32-wasip1").opt().run();
verify_symbols(&tmp_dir().join("bar.wasm"));
verify_symbols(Path::new("bar.wasm"));
}
fn verify_symbols(path: &Path) {

View File

@ -1,17 +1,17 @@
//@ only-wasm32-wasip1
use run_make_support::{rustc, tmp_dir, wasmparser};
use run_make_support::{rustc, wasmparser};
use std::path::Path;
fn main() {
rustc().input("foo.rs").target("wasm32-wasip1").run();
verify_symbols(&tmp_dir().join("foo.wasm"));
verify_symbols(Path::new("foo.wasm"));
rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").run();
verify_symbols(&tmp_dir().join("foo.wasm"));
verify_symbols(Path::new("foo.wasm"));
rustc().input("foo.rs").target("wasm32-wasip1").opt().run();
verify_symbols(&tmp_dir().join("foo.wasm"));
verify_symbols(Path::new("foo.wasm"));
rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").opt().run();
verify_symbols(&tmp_dir().join("foo.wasm"));
verify_symbols(Path::new("foo.wasm"));
}
fn verify_symbols(path: &Path) {

View File

@ -2,7 +2,7 @@
//! a "hello world" application by setting `PATH` to `C:\Windows\System32`.
//@ only-windows
use run_make_support::{env_var, rustc, tmp_dir};
use run_make_support::{env_var, rustc};
use std::path::PathBuf;
use std::process::Command;
@ -12,7 +12,7 @@ fn main() {
let windows_dir = env_var("SystemRoot");
let system32: PathBuf = [&windows_dir, "System32"].iter().collect();
// Note: This does not use the support wrappers so that we can precisely control the PATH
let exe = tmp_dir().join("hello.exe");
let exe = "hello.exe";
let status = Command::new(exe).env("PATH", &system32).spawn().unwrap().wait().unwrap();
if !status.success() {
panic!("Command failed!\noutput status: `{status}`");

View File

@ -1,6 +1,6 @@
//@ only-windows
use run_make_support::{run, rustc, tmp_dir};
use run_make_support::{run, rustc};
// On Windows `Command` uses `CreateProcessW` to run a new process.
// However, in the past std used to not pass in the application name, leaving
@ -10,8 +10,7 @@ use run_make_support::{run, rustc, tmp_dir};
// `foo bar.exe` if foo.exe does not exist. Which is clearly not desired.
fn main() {
let out_dir = tmp_dir();
rustc().input("hello.rs").output(out_dir.join("hopefullydoesntexist bar.exe")).run();
rustc().input("hello.rs").output("hopefullydoesntexist bar.exe").run();
rustc().input("spawn.rs").run();
run("spawn");
}

View File

@ -3,7 +3,7 @@
// Tests that WS2_32.dll is not unnecessarily linked, see issue #85441
use run_make_support::object::{self, read::Object};
use run_make_support::{rustc, tmp_dir};
use run_make_support::rustc;
use std::fs;
fn main() {
@ -15,8 +15,7 @@ fn main() {
}
fn links_ws2_32(exe: &str) -> bool {
let path = tmp_dir().join(exe);
let binary_data = fs::read(path).unwrap();
let binary_data = fs::read(exe).unwrap();
let file = object::File::parse(&*binary_data).unwrap();
for import in file.imports().unwrap() {
if import.library().eq_ignore_ascii_case(b"WS2_32.dll") {