From 7c090b1b14e6b5000dbbed434525387c414ca62c Mon Sep 17 00:00:00 2001 From: David Sherret Date: Mon, 27 Feb 2023 16:52:49 -0400 Subject: chore: test builders for integration tests (#17965) Start of adding test builders to simplify integration tests. I only updated a few test files. We can complete upgrading over time. --- cli/tests/integration/bench_tests.rs | 39 ++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 20 deletions(-) (limited to 'cli/tests/integration/bench_tests.rs') diff --git a/cli/tests/integration/bench_tests.rs b/cli/tests/integration/bench_tests.rs index 240c4b2d4..4e94463e5 100644 --- a/cli/tests/integration/bench_tests.rs +++ b/cli/tests/integration/bench_tests.rs @@ -2,7 +2,11 @@ use deno_core::url::Url; use test_util as util; +use util::assert_contains; +use util::assert_exit_code; +use util::assert_output_file; use util::env_vars_for_npm_tests; +use util::TestContext; itest!(overloads { args: "bench bench/overloads.ts", @@ -187,19 +191,16 @@ itest!(json_output { #[test] fn recursive_permissions_pledge() { - let output = util::deno_cmd() - .current_dir(util::testdata_path()) - .arg("bench") - .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( + let context = TestContext::default(); + let output = context + .new_command() + .args("bench bench/recursive_permissions_pledge.js") + .run(); + assert_exit_code!(output, 1); + assert_contains!( + output.text(), "pledge test permissions called before restoring previous pledge" - )); + ); } #[test] @@ -208,14 +209,12 @@ fn file_protocol() { Url::from_file_path(util::testdata_path().join("bench/file_protocol.ts")) .unwrap() .to_string(); - - (util::CheckOutputIntegrationTest { - args_vec: vec!["bench", &file_url], - exit_code: 0, - output: "bench/file_protocol.out", - ..Default::default() - }) - .run(); + let context = TestContext::default(); + let output = context + .new_command() + .args(format!("bench bench/file_protocol.ts {file_url}")) + .run(); + assert_output_file!(output, "bench/file_protocol.out"); } itest!(package_json_basic { -- cgit v1.2.3