Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(integration_tests): stop collecting unnecessary output in permissions tests #5926

Merged
merged 1 commit into from
May 28, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
142 changes: 77 additions & 65 deletions cli/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}

Expand All @@ -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());
}
}

Expand Down Expand Up @@ -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());
}
}

Expand Down Expand Up @@ -2012,53 +2021,56 @@ 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());
}
}

#[test]
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());
}
}

#[test]
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());
}
}

Expand Down