mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 23:34:47 -05:00
fix: Deno.setRaw shouldn't panic on ENOTTY (#6630)
This commit is contained in:
parent
2b52e3daf1
commit
ab4c574f52
2 changed files with 21 additions and 0 deletions
|
@ -319,6 +319,7 @@ impl From<nix::Error> for OpError {
|
|||
nix::Error::Sys(EPERM) => ErrorKind::PermissionDenied,
|
||||
nix::Error::Sys(EINVAL) => ErrorKind::TypeError,
|
||||
nix::Error::Sys(ENOENT) => ErrorKind::NotFound,
|
||||
nix::Error::Sys(ENOTTY) => ErrorKind::BadResource,
|
||||
nix::Error::Sys(UnknownErrno) => unreachable!(),
|
||||
nix::Error::Sys(_) => unreachable!(),
|
||||
nix::Error::InvalidPath => ErrorKind::TypeError,
|
||||
|
|
|
@ -3063,3 +3063,23 @@ fn exec_path() {
|
|||
let expected = std::fs::canonicalize(util::deno_exe_path()).unwrap();
|
||||
assert_eq!(expected, actual);
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
#[test]
|
||||
fn set_raw_should_not_panic_on_no_tty() {
|
||||
let output = util::deno_cmd()
|
||||
.arg("eval")
|
||||
.arg("--unstable")
|
||||
.arg("Deno.setRaw(Deno.stdin.rid, true)")
|
||||
// stdin set to piped so it certainly does not refer to TTY
|
||||
.stdin(std::process::Stdio::piped())
|
||||
// stderr is piped so we can capture output.
|
||||
.stderr(std::process::Stdio::piped())
|
||||
.spawn()
|
||||
.unwrap()
|
||||
.wait_with_output()
|
||||
.unwrap();
|
||||
assert!(!output.status.success());
|
||||
let stderr = std::str::from_utf8(&output.stderr).unwrap().trim();
|
||||
assert!(stderr.contains("BadResource"));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue