diff options
Diffstat (limited to 'cli/tools/test.rs')
-rw-r--r-- | cli/tools/test.rs | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/cli/tools/test.rs b/cli/tools/test.rs index 35c0ea079..9d1774fff 100644 --- a/cli/tools/test.rs +++ b/cli/tools/test.rs @@ -37,6 +37,7 @@ use deno_runtime::fmt_errors::format_js_error; use deno_runtime::ops::io::Stdio; use deno_runtime::ops::io::StdioPipe; use deno_runtime::permissions::Permissions; +use deno_runtime::permissions::PermissionsContainer; use deno_runtime::tokio_util::run_local; use indexmap::IndexMap; use log::Level; @@ -723,7 +724,7 @@ async fn test_specifier( let mut worker = create_main_worker_for_test_or_bench( &ps, specifier.clone(), - permissions, + PermissionsContainer::new(permissions), vec![ops::testing::init( sender, fail_fast_tracker, @@ -895,11 +896,8 @@ async fn fetch_inline_files( ) -> Result<Vec<File>, AnyError> { let mut files = Vec::new(); for specifier in specifiers { - let mut fetch_permissions = Permissions::allow_all(); - let file = ps - .file_fetcher - .fetch(&specifier, &mut fetch_permissions) - .await?; + let fetch_permissions = PermissionsContainer::allow_all(); + let file = ps.file_fetcher.fetch(&specifier, fetch_permissions).await?; let inline_files = if file.media_type == MediaType::Unknown { extract_files_from_fenced_blocks( @@ -957,8 +955,8 @@ pub async fn check_specifiers( specifiers, false, lib, - Permissions::allow_all(), - permissions.clone(), + PermissionsContainer::new(Permissions::allow_all()), + PermissionsContainer::new(permissions.clone()), false, ) .await?; @@ -979,8 +977,8 @@ pub async fn check_specifiers( module_specifiers, false, lib, - Permissions::allow_all(), - permissions, + PermissionsContainer::allow_all(), + PermissionsContainer::new(permissions), true, ) .await?; @@ -1324,7 +1322,7 @@ async fn fetch_specifiers_with_test_mode( for (specifier, mode) in &mut specifiers_with_mode { let file = ps .file_fetcher - .fetch(specifier, &mut Permissions::allow_all()) + .fetch(specifier, PermissionsContainer::allow_all()) .await?; if file.media_type == MediaType::Unknown @@ -1342,6 +1340,9 @@ pub async fn run_tests( test_flags: TestFlags, ) -> Result<(), AnyError> { let ps = ProcState::build(flags).await?; + // Various test files should not share the same permissions in terms of + // `PermissionsContainer` - otherwise granting/revoking permissions in one + // file would have impact on other files, which is undesirable. let permissions = Permissions::from_options(&ps.options.permissions_options())?; let specifiers_with_mode = fetch_specifiers_with_test_mode( @@ -1383,6 +1384,9 @@ pub async fn run_tests_with_watch( test_flags: TestFlags, ) -> Result<(), AnyError> { let ps = ProcState::build(flags).await?; + // Various test files should not share the same permissions in terms of + // `PermissionsContainer` - otherwise granting/revoking permissions in one + // file would have impact on other files, which is undesirable. let permissions = Permissions::from_options(&ps.options.permissions_options())?; |