diff --git a/cli/op_error.rs b/cli/op_error.rs index a687eed2b7..73f7640a8e 100644 --- a/cli/op_error.rs +++ b/cli/op_error.rs @@ -319,6 +319,7 @@ impl From 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, diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index c88c595875..651ffa110e 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -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")); +}