Skip to content

Commit

Permalink
Add failing test for denoland#9750
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Sep 6, 2021
1 parent c132c86 commit aee9a66
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
31 changes: 31 additions & 0 deletions cli/tests/integration/run_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1805,3 +1805,34 @@ itest!(byte_order_mark {
args: "run --no-check byte_order_mark.ts",
output: "byte_order_mark.out",
});

#[cfg(unix)]
#[test]
fn issue9750() {
use util::pty::fork::*;
let deno_exe = util::deno_exe_path();
let fork = Fork::from_ptmx().unwrap();
if let Ok(mut master) = fork.is_parent() {
use std::io::Read;
use std::io::Write;

master.write_all(b"yy\n").unwrap();

let mut output = String::new();
master.read_to_string(&mut output).unwrap();
assert!(!output.contains("secret"));
println!("out: {}", output);

fork.wait().unwrap();
} else {
std::env::set_var("SECRET", "secret");
std::env::set_current_dir(util::testdata_path()).unwrap();
let err = exec::Command::new(deno_exe)
.arg("run")
.arg("--prompt")
.arg("issue9750.js")
.exec();
println!("err {}", err);
unreachable!()
}
}
6 changes: 6 additions & 0 deletions cli/tests/testdata/issue9750.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Run without permissions.
const buf = new Uint8Array(1);
console.log("Enter 'yy':");
await Deno.stdin.read(buf);
await Deno.permissions.request({ "name": "env" });
console.log("\n\nOwned", Deno.env.get("SECRET"));

0 comments on commit aee9a66

Please sign in to comment.