mirror of
https://github.com/denoland/deno.git
synced 2024-11-25 15:29:32 -05:00
fix(test/bench): accept file protocol module specifier CLI args (#14429)
This commit is contained in:
parent
66b9187a2d
commit
256dcb058a
8 changed files with 58 additions and 7 deletions
|
@ -253,6 +253,7 @@ where
|
|||
let lowercase_path = path.to_lowercase();
|
||||
if lowercase_path.starts_with("http://")
|
||||
|| lowercase_path.starts_with("https://")
|
||||
|| lowercase_path.starts_with("file://")
|
||||
{
|
||||
let url = ModuleSpecifier::parse(&path)?;
|
||||
prepared.push(url);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use crate::itest;
|
||||
use deno_core::url::Url;
|
||||
use test_util as util;
|
||||
|
||||
itest!(requires_unstable {
|
||||
|
@ -171,3 +172,19 @@ fn recursive_permissions_pledge() {
|
|||
"pledge test permissions called before restoring previous pledge"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_protocol() {
|
||||
let file_url =
|
||||
Url::from_file_path(util::testdata_path().join("bench/file_protocol.ts"))
|
||||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
(util::CheckOutputIntegrationTest {
|
||||
args_vec: vec!["bench", "--unstable", &file_url],
|
||||
exit_code: 0,
|
||||
output: "bench/file_protocol.out",
|
||||
..Default::default()
|
||||
})
|
||||
.run();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
use crate::itest;
|
||||
use deno_core::url::Url;
|
||||
use test_util as util;
|
||||
|
||||
#[test]
|
||||
|
@ -351,3 +352,19 @@ fn recursive_permissions_pledge() {
|
|||
"pledge test permissions called before restoring previous pledge"
|
||||
));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn file_protocol() {
|
||||
let file_url =
|
||||
Url::from_file_path(util::testdata_path().join("test/file_protocol.ts"))
|
||||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
(util::CheckOutputIntegrationTest {
|
||||
args_vec: vec!["test", &file_url],
|
||||
exit_code: 0,
|
||||
output: "test/file_protocol.out",
|
||||
..Default::default()
|
||||
})
|
||||
.run();
|
||||
}
|
||||
|
|
8
cli/tests/testdata/bench/file_protocol.out
vendored
Normal file
8
cli/tests/testdata/bench/file_protocol.out
vendored
Normal file
|
@ -0,0 +1,8 @@
|
|||
Check file://[WILDCARD]/bench/file_protocol.ts
|
||||
cpu: [WILDCARD]
|
||||
runtime: deno [WILDCARD] ([WILDCARD])
|
||||
|
||||
[WILDCARD]/bench/file_protocol.ts
|
||||
benchmark time (avg) (min … max) p75 p99 p995
|
||||
------------------------------------------------- -----------------------------
|
||||
bench0 [WILDCARD] [WILDCARD]/iter[WILDCARD]([WILDCARD] … [WILDCARD]) [WILDCARD]
|
1
cli/tests/testdata/bench/file_protocol.ts
vendored
Normal file
1
cli/tests/testdata/bench/file_protocol.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Deno.bench("bench0", () => {});
|
6
cli/tests/testdata/test/file_protocol.out
vendored
Normal file
6
cli/tests/testdata/test/file_protocol.out
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
Check file://[WILDCARD]/test/file_protocol.ts
|
||||
running 1 test from ./test/file_protocol.ts
|
||||
test 0 ... ok ([WILDCARD])
|
||||
|
||||
test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out ([WILDCARD])
|
||||
|
1
cli/tests/testdata/test/file_protocol.ts
vendored
Normal file
1
cli/tests/testdata/test/file_protocol.ts
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
Deno.test("test 0", () => {});
|
|
@ -1728,18 +1728,18 @@ pub fn run_powershell_script_file(
|
|||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct CheckOutputIntegrationTest {
|
||||
pub args: &'static str,
|
||||
pub args_vec: Vec<&'static str>,
|
||||
pub output: &'static str,
|
||||
pub input: Option<&'static str>,
|
||||
pub output_str: Option<&'static str>,
|
||||
pub struct CheckOutputIntegrationTest<'a> {
|
||||
pub args: &'a str,
|
||||
pub args_vec: Vec<&'a str>,
|
||||
pub output: &'a str,
|
||||
pub input: Option<&'a str>,
|
||||
pub output_str: Option<&'a str>,
|
||||
pub exit_code: i32,
|
||||
pub http_server: bool,
|
||||
pub envs: Vec<(String, String)>,
|
||||
}
|
||||
|
||||
impl CheckOutputIntegrationTest {
|
||||
impl<'a> CheckOutputIntegrationTest<'a> {
|
||||
pub fn run(&self) {
|
||||
let args = if self.args_vec.is_empty() {
|
||||
std::borrow::Cow::Owned(self.args.split_whitespace().collect::<Vec<_>>())
|
||||
|
|
Loading…
Reference in a new issue