Skip to content

Commit e40e22b

Browse files
committed
Auto merge of rust-lang#112390 - MoskalykA:move-two-tests-from-library-to-tests, r=workingjubilee
Move two tests from `tests/ui/std` to `library/std/tests` Hi, there, This pull request comes from this issue (rust-lang#99417), sorry I made some mistakes creating the pull request, it's my first one.
2 parents 0ca28c3 + 48e7f3e commit e40e22b

File tree

2 files changed

+17
-37
lines changed

2 files changed

+17
-37
lines changed

tests/ui/std/issue-15149.rs renamed to library/std/tests/process_spawning.rs

+5-26
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,17 @@
1-
// run-pass
2-
3-
#![allow(unused_variables)]
4-
// no-prefer-dynamic
5-
// ignore-cross-compile
6-
71
use std::env;
8-
use std::ffi::OsStr;
92
use std::fs;
10-
use std::path::PathBuf;
113
use std::process;
124
use std::str;
135

14-
fn main() {
15-
// If we're the child, make sure we were invoked correctly
16-
let args: Vec<String> = env::args().collect();
17-
if args.len() > 1 && args[1] == "child" {
18-
// FIXME: This should check the whole `args[0]` instead of just
19-
// checking that it ends_with the executable name. This
20-
// is needed because of Windows, which has a different behavior.
21-
// See #15149 for more info.
22-
let my_path = env::current_exe().unwrap();
23-
return assert_eq!(my_path.file_stem(), Some(OsStr::new("mytest")));
24-
}
25-
26-
test();
27-
}
6+
mod common;
287

29-
fn test() {
8+
#[test]
9+
fn issue_15149() {
3010
// If we're the parent, copy our own binary to a new directory.
3111
let my_path = env::current_exe().unwrap();
32-
let my_dir = my_path.parent().unwrap();
3312

34-
let child_dir = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap());
35-
let child_dir = child_dir.join("issue-15140-child");
13+
let temp = common::tmpdir();
14+
let child_dir = temp.join("issue-15140-child");
3615
fs::create_dir_all(&child_dir).unwrap();
3716

3817
let child_path = child_dir.join(&format!("mytest{}", env::consts::EXE_SUFFIX));

tests/ui/std/switch-stdout.rs renamed to library/std/tests/switch-stdout.rs

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
// run-pass
2-
// ignore-wasm (needs file descriptors and env variables)
1+
#[cfg(any(target_family = "unix", target_family = "windows"))]
32

4-
use std::env;
53
use std::fs::File;
64
use std::io::{Read, Write};
7-
use std::path::PathBuf;
5+
6+
mod common;
87

98
#[cfg(unix)]
109
fn switch_stdout_to(file: File) {
@@ -35,16 +34,18 @@ fn switch_stdout_to(file: File) {
3534
}
3635
}
3736

38-
fn main() {
39-
let path = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap());
40-
let path = path.join("switch-stdout-output");
37+
#[test]
38+
fn switch_stdout() {
39+
let temp = common::tmpdir();
40+
let path = temp.join("switch-stdout-output");
4141
let f = File::create(&path).unwrap();
4242

43-
println!("foo");
44-
std::io::stdout().flush().unwrap();
43+
let mut stdout = std::io::stdout();
44+
stdout.write(b"foo\n").unwrap();
45+
stdout.flush().unwrap();
4546
switch_stdout_to(f);
46-
println!("bar");
47-
std::io::stdout().flush().unwrap();
47+
stdout.write(b"bar\n").unwrap();
48+
stdout.flush().unwrap();
4849

4950
let mut contents = String::new();
5051
File::open(&path).unwrap().read_to_string(&mut contents).unwrap();

0 commit comments

Comments
 (0)