diff options
author | uki00a <uki00a@gmail.com> | 2020-07-07 07:26:34 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-07-06 18:26:34 -0400 |
commit | ab4c574f5202f607ceb6068f56b3cc8aed1bbbaf (patch) | |
tree | 3575905a85bbb6ba988733baad0d38de2d01d2c1 /cli | |
parent | 2b52e3daf168c6fd0f3d13afcd827cc5b3a284ca (diff) |
fix: Deno.setRaw shouldn't panic on ENOTTY (#6630)
Diffstat (limited to 'cli')
-rw-r--r-- | cli/op_error.rs | 1 | ||||
-rw-r--r-- | cli/tests/integration_tests.rs | 20 |
2 files changed, 21 insertions, 0 deletions
diff --git a/cli/op_error.rs b/cli/op_error.rs index a687eed2b..73f7640a8 100644 --- a/cli/op_error.rs +++ b/cli/op_error.rs @@ -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, diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index c88c59587..651ffa110 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")); +} |