diff options
author | Ryan Dahl <ry@tinyclouds.org> | 2020-11-27 12:08:28 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-27 12:08:28 -0500 |
commit | 29374db11fdadd7ec6271cc05de29039fcc02f87 (patch) | |
tree | a28fd7ba9cd8ed6edb1ba0829d1d97a87e039dd4 | |
parent | 22f951aa67c5b677d156ec338f71714cf2d4ddb2 (diff) |
fix test_raw_tty hang (#8520)
-rw-r--r-- | Cargo.lock | 40 | ||||
-rw-r--r-- | cli/Cargo.toml | 3 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 23 |
3 files changed, 52 insertions, 14 deletions
diff --git a/Cargo.lock b/Cargo.lock index a27257bba..6fe44c3a6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -448,6 +448,7 @@ dependencies = [ "dprint-plugin-typescript", "encoding_rs", "env_logger", + "exec", "filetime", "fwdansi", "http", @@ -701,6 +702,37 @@ dependencies = [ ] [[package]] +name = "errno" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa68f2fb9cae9d37c9b2b3584aba698a2e97f72d7aef7b9f7aa71d8b54ce46fe" +dependencies = [ + "errno-dragonfly", + "libc", + "winapi 0.3.9", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14ca354e36190500e1e1fb267c647932382b54053c50b14970856c0b00a35067" +dependencies = [ + "gcc", + "libc", +] + +[[package]] +name = "exec" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "886b70328cba8871bfc025858e1de4be16b1d5088f2ba50b57816f4210672615" +dependencies = [ + "errno 0.2.7", + "libc", +] + +[[package]] name = "fake-simd" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -910,6 +942,12 @@ dependencies = [ ] [[package]] +name = "gcc" +version = "0.3.55" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f5f3913fa0bfe7ee1fd8248b6b9f42a5af4b9d65ec2dd2c3c26132b950ecfc2" + +[[package]] name = "generic-array" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1775,7 +1813,7 @@ version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f50f3d255966981eb4e4c5df3e983e6f7d163221f547406d83b6a460ff5c5ee8" dependencies = [ - "errno", + "errno 0.1.8", "libc", ] diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 347db66a2..732adebeb 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -94,6 +94,9 @@ chrono = "0.4.15" os_pipe = "0.9.2" test_util = { path = "../test_util" } +[target.'cfg(unix)'.dev-dependencies] +exec = "0.3.1" # Used in test_raw_tty + [package.metadata.winres] # This section defines the metadata that appears in the deno.exe PE header. OriginalFilename = "deno.exe" diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index a7e901d83..e57b682c5 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -176,8 +176,9 @@ fn no_color() { pub fn test_raw_tty() { use std::io::{Read, Write}; use util::pty::fork::*; + let deno_exe = util::deno_exe_path(); - let deno_dir = TempDir::new().expect("tempdir fail"); + let root_path = util::root_path(); let fork = Fork::from_ptmx().unwrap(); if let Ok(mut master) = fork.is_parent() { @@ -193,10 +194,10 @@ pub fn test_raw_tty() { master.write_all(b"c").unwrap(); nread = master.read(&mut obytes).unwrap(); assert_eq!(String::from_utf8_lossy(&obytes[0..nread]), "C"); + fork.wait().unwrap(); } else { use nix::sys::termios; use std::os::unix::io::AsRawFd; - use std::process::*; // Turn off echo such that parent is reading works properly. let stdin_fd = std::io::stdin().as_raw_fd(); @@ -204,20 +205,16 @@ pub fn test_raw_tty() { t.local_flags.remove(termios::LocalFlags::ECHO); termios::tcsetattr(stdin_fd, termios::SetArg::TCSANOW, &t).unwrap(); - let mut child = Command::new(deno_exe) - .env("DENO_DIR", deno_dir.path()) - .current_dir(util::root_path()) + std::env::set_current_dir(root_path).unwrap(); + let err = exec::Command::new(deno_exe) .arg("run") .arg("--unstable") + .arg("--quiet") + .arg("--no-check") .arg("cli/tests/raw_mode.ts") - .stdin(Stdio::inherit()) - .stdout(Stdio::inherit()) - // Warning: errors may be swallowed. Try to comment stderr null if - // experiencing problems. - .stderr(Stdio::null()) - .spawn() - .expect("Failed to spawn script"); - child.wait().unwrap(); + .exec(); + println!("err {}", err); + unreachable!() } } |