diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2022-04-17 17:47:24 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-17 17:47:24 +0200 |
commit | 9c5928b5aa3716f7441694da24982cecacb7a061 (patch) | |
tree | 0c3e750337774162dfb2910cf462b9b7e0b8d4ba /cli/tests/integration/bench_tests.rs | |
parent | 19bb82aa40eabd9a06ba6650558653ec88d19a96 (diff) |
fix: panic when trying to pledge permissions before restoring previous pledge (#14306)
This commit fixes and edge case, where testing/benching code could pledge new
permission set before restoring the previous pledge.
Appropriate panics were added and tests that assert that process is killed
in case of "recursive pledge".
Diffstat (limited to 'cli/tests/integration/bench_tests.rs')
-rw-r--r-- | cli/tests/integration/bench_tests.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/cli/tests/integration/bench_tests.rs b/cli/tests/integration/bench_tests.rs index 2df08bdb5..7b4fbb0a5 100644 --- a/cli/tests/integration/bench_tests.rs +++ b/cli/tests/integration/bench_tests.rs @@ -1,6 +1,7 @@ // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. use crate::itest; +use test_util as util; itest!(requires_unstable { args: "bench bench/requires_unstable.js", @@ -139,3 +140,21 @@ itest!(no_prompt_with_denied_perms { exit_code: 1, output: "bench/no_prompt_with_denied_perms.out", }); + +#[test] +fn recursive_permissions_pledge() { + let output = util::deno_cmd() + .current_dir(util::testdata_path()) + .arg("bench") + .arg("--unstable") + .arg("bench/recursive_permissions_pledge.js") + .stderr(std::process::Stdio::piped()) + .spawn() + .unwrap() + .wait_with_output() + .unwrap(); + assert!(!output.status.success()); + assert!(String::from_utf8(output.stderr).unwrap().contains( + "pledge test permissions called before restoring previous pledge" + )); +} |