mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 09:31:22 -05:00
fix test_raw_tty hang (#8520)
This commit is contained in:
parent
22f951aa67
commit
29374db11f
3 changed files with 52 additions and 14 deletions
40
Cargo.lock
generated
40
Cargo.lock
generated
|
@ -448,6 +448,7 @@ dependencies = [
|
|||
"dprint-plugin-typescript",
|
||||
"encoding_rs",
|
||||
"env_logger",
|
||||
"exec",
|
||||
"filetime",
|
||||
"fwdansi",
|
||||
"http",
|
||||
|
@ -700,6 +701,37 @@ dependencies = [
|
|||
"winapi 0.2.8",
|
||||
]
|
||||
|
||||
[[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"
|
||||
|
@ -909,6 +941,12 @@ dependencies = [
|
|||
"byteorder",
|
||||
]
|
||||
|
||||
[[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"
|
||||
|
@ -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",
|
||||
]
|
||||
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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!()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue