Skip to content

Commit 2f093c6

Browse files
committed
Move two tests from tests/ui/std to library/std/tests
1 parent e94bda3 commit 2f093c6

File tree

2 files changed

+16
-38
lines changed

2 files changed

+16
-38
lines changed

tests/ui/std/issue-15149.rs renamed to library/std/tests/issue-15149.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

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
// run-pass
2-
// ignore-wasm (needs file descriptors and env variables)
3-
4-
use std::env;
51
use std::fs::File;
62
use std::io::{Read, Write};
7-
use std::path::PathBuf;
3+
4+
mod common;
85

96
#[cfg(unix)]
107
fn switch_stdout_to(file: File) {
@@ -35,16 +32,18 @@ fn switch_stdout_to(file: File) {
3532
}
3633
}
3734

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

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

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

0 commit comments

Comments
 (0)