Skip to content

Commit d86c981

Browse files
committed
Remove all usages of tmp_dir from tests
1 parent 94ccb9b commit d86c981

File tree

64 files changed

+182
-210
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+182
-210
lines changed

src/tools/run-make-support/src/cc.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
use std::path::Path;
22
use std::process::Command;
33

4-
use crate::{
5-
bin_name, cygpath_windows, env_var, handle_failed_output, is_msvc, is_windows, tmp_dir, uname,
6-
};
4+
use crate::{bin_name, cygpath_windows, env_var, handle_failed_output, is_msvc, is_windows, uname};
75

86
/// Construct a new platform-specific C compiler invocation.
97
///

src/tools/run-make-support/src/clang.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::path::Path;
22
use std::process::Command;
33

4-
use crate::{bin_name, env_var, handle_failed_output, tmp_dir};
4+
use crate::{bin_name, env_var, handle_failed_output};
55

66
/// Construct a new `clang` invocation. `clang` is not always available for all targets.
77
pub fn clang() -> Clang {

src/tools/run-make-support/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ pub fn bin_name(name: &str) -> String {
171171
if is_windows() { format!("{name}.exe") } else { name.to_string() }
172172
}
173173

174+
/// Return the current working directory.
175+
pub fn cwd() -> PathBuf {
176+
env::current_dir().unwrap()
177+
}
178+
174179
/// Use `cygpath -w` on a path to get a Windows path string back. This assumes that `cygpath` is
175180
/// available on the platform!
176181
#[track_caller]

tests/run-make/CURRENT_RUSTC_VERSION/rmake.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ use run_make_support::{aux_build, rustc};
1010
fn main() {
1111
aux_build().input("stable.rs").emit("metadata").run();
1212

13-
let mut stable_path = PathBuf::from(env!("TMPDIR"));
14-
stable_path.push("libstable.rmeta");
15-
16-
let output =
17-
rustc().input("main.rs").emit("metadata").extern_("stable", &stable_path).command_output();
13+
let output = rustc()
14+
.input("main.rs")
15+
.emit("metadata")
16+
.extern_("stable", "libstable.rmeta")
17+
.command_output();
1818

1919
let stderr = String::from_utf8_lossy(&output.stderr);
2020
let version = include_str!(concat!(env!("S"), "/src/version"));

tests/run-make/artifact-incr-cache-no-obj/rmake.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
//
66
// Fixes: rust-lang/rust#123234
77

8-
use run_make_support::{rustc, tmp_dir};
8+
use run_make_support::rustc;
99

1010
fn main() {
11-
let inc_dir = tmp_dir();
12-
1311
for _ in 0..=1 {
1412
rustc()
1513
.input("lib.rs")
1614
.crate_type("lib")
1715
.emit("asm,dep-info,link,mir,llvm-ir,llvm-bc")
18-
.incremental(&inc_dir)
16+
.incremental("incremental")
1917
.run();
2018
}
2119
}

tests/run-make/artifact-incr-cache/rmake.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,15 @@
77
// Also see discussion at
88
// <https://internals.rust-lang.org/t/interaction-between-incremental-compilation-and-emit/20551>
99

10-
use run_make_support::{rustc, tmp_dir};
10+
use run_make_support::rustc;
1111

1212
fn main() {
13-
let inc_dir = tmp_dir();
14-
1513
for _ in 0..=1 {
1614
rustc()
1715
.input("lib.rs")
1816
.crate_type("lib")
1917
.emit("obj,asm,dep-info,link,mir,llvm-ir,llvm-bc")
20-
.incremental(&inc_dir)
18+
.incremental("incremental")
2119
.run();
2220
}
2321
}

tests/run-make/box-struct-no-segfault/rmake.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
// This test checks that this bug does not resurface.
66
// See https://github.com/rust-lang/rust/issues/28766
77

8-
use run_make_support::{rustc, tmp_dir};
8+
use run_make_support::rustc;
99

1010
fn main() {
1111
rustc().opt().input("foo.rs").run();
12-
rustc().opt().library_search_path(tmp_dir()).input("main.rs").run();
12+
rustc().opt().input("main.rs").run();
1313
}

tests/run-make/c-link-to-rust-dylib/rmake.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,23 @@
55

66
use std::fs::remove_file;
77

8-
use run_make_support::{
9-
cc, dynamic_lib_extension, is_msvc, read_dir, run, run_fail, rustc, tmp_dir,
10-
};
8+
use run_make_support::{cc, cwd, dynamic_lib_extension, is_msvc, read_dir, run, run_fail, rustc};
119

1210
fn main() {
1311
rustc().input("foo.rs").run();
1412

1513
if is_msvc() {
16-
let lib = tmp_dir().join("foo.dll.lib");
14+
let lib = "foo.dll.lib";
1715

1816
cc().input("bar.c").arg(lib).out_exe("bar").run();
1917
} else {
20-
cc().input("bar.c")
21-
.arg("-lfoo")
22-
.output(tmp_dir().join("bar"))
23-
.library_search_path(tmp_dir())
24-
.run();
18+
cc().input("bar.c").arg("-lfoo").output("bar").library_search_path(cwd()).run();
2519
}
2620

2721
run("bar");
2822

2923
let expected_extension = dynamic_lib_extension();
30-
read_dir(tmp_dir(), |path| {
24+
read_dir(std::env::current_dir().unwrap(), |path| {
3125
if path.is_file()
3226
&& path.extension().is_some_and(|ext| ext == expected_extension)
3327
&& path.file_name().and_then(|name| name.to_str()).is_some_and(|name| {

tests/run-make/cdylib/rmake.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,16 @@
1212

1313
use std::fs::remove_file;
1414

15-
use run_make_support::{cc, dynamic_lib, is_msvc, run, rustc, tmp_dir};
15+
use run_make_support::{cc, cwd, dynamic_lib, is_msvc, run, rustc};
1616

1717
fn main() {
1818
rustc().input("bar.rs").run();
1919
rustc().input("foo.rs").run();
2020

2121
if is_msvc() {
22-
cc().input("foo.c").arg(tmp_dir().join("foo.dll.lib")).out_exe("foo").run();
22+
cc().input("foo.c").arg("foo.dll.lib").out_exe("foo").run();
2323
} else {
24-
cc().input("foo.c")
25-
.arg("-lfoo")
26-
.output(tmp_dir().join("foo"))
27-
.library_search_path(tmp_dir())
28-
.run();
24+
cc().input("foo.c").arg("-lfoo").library_search_path(cwd()).output("foo").run();
2925
}
3026

3127
run("foo");
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[package]
2+
name = "scratch"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[lib]
7+
path = "lib.rs"

0 commit comments

Comments
 (0)