Skip to content

Commit

Permalink
Auto merge of #92201 - ChrisDenton:fix-tests, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Fix failing tests

Fixes tests that have been failing in CI.

I hope it's ok but I've temporarily commented out some of the Windows resolver tests. I actually have a bigger fix for that test code as part of another PR. I could separate it out and patch as necessary but I'd prefer not to rush into that if possible.

r? `@Mark-Simulacrum`
  • Loading branch information
bors committed Dec 22, 2021
2 parents e100ec5 + 615604f commit 34926f0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 7 additions & 3 deletions library/std/src/process/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ use super::{Command, Output, Stdio};
use crate::io::ErrorKind;
use crate::str;

fn known_command() -> Command {
if cfg!(windows) { Command::new("help") } else { Command::new("echo") }
}

#[cfg(target_os = "android")]
fn shell_cmd() -> Command {
Command::new("/system/bin/sh")
Expand Down Expand Up @@ -305,23 +309,23 @@ fn test_interior_nul_in_progname_is_error() {

#[test]
fn test_interior_nul_in_arg_is_error() {
match Command::new("rustc").arg("has-some-\0\0s-inside").spawn() {
match known_command().arg("has-some-\0\0s-inside").spawn() {
Err(e) => assert_eq!(e.kind(), ErrorKind::InvalidInput),
Ok(_) => panic!(),
}
}

#[test]
fn test_interior_nul_in_args_is_error() {
match Command::new("rustc").args(&["has-some-\0\0s-inside"]).spawn() {
match known_command().args(&["has-some-\0\0s-inside"]).spawn() {
Err(e) => assert_eq!(e.kind(), ErrorKind::InvalidInput),
Ok(_) => panic!(),
}
}

#[test]
fn test_interior_nul_in_current_dir_is_error() {
match Command::new("rustc").current_dir("has-some-\0\0s-inside").spawn() {
match known_command().current_dir("has-some-\0\0s-inside").spawn() {
Err(e) => assert_eq!(e.kind(), ErrorKind::InvalidInput),
Ok(_) => panic!(),
}
Expand Down
4 changes: 4 additions & 0 deletions library/std/src/sys/windows/process/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ fn windows_exe_resolver() {
io::ErrorKind::InvalidInput
);

/* FIXME: fix and re-enable these tests before making changes to the resolver.
/*
Some of the following tests may need to be changed if you are deliberately
changing the behaviour of `resolve_exe`.
Expand All @@ -179,4 +181,6 @@ fn windows_exe_resolver() {
// The application's directory is also searched.
let current_exe = env::current_exe().unwrap();
assert!(resolve_exe(current_exe.file_name().unwrap().as_ref(), None).is_ok());
*/
}

0 comments on commit 34926f0

Please sign in to comment.