From 0dced3d15748014489ea880a2593478720a282eb Mon Sep 17 00:00:00 2001 From: uki00a Date: Fri, 29 May 2020 03:55:45 +0900 Subject: [PATCH] chore(integration_tests): stop collecting unnecessary output in permissions tests --- cli/tests/integration_tests.rs | 142 ++++++++++++++++++--------------- 1 file changed, 77 insertions(+), 65 deletions(-) diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index a9d3ebd6c194a5..606a4051697021 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -1862,14 +1862,17 @@ fn cafile_bundle_remote_exports() { #[test] fn test_permissions_with_allow() { for permission in &util::PERMISSION_VARIANTS { - let (_, err) = util::run_and_collect_output( - true, - &format!("run --allow-{0} permission_test.ts {0}Required", permission), - None, - None, - false, - ); - assert!(!err.contains(util::PERMISSION_DENIED_PATTERN)); + let status = util::deno_cmd() + .current_dir(&util::tests_path()) + .arg("run") + .arg(format!("--allow-{0}", permission)) + .arg("permission_test.ts") + .arg(format!("{0}Required", permission)) + .spawn() + .unwrap() + .wait() + .unwrap(); + assert!(status.success()); } } @@ -1891,19 +1894,22 @@ fn test_permissions_without_allow() { fn test_permissions_rw_inside_project_dir() { const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"]; for permission in &PERMISSION_VARIANTS { - let (_, err) = util::run_and_collect_output( - true, - &format!( - "run --allow-{0}={1} complex_permissions_test.ts {0} {2} {2}", + let status = util::deno_cmd() + .current_dir(&util::tests_path()) + .arg("run") + .arg(format!( + "--allow-{0}={1}", permission, - util::root_path().into_os_string().into_string().unwrap(), - "complex_permissions_test.ts" - ), - None, - None, - false, - ); - assert!(!err.contains(util::PERMISSION_DENIED_PATTERN)); + util::root_path().into_os_string().into_string().unwrap() + )) + .arg("complex_permissions_test.ts") + .arg(permission) + .arg("complex_permissions_test.ts") + .spawn() + .unwrap() + .wait() + .unwrap(); + assert!(status.success()); } } @@ -1940,24 +1946,27 @@ fn test_permissions_rw_outside_test_dir() { fn test_permissions_rw_inside_test_dir() { const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"]; for permission in &PERMISSION_VARIANTS { - let (_, err) = util::run_and_collect_output( - true, - &format!( - "run --allow-{0}={1} complex_permissions_test.ts {0} {2}", + let status = util::deno_cmd() + .current_dir(&util::tests_path()) + .arg("run") + .arg(format!( + "--allow-{0}={1}", permission, util::root_path() .join("cli") .join("tests") .into_os_string() .into_string() - .unwrap(), - "complex_permissions_test.ts" - ), - None, - None, - false, - ); - assert!(!err.contains(util::PERMISSION_DENIED_PATTERN)); + .unwrap() + )) + .arg("complex_permissions_test.ts") + .arg(permission) + .arg("complex_permissions_test.ts") + .spawn() + .unwrap() + .wait() + .unwrap(); + assert!(status.success()); } } @@ -2012,17 +2021,18 @@ fn test_permissions_rw_inside_test_and_js_dir() { .into_string() .unwrap(); for permission in &PERMISSION_VARIANTS { - let (_, err) = util::run_and_collect_output( - true, - &format!( - "run --allow-{0}={1},{2} complex_permissions_test.ts {0} {3}", - permission, test_dir, js_dir, "complex_permissions_test.ts" - ), - None, - None, - false, - ); - assert!(!err.contains(util::PERMISSION_DENIED_PATTERN)); + let status = util::deno_cmd() + .current_dir(&util::tests_path()) + .arg("run") + .arg(format!("--allow-{0}={1},{2}", permission, test_dir, js_dir)) + .arg("complex_permissions_test.ts") + .arg(permission) + .arg("complex_permissions_test.ts") + .spawn() + .unwrap() + .wait() + .unwrap(); + assert!(status.success()); } } @@ -2030,17 +2040,18 @@ fn test_permissions_rw_inside_test_and_js_dir() { fn test_permissions_rw_relative() { const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"]; for permission in &PERMISSION_VARIANTS { - let (_, err) = util::run_and_collect_output( - true, - &format!( - "run --allow-{0}=. complex_permissions_test.ts {0} complex_permissions_test.ts", - permission - ), - None, - None, - false, - ); - assert!(!err.contains(util::PERMISSION_DENIED_PATTERN)); + let status = util::deno_cmd() + .current_dir(&util::tests_path()) + .arg("run") + .arg(format!("--allow-{0}=.", permission)) + .arg("complex_permissions_test.ts") + .arg(permission) + .arg("complex_permissions_test.ts") + .spawn() + .unwrap() + .wait() + .unwrap(); + assert!(status.success()); } } @@ -2048,17 +2059,18 @@ fn test_permissions_rw_relative() { fn test_permissions_rw_no_prefix() { const PERMISSION_VARIANTS: [&str; 2] = ["read", "write"]; for permission in &PERMISSION_VARIANTS { - let (_, err) = util::run_and_collect_output( - true, - &format!( - "run --allow-{0}=tls/../ complex_permissions_test.ts {0} complex_permissions_test.ts", - permission - ), - None, - None, - false, - ); - assert!(!err.contains(util::PERMISSION_DENIED_PATTERN)); + let status = util::deno_cmd() + .current_dir(&util::tests_path()) + .arg("run") + .arg(format!("--allow-{0}=tls/../", permission)) + .arg("complex_permissions_test.ts") + .arg(permission) + .arg("complex_permissions_test.ts") + .spawn() + .unwrap() + .wait() + .unwrap(); + assert!(status.success()); } }