mirror of https://github.com/rust-lang/rust.git
Auto merge of #126097 - Kobzol:runmake-change-cwd, r=jieyouxu
Change how runmake v2 tests are executed This PR makes execution of v2 runmake tests more sane, by executing each test in a temporary directory by default, rather than running it inside `tests/run-make`. This will have.. a lot of conflicts. Fixes: https://github.com/rust-lang/rust/issues/126080 Closes https://github.com/rust-lang/rust/issues/125726, because it removes `tmp_dir`, lol. r? `@jieyouxu` try-job: x86_64-msvc
This commit is contained in:
commit
cfdb6175c2
|
@ -15,7 +15,7 @@ use crate::errors::{self, Error, ErrorKind};
|
|||
use crate::header::TestProps;
|
||||
use crate::json;
|
||||
use crate::read2::{read2_abbreviated, Truncated};
|
||||
use crate::util::{add_dylib_path, dylib_env_var, logv, PathBufExt};
|
||||
use crate::util::{add_dylib_path, copy_dir_all, dylib_env_var, logv, PathBufExt};
|
||||
use crate::ColorConfig;
|
||||
use colored::Colorize;
|
||||
use miropt_test_tools::{files_for_miropt_test, MiroptTest, MiroptTestFile};
|
||||
|
@ -3471,6 +3471,21 @@ impl<'test> TestCx<'test> {
|
|||
let rmake_out_dir = base_dir.join("rmake_out");
|
||||
create_dir_all(&rmake_out_dir).unwrap();
|
||||
|
||||
// Copy all input files (apart from rmake.rs) to the temporary directory,
|
||||
// so that the input directory structure from `tests/run-make/<test>` is mirrored
|
||||
// to the `rmake_out` directory.
|
||||
for path in walkdir::WalkDir::new(&self.testpaths.file).min_depth(1) {
|
||||
let path = path.unwrap().path().to_path_buf();
|
||||
if path.file_name().is_some_and(|s| s != "rmake.rs") {
|
||||
let target = rmake_out_dir.join(path.strip_prefix(&self.testpaths.file).unwrap());
|
||||
if path.is_dir() {
|
||||
copy_dir_all(&path, target).unwrap();
|
||||
} else {
|
||||
fs::copy(&path, target).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// HACK: assume stageN-target, we only want stageN.
|
||||
let stage = self.config.stage_id.split('-').next().unwrap();
|
||||
|
||||
|
@ -3530,18 +3545,11 @@ impl<'test> TestCx<'test> {
|
|||
.env("PYTHON", &self.config.python)
|
||||
.env("RUST_BUILD_STAGE", &self.config.stage_id)
|
||||
.env("RUSTC", cwd.join(&self.config.rustc_path))
|
||||
.env("TMPDIR", &rmake_out_dir)
|
||||
.env("LD_LIB_PATH_ENVVAR", dylib_env_var())
|
||||
.env(dylib_env_var(), &host_dylib_env_paths)
|
||||
.env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path))
|
||||
.env("TARGET_RPATH_DIR", cwd.join(&self.config.run_lib_path))
|
||||
.env("LLVM_COMPONENTS", &self.config.llvm_components)
|
||||
// We for sure don't want these tests to run in parallel, so make
|
||||
// sure they don't have access to these vars if we run via `make`
|
||||
// at the top level
|
||||
.env_remove("MAKEFLAGS")
|
||||
.env_remove("MFLAGS")
|
||||
.env_remove("CARGO_MAKEFLAGS");
|
||||
.env("LLVM_COMPONENTS", &self.config.llvm_components);
|
||||
|
||||
if std::env::var_os("COMPILETEST_FORCE_STAGE0").is_some() {
|
||||
let mut stage0_sysroot = build_root.clone();
|
||||
|
@ -3571,7 +3579,7 @@ impl<'test> TestCx<'test> {
|
|||
let target_rpath_env_path = env::join_paths(target_rpath_env_path).unwrap();
|
||||
|
||||
let mut cmd = Command::new(&recipe_bin);
|
||||
cmd.current_dir(&self.testpaths.file)
|
||||
cmd.current_dir(&rmake_out_dir)
|
||||
.stdout(Stdio::piped())
|
||||
.stderr(Stdio::piped())
|
||||
.env("LD_LIB_PATH_ENVVAR", dylib_env_var())
|
||||
|
@ -3582,16 +3590,9 @@ impl<'test> TestCx<'test> {
|
|||
.env("SOURCE_ROOT", &src_root)
|
||||
.env("RUST_BUILD_STAGE", &self.config.stage_id)
|
||||
.env("RUSTC", cwd.join(&self.config.rustc_path))
|
||||
.env("TMPDIR", &rmake_out_dir)
|
||||
.env("HOST_RPATH_DIR", cwd.join(&self.config.compile_lib_path))
|
||||
.env("TARGET_RPATH_DIR", cwd.join(&self.config.run_lib_path))
|
||||
.env("LLVM_COMPONENTS", &self.config.llvm_components)
|
||||
// We for sure don't want these tests to run in parallel, so make
|
||||
// sure they don't have access to these vars if we run via `make`
|
||||
// at the top level
|
||||
.env_remove("MAKEFLAGS")
|
||||
.env_remove("MFLAGS")
|
||||
.env_remove("CARGO_MAKEFLAGS");
|
||||
.env("LLVM_COMPONENTS", &self.config.llvm_components);
|
||||
|
||||
if let Some(ref rustdoc) = self.config.rustdoc_path {
|
||||
cmd.env("RUSTDOC", cwd.join(rustdoc));
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::common::Config;
|
||||
use std::env;
|
||||
use std::ffi::OsStr;
|
||||
use std::path::PathBuf;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use tracing::*;
|
||||
|
@ -76,3 +76,17 @@ pub fn add_dylib_path(cmd: &mut Command, paths: impl Iterator<Item = impl Into<P
|
|||
let new_paths = paths.map(Into::into).chain(old_paths.into_iter().flatten());
|
||||
cmd.env(dylib_env_var(), env::join_paths(new_paths).unwrap());
|
||||
}
|
||||
|
||||
pub fn copy_dir_all(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io::Result<()> {
|
||||
std::fs::create_dir_all(&dst)?;
|
||||
for entry in std::fs::read_dir(src)? {
|
||||
let entry = entry?;
|
||||
let ty = entry.file_type()?;
|
||||
if ty.is_dir() {
|
||||
copy_dir_all(entry.path(), dst.as_ref().join(entry.file_name()))?;
|
||||
} else {
|
||||
std::fs::copy(entry.path(), dst.as_ref().join(entry.file_name()))?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
///
|
||||
|
@ -54,8 +52,7 @@ impl Cc {
|
|||
self
|
||||
}
|
||||
|
||||
/// Specify `-o` or `-Fe`/`-Fo` depending on platform/compiler. This assumes that the executable
|
||||
/// is under `$TMPDIR`.
|
||||
/// Specify `-o` or `-Fe`/`-Fo` depending on platform/compiler.
|
||||
pub fn out_exe(&mut self, name: &str) -> &mut Self {
|
||||
// Ref: tools.mk (irrelevant lines omitted):
|
||||
//
|
||||
|
@ -69,13 +66,13 @@ impl Cc {
|
|||
// ```
|
||||
|
||||
if is_msvc() {
|
||||
let fe_path = cygpath_windows(tmp_dir().join(bin_name(name)));
|
||||
let fo_path = cygpath_windows(tmp_dir().join(format!("{name}.obj")));
|
||||
let fe_path = cygpath_windows(bin_name(name));
|
||||
let fo_path = cygpath_windows(format!("{name}.obj"));
|
||||
self.cmd.arg(format!("-Fe:{fe_path}"));
|
||||
self.cmd.arg(format!("-Fo:{fo_path}"));
|
||||
} else {
|
||||
self.cmd.arg("-o");
|
||||
self.cmd.arg(tmp_dir().join(name));
|
||||
self.cmd.arg(name);
|
||||
}
|
||||
|
||||
self
|
||||
|
|
|
@ -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 {
|
||||
|
@ -30,11 +30,11 @@ impl Clang {
|
|||
self
|
||||
}
|
||||
|
||||
/// Specify the name of the executable. The executable will be placed under `$TMPDIR`, and the
|
||||
/// extension will be determined by [`bin_name`].
|
||||
/// Specify the name of the executable. The executable will be placed under the current directory
|
||||
/// and the extension will be determined by [`bin_name`].
|
||||
pub fn out_exe(&mut self, name: &str) -> &mut Self {
|
||||
self.cmd.arg("-o");
|
||||
self.cmd.arg(tmp_dir().join(bin_name(name)));
|
||||
self.cmd.arg(bin_name(name));
|
||||
self
|
||||
}
|
||||
|
||||
|
|
|
@ -45,11 +45,6 @@ pub fn env_var_os(name: &str) -> OsString {
|
|||
}
|
||||
}
|
||||
|
||||
/// Path of `TMPDIR` (a temporary build directory, not under `/tmp`).
|
||||
pub fn tmp_dir() -> PathBuf {
|
||||
env_var_os("TMPDIR").into()
|
||||
}
|
||||
|
||||
/// `TARGET`
|
||||
pub fn target() -> String {
|
||||
env_var("TARGET")
|
||||
|
@ -70,12 +65,6 @@ pub fn is_darwin() -> bool {
|
|||
target().contains("darwin")
|
||||
}
|
||||
|
||||
/// Construct a path to a static library under `$TMPDIR` given the library name. This will return a
|
||||
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
|
||||
pub fn static_lib(name: &str) -> PathBuf {
|
||||
tmp_dir().join(static_lib_name(name))
|
||||
}
|
||||
|
||||
pub fn python_command() -> Command {
|
||||
let python_path = env_var("PYTHON");
|
||||
Command::new(python_path)
|
||||
|
@ -116,12 +105,6 @@ pub fn static_lib_name(name: &str) -> String {
|
|||
if is_msvc() { format!("{name}.lib") } else { format!("lib{name}.a") }
|
||||
}
|
||||
|
||||
/// Construct a path to a dynamic library under `$TMPDIR` given the library name. This will return a
|
||||
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
|
||||
pub fn dynamic_lib(name: &str) -> PathBuf {
|
||||
tmp_dir().join(dynamic_lib_name(name))
|
||||
}
|
||||
|
||||
/// Construct the dynamic library name based on the platform.
|
||||
pub fn dynamic_lib_name(name: &str) -> String {
|
||||
// See tools.mk (irrelevant lines omitted):
|
||||
|
@ -159,14 +142,7 @@ pub fn dynamic_lib_extension() -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
/// Construct a path to a rust library (rlib) under `$TMPDIR` given the library name. This will return a
|
||||
/// path with `$TMPDIR` joined with the library name.
|
||||
pub fn rust_lib(name: &str) -> PathBuf {
|
||||
tmp_dir().join(rust_lib_name(name))
|
||||
}
|
||||
|
||||
/// Generate the name a rust library (rlib) would have. If you want the complete path, use
|
||||
/// [`rust_lib`] instead.
|
||||
/// Construct a rust library (rlib) name.
|
||||
pub fn rust_lib_name(name: &str) -> String {
|
||||
format!("lib{name}.rlib")
|
||||
}
|
||||
|
@ -176,6 +152,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]
|
||||
|
@ -227,7 +208,7 @@ pub fn set_host_rpath(cmd: &mut Command) {
|
|||
let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR");
|
||||
cmd.env(&ld_lib_path_envvar, {
|
||||
let mut paths = vec![];
|
||||
paths.push(PathBuf::from(env_var("TMPDIR")));
|
||||
paths.push(cwd());
|
||||
paths.push(PathBuf::from(env_var("HOST_RPATH_DIR")));
|
||||
for p in env::split_paths(&env_var(&ld_lib_path_envvar)) {
|
||||
paths.push(p.to_path_buf());
|
||||
|
@ -315,6 +296,27 @@ pub fn assert_not_contains(haystack: &str, needle: &str) {
|
|||
}
|
||||
}
|
||||
|
||||
/// This function is designed for running commands in a temporary directory
|
||||
/// that is cleared after the function ends.
|
||||
///
|
||||
/// What this function does:
|
||||
/// 1) Creates a temporary directory (`tmpdir`)
|
||||
/// 2) Copies all files from the current directory to `tmpdir`
|
||||
/// 3) Changes the current working directory to `tmpdir`
|
||||
/// 4) Calls `callback`
|
||||
/// 5) Switches working directory back to the original one
|
||||
/// 6) Removes `tmpdir`
|
||||
pub fn run_in_tmpdir<F: FnOnce()>(callback: F) {
|
||||
let original_dir = cwd();
|
||||
let tmpdir = original_dir.join("../temporary-directory");
|
||||
copy_dir_all(".", &tmpdir);
|
||||
|
||||
env::set_current_dir(&tmpdir).unwrap();
|
||||
callback();
|
||||
env::set_current_dir(original_dir).unwrap();
|
||||
fs::remove_dir_all(tmpdir).unwrap();
|
||||
}
|
||||
|
||||
/// Implement common helpers for command wrappers. This assumes that the command wrapper is a struct
|
||||
/// containing a `cmd: Command` field and a `output` function. The provided helpers are:
|
||||
///
|
||||
|
|
|
@ -2,19 +2,19 @@ use std::env;
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Output};
|
||||
|
||||
use crate::{env_var, is_windows};
|
||||
use crate::{cwd, env_var, is_windows};
|
||||
|
||||
use super::handle_failed_output;
|
||||
|
||||
fn run_common(name: &str) -> (Command, Output) {
|
||||
let mut bin_path = PathBuf::new();
|
||||
bin_path.push(env_var("TMPDIR"));
|
||||
bin_path.push(cwd());
|
||||
bin_path.push(name);
|
||||
let ld_lib_path_envvar = env_var("LD_LIB_PATH_ENVVAR");
|
||||
let mut cmd = Command::new(bin_path);
|
||||
cmd.env(&ld_lib_path_envvar, {
|
||||
let mut paths = vec![];
|
||||
paths.push(PathBuf::from(env_var("TMPDIR")));
|
||||
paths.push(cwd());
|
||||
for p in env::split_paths(&env_var("TARGET_RPATH_ENV")) {
|
||||
paths.push(p.to_path_buf());
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::io::Write;
|
|||
use std::path::Path;
|
||||
use std::process::{Command, Output, Stdio};
|
||||
|
||||
use crate::{env_var, handle_failed_output, set_host_rpath, tmp_dir};
|
||||
use crate::{cwd, env_var, handle_failed_output, set_host_rpath};
|
||||
|
||||
/// Construct a new `rustc` invocation.
|
||||
pub fn rustc() -> Rustc {
|
||||
|
@ -28,7 +28,7 @@ fn setup_common() -> Command {
|
|||
let rustc = env_var("RUSTC");
|
||||
let mut cmd = Command::new(rustc);
|
||||
set_host_rpath(&mut cmd);
|
||||
cmd.arg("--out-dir").arg(tmp_dir()).arg("-L").arg(tmp_dir());
|
||||
cmd.arg("-L").arg(cwd());
|
||||
cmd
|
||||
}
|
||||
|
||||
|
|
|
@ -10,11 +10,11 @@ use run_make_support::{aux_build, rustc, source_root};
|
|||
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 = std::fs::read_to_string(source_root().join("src/version")).unwrap();
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
//! Check that non-trivial `repr(C)` enum in Rust has valid C layout.
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use run_make_support::{cc, extra_c_flags, extra_cxx_flags, run, rustc, static_lib};
|
||||
use run_make_support::{cc, extra_c_flags, extra_cxx_flags, run, rustc, static_lib_name};
|
||||
|
||||
pub fn main() {
|
||||
use std::path::Path;
|
||||
|
||||
rustc().input("nonclike.rs").crate_type("staticlib").run();
|
||||
cc().input("test.c")
|
||||
.input(static_lib("nonclike"))
|
||||
.input(static_lib_name("nonclike"))
|
||||
.out_exe("test")
|
||||
.args(&extra_c_flags())
|
||||
.args(&extra_cxx_flags())
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,13 +3,9 @@
|
|||
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use run_make_support::{run, rustc, tmp_dir};
|
||||
use std::env;
|
||||
use std::fs;
|
||||
use run_make_support::{run, rustc};
|
||||
|
||||
fn main() {
|
||||
fs::copy("foo.rs", tmp_dir().join("foo.rs")).unwrap();
|
||||
env::set_current_dir(tmp_dir());
|
||||
rustc().output("foo").input("foo.rs").run();
|
||||
run("foo");
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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(cwd(), |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| {
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use run_make_support::{cc, extra_c_flags, run, rustc, static_lib};
|
||||
use run_make_support::{cc, extra_c_flags, run, rustc, static_lib_name};
|
||||
use std::fs;
|
||||
|
||||
fn main() {
|
||||
rustc().input("foo.rs").run();
|
||||
cc().input("bar.c").input(static_lib("foo")).out_exe("bar").args(&extra_c_flags()).run();
|
||||
cc().input("bar.c").input(static_lib_name("foo")).out_exe("bar").args(&extra_c_flags()).run();
|
||||
run("bar");
|
||||
fs::remove_file(static_lib("foo"));
|
||||
fs::remove_file(static_lib_name("foo"));
|
||||
run("bar");
|
||||
}
|
||||
|
|
|
@ -5,12 +5,12 @@
|
|||
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use run_make_support::{cc, extra_c_flags, run, rustc, static_lib};
|
||||
use run_make_support::{cc, extra_c_flags, run, rustc, static_lib_name};
|
||||
|
||||
fn main() {
|
||||
rustc().input("checkrust.rs").run();
|
||||
cc().input("test.c")
|
||||
.input(static_lib("checkrust"))
|
||||
.input(static_lib_name("checkrust"))
|
||||
.out_exe("test")
|
||||
.args(&extra_c_flags())
|
||||
.run();
|
||||
|
|
|
@ -12,24 +12,20 @@
|
|||
|
||||
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_name, 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");
|
||||
remove_file(dynamic_lib("foo")).unwrap();
|
||||
remove_file(dynamic_lib_name("foo")).unwrap();
|
||||
|
||||
rustc().input("foo.rs").arg("-Clto").run();
|
||||
run("foo");
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "scratch"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[lib]
|
||||
path = "lib.rs"
|
|
@ -0,0 +1 @@
|
|||
#![no_std]
|
|
@ -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");
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
use std::fs;
|
||||
|
||||
use run_make_support::{rustc, tmp_dir};
|
||||
use run_make_support::{cwd, 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(cwd()).unwrap() {
|
||||
let entry = entry.unwrap();
|
||||
let path = entry.path();
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -12,31 +12,24 @@
|
|||
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use run_make_support::{rustc, tmp_dir};
|
||||
use run_make_support::{run_in_tmpdir, rustc};
|
||||
use std::fs;
|
||||
|
||||
fn test_with_teardown(rustc_calls: impl Fn()) {
|
||||
rustc_calls();
|
||||
//FIXME(Oneirical): This should be replaced with the run-make-support fs wrappers.
|
||||
fs::remove_dir_all(tmp_dir()).unwrap();
|
||||
fs::create_dir(tmp_dir()).unwrap();
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test_with_teardown(|| {
|
||||
run_in_tmpdir(|| {
|
||||
// Building just baz
|
||||
rustc().crate_type("rlib").input("foo.rs").run();
|
||||
rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("bin").input("baz.rs").run();
|
||||
});
|
||||
test_with_teardown(|| {
|
||||
run_in_tmpdir(|| {
|
||||
rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("rlib").input("bar1.rs").run();
|
||||
rustc().crate_type("dylib,rlib").input("baz.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("bin").input("baz.rs").run();
|
||||
});
|
||||
test_with_teardown(|| {
|
||||
run_in_tmpdir(|| {
|
||||
// Building baz2
|
||||
rustc().crate_type("rlib").input("foo.rs").run();
|
||||
rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run();
|
||||
|
@ -44,42 +37,42 @@ fn main() {
|
|||
rustc().crate_type("dylib").input("baz2.rs").run_fail_assert_exit_code(1);
|
||||
rustc().crate_type("bin").input("baz2.rs").run_fail_assert_exit_code(1);
|
||||
});
|
||||
test_with_teardown(|| {
|
||||
run_in_tmpdir(|| {
|
||||
rustc().crate_type("rlib").input("foo.rs").run();
|
||||
rustc().crate_type("rlib").input("bar1.rs").run();
|
||||
rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("dylib,rlib").input("baz2.rs").run();
|
||||
rustc().crate_type("bin").input("baz2.rs").run();
|
||||
});
|
||||
test_with_teardown(|| {
|
||||
run_in_tmpdir(|| {
|
||||
rustc().crate_type("rlib").input("foo.rs").run();
|
||||
rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("rlib").input("bar2.rs").run();
|
||||
rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("bin").input("baz2.rs").run();
|
||||
});
|
||||
test_with_teardown(|| {
|
||||
run_in_tmpdir(|| {
|
||||
rustc().crate_type("rlib").input("foo.rs").run();
|
||||
rustc().crate_type("rlib").input("bar1.rs").run();
|
||||
rustc().crate_type("rlib").input("bar2.rs").run();
|
||||
rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("bin").input("baz2.rs").run();
|
||||
});
|
||||
test_with_teardown(|| {
|
||||
run_in_tmpdir(|| {
|
||||
rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("rlib").input("bar1.rs").run();
|
||||
rustc().crate_type("rlib").input("bar2.rs").run();
|
||||
rustc().crate_type("dylib,rlib").input("baz2.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("bin").input("baz2.rs").run();
|
||||
});
|
||||
test_with_teardown(|| {
|
||||
run_in_tmpdir(|| {
|
||||
rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("dylib").input("bar1.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("rlib").input("bar2.rs").run();
|
||||
rustc().crate_type("dylib,rlib").input("baz2.rs").run();
|
||||
rustc().crate_type("bin").input("baz2.rs").run();
|
||||
});
|
||||
test_with_teardown(|| {
|
||||
run_in_tmpdir(|| {
|
||||
rustc().crate_type("dylib").input("foo.rs").arg("-Cprefer-dynamic").run();
|
||||
rustc().crate_type("rlib").input("bar1.rs").run();
|
||||
rustc().crate_type("dylib").input("bar2.rs").arg("-Cprefer-dynamic").run();
|
||||
|
|
|
@ -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."
|
||||
);
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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::{cwd, 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(cwd())
|
||||
.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(cwd())
|
||||
.run();
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
for file in &["rcgu.o", "rcgu.ll", "rcgu.bc", "rcgu.s"] {
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -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());
|
||||
|
||||
|
|
|
@ -9,10 +9,10 @@
|
|||
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use run_make_support::{cc, extra_c_flags, run, rustc, static_lib};
|
||||
use run_make_support::{cc, extra_c_flags, run, rustc, static_lib_name};
|
||||
|
||||
fn main() {
|
||||
let libbar_path = static_lib("bar");
|
||||
let libbar_path = static_lib_name("bar");
|
||||
rustc().input("foo.rs").crate_type("rlib").run();
|
||||
rustc()
|
||||
.input("bar.rs")
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
//@ ignore-cross-compile
|
||||
|
||||
use run_make_support::{htmldocck, rustc, rustdoc, tmp_dir};
|
||||
use run_make_support::{htmldocck, rust_lib_name, 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, rust_lib_name(crate_name))
|
||||
.extern_(proc_crate_name, dylib_name.trim())
|
||||
.arg("-Zunstable-options")
|
||||
.arg("--scrape-examples-output-path")
|
||||
.arg(&ex_dir)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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"))
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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 -
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -3,12 +3,12 @@
|
|||
|
||||
//@ ignore-cross-compile
|
||||
|
||||
use run_make_support::{dynamic_lib, rustc};
|
||||
use run_make_support::{dynamic_lib_name, rustc};
|
||||
use std::fs::File;
|
||||
|
||||
fn main() {
|
||||
rustc().input("foo.rs").arg("-Cprefer-dynamic").run();
|
||||
File::create(dynamic_lib("foo-something-special")).unwrap();
|
||||
File::create(dynamic_lib("foo-something-special2")).unwrap();
|
||||
File::create(dynamic_lib_name("foo-something-special")).unwrap();
|
||||
File::create(dynamic_lib_name("foo-something-special2")).unwrap();
|
||||
rustc().input("bar.rs").run();
|
||||
}
|
||||
|
|
|
@ -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 = Path::new("foo.wasm");
|
||||
|
||||
run(&file, "return_two_i32", "1\n2\n");
|
||||
run(&file, "return_two_i64", "3\n4\n");
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
//@ only-wasm32-wasip1
|
||||
|
||||
use run_make_support::{rustc, tmp_dir, wasmparser};
|
||||
use run_make_support::{rustc, wasmparser};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
test_file("foo.rs", &[("a", &["foo"]), ("b", &["foo"])]);
|
||||
|
@ -22,7 +23,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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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::{cwd, 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 = cwd().join("hello.exe");
|
||||
let status = Command::new(exe).env("PATH", &system32).spawn().unwrap().wait().unwrap();
|
||||
if !status.success() {
|
||||
panic!("Command failed!\noutput status: `{status}`");
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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") {
|
||||
|
|
Loading…
Reference in New Issue