summaryrefslogtreecommitdiffstats
path: root/tests/ui/std
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:59:24 +0000
commit023939b627b7dc93b01471f7d41fb8553ddb4ffa (patch)
tree60fc59477c605c72b0a1051409062ddecc43f877 /tests/ui/std
parentAdding debian version 1.72.1+dfsg1-1. (diff)
downloadrustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.tar.xz
rustc-023939b627b7dc93b01471f7d41fb8553ddb4ffa.zip
Merging upstream version 1.73.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/std')
-rw-r--r--tests/ui/std/issue-15149.rs57
-rw-r--r--tests/ui/std/switch-stdout.rs52
2 files changed, 0 insertions, 109 deletions
diff --git a/tests/ui/std/issue-15149.rs b/tests/ui/std/issue-15149.rs
deleted file mode 100644
index 064472f57..000000000
--- a/tests/ui/std/issue-15149.rs
+++ /dev/null
@@ -1,57 +0,0 @@
-// run-pass
-
-#![allow(unused_variables)]
-// no-prefer-dynamic
-// ignore-cross-compile
-
-use std::env;
-use std::ffi::OsStr;
-use std::fs;
-use std::path::PathBuf;
-use std::process;
-use std::str;
-
-fn main() {
- // If we're the child, make sure we were invoked correctly
- let args: Vec<String> = env::args().collect();
- if args.len() > 1 && args[1] == "child" {
- // FIXME: This should check the whole `args[0]` instead of just
- // checking that it ends_with the executable name. This
- // is needed because of Windows, which has a different behavior.
- // See #15149 for more info.
- let my_path = env::current_exe().unwrap();
- return assert_eq!(my_path.file_stem(), Some(OsStr::new("mytest")));
- }
-
- test();
-}
-
-fn test() {
- // If we're the parent, copy our own binary to a new directory.
- let my_path = env::current_exe().unwrap();
- let my_dir = my_path.parent().unwrap();
-
- let child_dir = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap());
- let child_dir = child_dir.join("issue-15140-child");
- fs::create_dir_all(&child_dir).unwrap();
-
- let child_path = child_dir.join(&format!("mytest{}", env::consts::EXE_SUFFIX));
- fs::copy(&my_path, &child_path).unwrap();
-
- // Append the new directory to our own PATH.
- let path = {
- let mut paths: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap()).collect();
- paths.push(child_dir.to_path_buf());
- env::join_paths(paths).unwrap()
- };
-
- let child_output =
- process::Command::new("mytest").env("PATH", &path).arg("child").output().unwrap();
-
- assert!(
- child_output.status.success(),
- "child assertion failed\n child stdout:\n {}\n child stderr:\n {}",
- str::from_utf8(&child_output.stdout).unwrap(),
- str::from_utf8(&child_output.stderr).unwrap()
- );
-}
diff --git a/tests/ui/std/switch-stdout.rs b/tests/ui/std/switch-stdout.rs
deleted file mode 100644
index 2d936d96b..000000000
--- a/tests/ui/std/switch-stdout.rs
+++ /dev/null
@@ -1,52 +0,0 @@
-// run-pass
-// ignore-wasm (needs file descriptors and env variables)
-
-use std::env;
-use std::fs::File;
-use std::io::{Read, Write};
-use std::path::PathBuf;
-
-#[cfg(unix)]
-fn switch_stdout_to(file: File) {
- use std::os::unix::prelude::*;
-
- extern "C" {
- fn dup2(old: i32, new: i32) -> i32;
- }
-
- unsafe {
- assert_eq!(dup2(file.as_raw_fd(), 1), 1);
- }
-}
-
-#[cfg(windows)]
-fn switch_stdout_to(file: File) {
- use std::os::windows::prelude::*;
-
- extern "system" {
- fn SetStdHandle(nStdHandle: u32, handle: *mut u8) -> i32;
- }
-
- const STD_OUTPUT_HANDLE: u32 = (-11i32) as u32;
-
- unsafe {
- let rc = SetStdHandle(STD_OUTPUT_HANDLE, file.into_raw_handle() as *mut _);
- assert!(rc != 0);
- }
-}
-
-fn main() {
- let path = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap());
- let path = path.join("switch-stdout-output");
- let f = File::create(&path).unwrap();
-
- println!("foo");
- std::io::stdout().flush().unwrap();
- switch_stdout_to(f);
- println!("bar");
- std::io::stdout().flush().unwrap();
-
- let mut contents = String::new();
- File::open(&path).unwrap().read_to_string(&mut contents).unwrap();
- assert_eq!(contents, "bar\n");
-}