2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2023-01-12 20:59:13 -05:00
|
|
|
|
2024-03-07 20:16:32 -05:00
|
|
|
use deno_core::serde_json::json;
|
2023-01-12 20:59:13 -05:00
|
|
|
use deno_core::url::Url;
|
|
|
|
use test_util as util;
|
2023-02-27 15:52:49 -05:00
|
|
|
use util::assert_contains;
|
2023-06-06 17:07:46 -04:00
|
|
|
use util::assert_not_contains;
|
2023-02-27 15:52:49 -05:00
|
|
|
use util::TestContext;
|
2024-03-07 20:16:32 -05:00
|
|
|
use util::TestContextBuilder;
|
2023-01-12 20:59:13 -05:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn recursive_permissions_pledge() {
|
2023-02-27 15:52:49 -05:00
|
|
|
let context = TestContext::default();
|
|
|
|
let output = context
|
|
|
|
.new_command()
|
2023-04-27 18:37:03 -04:00
|
|
|
.args("bench bench/recursive_permissions_pledge.js")
|
2023-02-27 15:52:49 -05:00
|
|
|
.run();
|
2023-02-28 14:10:12 -05:00
|
|
|
output.assert_exit_code(1);
|
2023-02-27 15:52:49 -05:00
|
|
|
assert_contains!(
|
2023-03-06 09:16:50 -05:00
|
|
|
output.combined_output(),
|
2023-01-12 20:59:13 -05:00
|
|
|
"pledge test permissions called before restoring previous pledge"
|
2023-02-27 15:52:49 -05:00
|
|
|
);
|
2023-01-12 20:59:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn file_protocol() {
|
|
|
|
let file_url =
|
|
|
|
Url::from_file_path(util::testdata_path().join("bench/file_protocol.ts"))
|
|
|
|
.unwrap()
|
|
|
|
.to_string();
|
2023-02-27 15:52:49 -05:00
|
|
|
let context = TestContext::default();
|
2023-02-28 14:10:12 -05:00
|
|
|
context
|
2023-02-27 15:52:49 -05:00
|
|
|
.new_command()
|
|
|
|
.args(format!("bench bench/file_protocol.ts {file_url}"))
|
2023-02-28 14:10:12 -05:00
|
|
|
.run()
|
|
|
|
.assert_matches_file("bench/file_protocol.out");
|
2023-01-12 20:59:13 -05:00
|
|
|
}
|
2023-02-23 10:58:10 -05:00
|
|
|
|
2023-06-06 17:07:46 -04:00
|
|
|
#[test]
|
|
|
|
fn conditionally_loads_type_graph() {
|
|
|
|
let context = TestContext::default();
|
|
|
|
let output = context
|
|
|
|
.new_command()
|
|
|
|
.args("bench --reload -L debug run/type_directives_js_main.js")
|
|
|
|
.run();
|
2024-04-18 21:43:28 -04:00
|
|
|
output.assert_matches_text("[WILDCARD] - FileFetcher::fetch_no_follow_with_options - specifier: file:///[WILDCARD]/subdir/type_reference.d.ts[WILDCARD]");
|
2023-06-06 17:07:46 -04:00
|
|
|
let output = context
|
|
|
|
.new_command()
|
|
|
|
.args("bench --reload -L debug --no-check run/type_directives_js_main.js")
|
|
|
|
.run();
|
|
|
|
assert_not_contains!(output.combined_output(), "type_reference.d.ts");
|
|
|
|
}
|
2024-03-07 20:16:32 -05:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn opt_out_top_level_exclude_via_bench_unexclude() {
|
|
|
|
let context = TestContextBuilder::new().use_temp_cwd().build();
|
|
|
|
let temp_dir = context.temp_dir().path();
|
|
|
|
temp_dir.join("deno.json").write_json(&json!({
|
|
|
|
"bench": {
|
|
|
|
"exclude": [ "!excluded.bench.ts" ]
|
|
|
|
},
|
|
|
|
"exclude": [ "excluded.bench.ts", "actually_excluded.bench.ts" ]
|
|
|
|
}));
|
|
|
|
|
|
|
|
temp_dir
|
|
|
|
.join("main.bench.ts")
|
|
|
|
.write("Deno.bench('test1', () => {});");
|
|
|
|
temp_dir
|
|
|
|
.join("excluded.bench.ts")
|
|
|
|
.write("Deno.bench('test2', () => {});");
|
|
|
|
temp_dir
|
|
|
|
.join("actually_excluded.bench.ts")
|
|
|
|
.write("Deno.bench('test3', () => {});");
|
|
|
|
|
|
|
|
let output = context.new_command().arg("bench").run();
|
|
|
|
output.assert_exit_code(0);
|
|
|
|
let output = output.combined_output();
|
|
|
|
assert_contains!(output, "main.bench.ts");
|
|
|
|
assert_contains!(output, "excluded.bench.ts");
|
|
|
|
assert_not_contains!(output, "actually_excluded.bench.ts");
|
|
|
|
}
|