mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
Remove unnecessary drop calls (#7007)
This commit is contained in:
parent
52c1017a74
commit
7d01fcbb77
8 changed files with 53 additions and 128 deletions
|
@ -797,7 +797,7 @@ mod tests {
|
|||
|
||||
#[tokio::test]
|
||||
async fn test_get_source_code_1() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (temp_dir, fetcher) = test_setup();
|
||||
let fetcher_1 = fetcher.clone();
|
||||
let fetcher_2 = fetcher.clone();
|
||||
|
@ -906,13 +906,11 @@ mod tests {
|
|||
assert_eq!(r4.source_code.bytes, expected4);
|
||||
// Resolved back to TypeScript
|
||||
assert_eq!(&(r4.media_type), &msg::MediaType::TypeScript);
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_source_code_2() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (temp_dir, fetcher) = test_setup();
|
||||
let module_url =
|
||||
Url::parse("http://localhost:4545/cli/tests/subdir/mismatch_ext.ts")
|
||||
|
@ -991,13 +989,11 @@ mod tests {
|
|||
assert_eq!(&(r3.media_type), &msg::MediaType::JavaScript);
|
||||
let (_, headers) = fetcher.http_cache.get(&module_url).unwrap();
|
||||
assert_eq!(headers.get("content-type").unwrap(), "text/javascript");
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_source_code_multiple_downloads_of_same_file() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let specifier = ModuleSpecifier::resolve_url(
|
||||
"http://localhost:4545/cli/tests/subdir/mismatch_ext.ts",
|
||||
|
@ -1038,12 +1034,11 @@ mod tests {
|
|||
let headers_file_modified_2 = headers_file_metadata_2.modified().unwrap();
|
||||
|
||||
assert_eq!(headers_file_modified, headers_file_modified_2);
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_source_code_3() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
|
||||
let redirect_module_url = Url::parse(
|
||||
|
@ -1091,13 +1086,11 @@ mod tests {
|
|||
assert!(headers.get("location").is_none());
|
||||
// Examine the meta result.
|
||||
assert_eq!(mod_meta.url, target_module_url);
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_source_code_4() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let double_redirect_url = Url::parse(
|
||||
"http://localhost:4548/cli/tests/subdir/redirects/redirect1.js",
|
||||
|
@ -1149,13 +1142,11 @@ mod tests {
|
|||
|
||||
// Examine the meta result.
|
||||
assert_eq!(mod_meta.url, target_url);
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_source_code_5() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
|
||||
let double_redirect_url = Url::parse(
|
||||
|
@ -1211,13 +1202,11 @@ mod tests {
|
|||
let file_modified_2 = file_metadata_2.modified().unwrap();
|
||||
|
||||
assert_eq!(file_modified, file_modified_2);
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_source_code_6() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let double_redirect_url = Url::parse(
|
||||
"http://localhost:4548/cli/tests/subdir/redirects/redirect1.js",
|
||||
|
@ -1253,13 +1242,11 @@ mod tests {
|
|||
|
||||
let result = fetcher.fetch_cached_remote_source(&double_redirect_url, 1);
|
||||
assert!(result.is_err());
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_source_code_7() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
|
||||
// Testing redirect with Location set to absolute url.
|
||||
|
@ -1308,13 +1295,11 @@ mod tests {
|
|||
assert!(headers.get("location").is_none());
|
||||
// Examine the meta result.
|
||||
assert_eq!(mod_meta.url, target_module_url);
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_source_no_remote() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let module_url =
|
||||
Url::parse("http://localhost:4545/cli/tests/002_hello.ts").unwrap();
|
||||
|
@ -1332,13 +1317,11 @@ mod tests {
|
|||
// FIXME(bartlomieju):
|
||||
// let err = result.err().unwrap();
|
||||
// assert_eq!(err.kind(), ErrorKind::NotFound);
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_get_source_cached_only() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let fetcher_1 = fetcher.clone();
|
||||
let fetcher_2 = fetcher.clone();
|
||||
|
@ -1384,12 +1367,11 @@ mod tests {
|
|||
)
|
||||
.await;
|
||||
assert!(result.is_ok());
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_source_0() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let module_url =
|
||||
Url::parse("http://127.0.0.1:4545/cli/tests/subdir/mt_video_mp2t.t3.ts")
|
||||
|
@ -1424,13 +1406,11 @@ mod tests {
|
|||
assert_eq!(r2.source_code.bytes, b"export const loaded = true;\n");
|
||||
// Not MediaType::TypeScript due to .headers.json modification
|
||||
assert_eq!(&(r2.media_type), &msg::MediaType::JavaScript);
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn fetch_remote_source_no_ext() {
|
||||
let g = test_util::http_server();
|
||||
let _g = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let module_url =
|
||||
&Url::parse("http://localhost:4545/cli/tests/subdir/no_ext").unwrap();
|
||||
|
@ -1449,12 +1429,11 @@ mod tests {
|
|||
assert_eq!(&(r.media_type), &msg::MediaType::TypeScript);
|
||||
let (_, headers) = fetcher.http_cache.get(module_url).unwrap();
|
||||
assert_eq!(headers.get("content-type").unwrap(), "text/typescript");
|
||||
drop(g)
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn fetch_remote_source_mismatch_ext() {
|
||||
let g = test_util::http_server();
|
||||
let _g = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let module_url =
|
||||
&Url::parse("http://localhost:4545/cli/tests/subdir/mismatch_ext.ts")
|
||||
|
@ -1474,12 +1453,11 @@ mod tests {
|
|||
assert_eq!(&(r2.media_type), &msg::MediaType::JavaScript);
|
||||
let (_, headers) = fetcher.http_cache.get(module_url).unwrap();
|
||||
assert_eq!(headers.get("content-type").unwrap(), "text/javascript");
|
||||
drop(g);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn fetch_remote_source_unknown_ext() {
|
||||
let g = test_util::http_server();
|
||||
let _g = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let module_url =
|
||||
&Url::parse("http://localhost:4545/cli/tests/subdir/unknown_ext.deno")
|
||||
|
@ -1499,7 +1477,6 @@ mod tests {
|
|||
assert_eq!(&(r3.media_type), &msg::MediaType::TypeScript);
|
||||
let (_, headers) = fetcher.http_cache.get(module_url).unwrap();
|
||||
assert_eq!(headers.get("content-type").unwrap(), "text/typescript");
|
||||
drop(g);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
@ -1879,7 +1856,7 @@ mod tests {
|
|||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_with_etag() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let module_url =
|
||||
Url::parse("http://127.0.0.1:4545/etag_script.ts").unwrap();
|
||||
|
@ -1928,13 +1905,11 @@ mod tests {
|
|||
|
||||
// Assert that the file has not been modified
|
||||
assert_eq!(modified1, modified2);
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_with_types_header() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let module_url =
|
||||
Url::parse("http://127.0.0.1:4545/xTypeScriptTypes.js").unwrap();
|
||||
|
@ -1955,7 +1930,6 @@ mod tests {
|
|||
source.types_header,
|
||||
Some("./xTypeScriptTypes.d.ts".to_string())
|
||||
);
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
|
@ -2001,7 +1975,7 @@ mod tests {
|
|||
file_name: &str,
|
||||
expected_content: &str,
|
||||
) {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let (_temp_dir, fetcher) = test_setup();
|
||||
let module_url = Url::parse(&format!(
|
||||
"http://127.0.0.1:4545/cli/tests/encoding/{}",
|
||||
|
@ -2030,7 +2004,5 @@ mod tests {
|
|||
headers.get("content-type").unwrap(),
|
||||
&format!("application/typescript;charset={}", charset)
|
||||
);
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -236,7 +236,6 @@ mod tests {
|
|||
);
|
||||
assert_eq!(headers.get("etag").unwrap(), "as5625rqdsfb");
|
||||
assert_eq!(headers.get("foobar"), None);
|
||||
drop(dir);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
@ -248,7 +248,7 @@ mod tests {
|
|||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_string() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
// Relies on external http server. See target/debug/test_server
|
||||
let url =
|
||||
Url::parse("http://127.0.0.1:4545/cli/tests/fixture.json").unwrap();
|
||||
|
@ -262,12 +262,11 @@ mod tests {
|
|||
} else {
|
||||
panic!();
|
||||
}
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_gzip() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
// Relies on external http server. See target/debug/test_server
|
||||
let url = Url::parse(
|
||||
"http://127.0.0.1:4545/cli/tests/053_import_compression/gziped",
|
||||
|
@ -286,12 +285,11 @@ mod tests {
|
|||
} else {
|
||||
panic!();
|
||||
}
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_with_etag() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let url = Url::parse("http://127.0.0.1:4545/etag_script.ts").unwrap();
|
||||
let client = create_http_client(None).unwrap();
|
||||
let result = fetch_once(client.clone(), &url, None).await;
|
||||
|
@ -310,13 +308,11 @@ mod tests {
|
|||
let res =
|
||||
fetch_once(client, &url, Some("33a64df551425fcc55e".to_string())).await;
|
||||
assert_eq!(res.unwrap(), FetchOnceResult::NotModified);
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_brotli() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
// Relies on external http server. See target/debug/test_server
|
||||
let url = Url::parse(
|
||||
"http://127.0.0.1:4545/cli/tests/053_import_compression/brotli",
|
||||
|
@ -336,12 +332,11 @@ mod tests {
|
|||
} else {
|
||||
panic!();
|
||||
}
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_once_with_redirect() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
// Relies on external http server. See target/debug/test_server
|
||||
let url =
|
||||
Url::parse("http://127.0.0.1:4546/cli/tests/fixture.json").unwrap();
|
||||
|
@ -355,7 +350,6 @@ mod tests {
|
|||
} else {
|
||||
panic!();
|
||||
}
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -398,7 +392,7 @@ mod tests {
|
|||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_with_cafile_string() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
// Relies on external http server. See target/debug/test_server
|
||||
let url =
|
||||
Url::parse("https://localhost:5545/cli/tests/fixture.json").unwrap();
|
||||
|
@ -419,12 +413,11 @@ mod tests {
|
|||
} else {
|
||||
panic!();
|
||||
}
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_with_cafile_gzip() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
// Relies on external http server. See target/debug/test_server
|
||||
let url = Url::parse(
|
||||
"https://localhost:5545/cli/tests/053_import_compression/gziped",
|
||||
|
@ -449,12 +442,11 @@ mod tests {
|
|||
} else {
|
||||
panic!();
|
||||
}
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_with_cafile_with_etag() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let url = Url::parse("https://localhost:5545/etag_script.ts").unwrap();
|
||||
let client = create_http_client(Some(String::from(
|
||||
test_util::root_path()
|
||||
|
@ -480,13 +472,11 @@ mod tests {
|
|||
let res =
|
||||
fetch_once(client, &url, Some("33a64df551425fcc55e".to_string())).await;
|
||||
assert_eq!(res.unwrap(), FetchOnceResult::NotModified);
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn test_fetch_with_cafile_brotli() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
// Relies on external http server. See target/debug/test_server
|
||||
let url = Url::parse(
|
||||
"https://localhost:5545/cli/tests/053_import_compression/brotli",
|
||||
|
@ -512,6 +502,5 @@ mod tests {
|
|||
} else {
|
||||
panic!();
|
||||
}
|
||||
drop(http_server_guard);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -604,7 +604,7 @@ mod tests {
|
|||
#[ignore]
|
||||
#[tokio::test]
|
||||
async fn source_graph_fetch() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
|
||||
let module_specifier = ModuleSpecifier::resolve_url_or_path(
|
||||
"http://localhost:4545/cli/tests/019_media_types.ts",
|
||||
|
@ -692,12 +692,11 @@ mod tests {
|
|||
},
|
||||
])
|
||||
);
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn source_graph_type_references() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
|
||||
let module_specifier = ModuleSpecifier::resolve_url_or_path(
|
||||
"http://localhost:4545/cli/tests/type_definitions.ts",
|
||||
|
@ -749,13 +748,11 @@ mod tests {
|
|||
));
|
||||
assert!(graph
|
||||
.contains_key("http://localhost:4545/cli/tests/type_definitions/qat.ts"));
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn source_graph_type_references2() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
|
||||
let module_specifier = ModuleSpecifier::resolve_url_or_path(
|
||||
"http://localhost:4545/cli/tests/type_directives_02.ts",
|
||||
|
@ -799,12 +796,11 @@ mod tests {
|
|||
}
|
||||
])
|
||||
);
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn source_graph_type_references3() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
|
||||
let module_specifier = ModuleSpecifier::resolve_url_or_path(
|
||||
"http://localhost:4545/cli/tests/type_directives_01.ts",
|
||||
|
@ -842,12 +838,11 @@ mod tests {
|
|||
}
|
||||
])
|
||||
);
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn source_graph_different_langs() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
|
||||
// ModuleGraphLoader was mistakenly parsing this file as TSX
|
||||
// https://github.com/denoland/deno/issues/5867
|
||||
|
@ -860,8 +855,6 @@ mod tests {
|
|||
build_graph(&module_specifier)
|
||||
.await
|
||||
.expect("Failed to build graph");
|
||||
|
||||
drop(http_server_guard);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -710,7 +710,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_permissions_request_run() {
|
||||
let guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let _guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let mut perms0 = Permissions::from_flags(&Flags {
|
||||
..Default::default()
|
||||
});
|
||||
|
@ -722,12 +722,11 @@ mod tests {
|
|||
});
|
||||
set_prompt_result(false);
|
||||
assert_eq!(perms1.request_run(), PermissionState::Deny);
|
||||
drop(guard);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_permissions_request_read() {
|
||||
let guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let _guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let allowlist = vec![PathBuf::from("/foo/bar")];
|
||||
let mut perms0 = Permissions::from_flags(&Flags {
|
||||
read_allowlist: allowlist.clone(),
|
||||
|
@ -760,12 +759,11 @@ mod tests {
|
|||
perms2.request_read(&Some(Path::new("/foo/baz"))),
|
||||
PermissionState::Deny
|
||||
);
|
||||
drop(guard);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_permissions_request_write() {
|
||||
let guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let _guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let allowlist = vec![PathBuf::from("/foo/bar")];
|
||||
let mut perms0 = Permissions::from_flags(&Flags {
|
||||
write_allowlist: allowlist.clone(),
|
||||
|
@ -798,12 +796,11 @@ mod tests {
|
|||
perms2.request_write(&Some(Path::new("/foo/baz"))),
|
||||
PermissionState::Deny
|
||||
);
|
||||
drop(guard);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_permission_request_net() {
|
||||
let guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let _guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let allowlist = svec!["localhost:8080"];
|
||||
|
||||
let mut perms0 = Permissions::from_flags(&Flags {
|
||||
|
@ -876,13 +873,11 @@ mod tests {
|
|||
.kind_str,
|
||||
"URIError"
|
||||
);
|
||||
|
||||
drop(guard);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_permissions_request_env() {
|
||||
let guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let _guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let mut perms0 = Permissions::from_flags(&Flags {
|
||||
..Default::default()
|
||||
});
|
||||
|
@ -894,12 +889,11 @@ mod tests {
|
|||
});
|
||||
set_prompt_result(false);
|
||||
assert_eq!(perms1.request_env(), PermissionState::Deny);
|
||||
drop(guard);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_permissions_request_plugin() {
|
||||
let guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let _guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let mut perms0 = Permissions::from_flags(&Flags {
|
||||
..Default::default()
|
||||
});
|
||||
|
@ -911,12 +905,11 @@ mod tests {
|
|||
});
|
||||
set_prompt_result(false);
|
||||
assert_eq!(perms1.request_plugin(), PermissionState::Deny);
|
||||
drop(guard);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_permissions_request_hrtime() {
|
||||
let guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let _guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let mut perms0 = Permissions::from_flags(&Flags {
|
||||
..Default::default()
|
||||
});
|
||||
|
@ -928,7 +921,6 @@ mod tests {
|
|||
});
|
||||
set_prompt_result(false);
|
||||
assert_eq!(perms1.request_hrtime(), PermissionState::Deny);
|
||||
drop(guard);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -966,7 +958,7 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_fork() {
|
||||
let guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let _guard = PERMISSION_PROMPT_GUARD.lock().unwrap();
|
||||
let perms0 = Permissions::from_flags(&Flags {
|
||||
..Default::default()
|
||||
});
|
||||
|
@ -1028,6 +1020,5 @@ mod tests {
|
|||
allow_hrtime: PermissionState::Deny,
|
||||
}
|
||||
);
|
||||
drop(guard);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ fn std_lint() {
|
|||
|
||||
#[test]
|
||||
fn x_deno_warning() {
|
||||
let g = util::http_server();
|
||||
let _g = util::http_server();
|
||||
let output = util::deno_cmd()
|
||||
.current_dir(util::root_path())
|
||||
.arg("run")
|
||||
|
@ -67,7 +67,6 @@ fn x_deno_warning() {
|
|||
let stderr_str = std::str::from_utf8(&output.stderr).unwrap().trim();
|
||||
assert_eq!("testing x-deno-warning header", stdout_str);
|
||||
assert!(util::strip_ansi_codes(stderr_str).contains("Warning foobar"));
|
||||
drop(g);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -283,7 +282,7 @@ fn benchmark_test() {
|
|||
#[test]
|
||||
fn deno_dir_test() {
|
||||
use std::fs::remove_dir_all;
|
||||
let g = util::http_server();
|
||||
let _g = util::http_server();
|
||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
||||
remove_dir_all(deno_dir.path()).unwrap();
|
||||
|
||||
|
@ -316,13 +315,11 @@ fn deno_dir_test() {
|
|||
assert!(deno_dir.path().join("gen").is_dir());
|
||||
|
||||
remove_dir_all(deno_dir.path()).unwrap();
|
||||
drop(deno_dir);
|
||||
drop(g);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cache_test() {
|
||||
let g = util::http_server();
|
||||
let _g = util::http_server();
|
||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
||||
let module_url =
|
||||
url::Url::parse("http://localhost:4545/cli/tests/006_url_imports.ts")
|
||||
|
@ -339,7 +336,6 @@ fn cache_test() {
|
|||
assert_eq!(out, "");
|
||||
// TODO(ry) Is there some way to check that the file was actually cached in
|
||||
// DENO_DIR?
|
||||
drop(g);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -554,7 +550,7 @@ fn installer_test_local_module_run() {
|
|||
|
||||
#[test]
|
||||
fn installer_test_remote_module_run() {
|
||||
let g = util::http_server();
|
||||
let _g = util::http_server();
|
||||
let temp_dir = TempDir::new().expect("tempdir fail");
|
||||
let bin_dir = temp_dir.path().join("bin");
|
||||
std::fs::create_dir(&bin_dir).unwrap();
|
||||
|
@ -587,12 +583,11 @@ fn installer_test_remote_module_run() {
|
|||
.unwrap()
|
||||
.trim()
|
||||
.ends_with("hello, foo"));
|
||||
drop(g)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn js_unit_tests() {
|
||||
let g = util::http_server();
|
||||
let _g = util::http_server();
|
||||
let mut deno = util::deno_cmd()
|
||||
.current_dir(util::root_path())
|
||||
.arg("run")
|
||||
|
@ -606,7 +601,6 @@ fn js_unit_tests() {
|
|||
.spawn()
|
||||
.expect("failed to spawn script");
|
||||
let status = deno.wait().expect("failed to wait for the child process");
|
||||
drop(g);
|
||||
assert_eq!(Some(0), status.code());
|
||||
assert!(status.success());
|
||||
}
|
||||
|
@ -1399,7 +1393,7 @@ itest!(deno_test_only {
|
|||
|
||||
#[test]
|
||||
fn workers() {
|
||||
let g = util::http_server();
|
||||
let _g = util::http_server();
|
||||
let status = util::deno_cmd()
|
||||
.current_dir(util::tests_path())
|
||||
.arg("test")
|
||||
|
@ -1413,7 +1407,6 @@ fn workers() {
|
|||
.wait()
|
||||
.unwrap();
|
||||
assert!(status.success());
|
||||
drop(g);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -2244,7 +2237,7 @@ itest!(import_file_with_colon {
|
|||
#[test]
|
||||
fn cafile_env_fetch() {
|
||||
use url::Url;
|
||||
let g = util::http_server();
|
||||
let _g = util::http_server();
|
||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
||||
let module_url =
|
||||
Url::parse("https://localhost:5545/cli/tests/cafile_url_imports.ts")
|
||||
|
@ -2259,13 +2252,12 @@ fn cafile_env_fetch() {
|
|||
.output()
|
||||
.expect("Failed to spawn script");
|
||||
assert!(output.status.success());
|
||||
drop(g);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cafile_fetch() {
|
||||
use url::Url;
|
||||
let g = util::http_server();
|
||||
let _g = util::http_server();
|
||||
let deno_dir = TempDir::new().expect("tempdir fail");
|
||||
let module_url =
|
||||
Url::parse("http://localhost:4545/cli/tests/cafile_url_imports.ts")
|
||||
|
@ -2283,12 +2275,11 @@ fn cafile_fetch() {
|
|||
assert!(output.status.success());
|
||||
let out = std::str::from_utf8(&output.stdout).unwrap();
|
||||
assert_eq!(out, "");
|
||||
drop(g);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cafile_install_remote_module() {
|
||||
let g = util::http_server();
|
||||
let _g = util::http_server();
|
||||
let temp_dir = TempDir::new().expect("tempdir fail");
|
||||
let bin_dir = temp_dir.path().join("bin");
|
||||
std::fs::create_dir(&bin_dir).unwrap();
|
||||
|
@ -2324,15 +2315,11 @@ fn cafile_install_remote_module() {
|
|||
.expect("failed to spawn script");
|
||||
let stdout = std::str::from_utf8(&output.stdout).unwrap().trim();
|
||||
assert!(stdout.ends_with("foo"));
|
||||
|
||||
drop(deno_dir);
|
||||
drop(temp_dir);
|
||||
drop(g)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cafile_bundle_remote_exports() {
|
||||
let g = util::http_server();
|
||||
let _g = util::http_server();
|
||||
|
||||
// First we have to generate a bundle of some remote module that has exports.
|
||||
let mod1 = "https://localhost:5545/cli/tests/subdir/mod1.ts";
|
||||
|
@ -2374,8 +2361,6 @@ fn cafile_bundle_remote_exports() {
|
|||
.trim()
|
||||
.ends_with("Hello"));
|
||||
assert_eq!(output.stderr, b"");
|
||||
|
||||
drop(g)
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -3155,7 +3140,7 @@ async fn inspector_runtime_evaluate_does_not_crash() {
|
|||
}
|
||||
}
|
||||
|
||||
std::mem::drop(stdin);
|
||||
drop(stdin);
|
||||
child.wait().unwrap();
|
||||
}
|
||||
|
||||
|
|
|
@ -401,7 +401,7 @@ mod tests {
|
|||
|
||||
#[tokio::test]
|
||||
async fn execute_006_url_imports() {
|
||||
let http_server_guard = test_util::http_server();
|
||||
let _http_server_guard = test_util::http_server();
|
||||
let p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
|
||||
.parent()
|
||||
.unwrap()
|
||||
|
@ -441,7 +441,6 @@ mod tests {
|
|||
assert_eq!(state.metrics.resolve_count, 3);
|
||||
// Check that we've only invoked the compiler once.
|
||||
assert_eq!(state.global_state.compiler_starts.load(Ordering::SeqCst), 1);
|
||||
drop(http_server_guard);
|
||||
}
|
||||
|
||||
fn create_test_worker() -> MainWorker {
|
||||
|
|
|
@ -593,7 +593,7 @@ pub fn run_and_collect_output(
|
|||
if let Some(envs) = envs {
|
||||
deno_process_builder.envs(envs);
|
||||
}
|
||||
let http_guard = if need_http_server {
|
||||
let _http_guard = if need_http_server {
|
||||
Some(http_server())
|
||||
} else {
|
||||
None
|
||||
|
@ -612,7 +612,6 @@ pub fn run_and_collect_output(
|
|||
stderr,
|
||||
status,
|
||||
} = deno.wait_with_output().expect("failed to wait on child");
|
||||
drop(http_guard);
|
||||
let stdout = String::from_utf8(stdout).unwrap();
|
||||
let stderr = String::from_utf8(stderr).unwrap();
|
||||
if expect_success != status.success() {
|
||||
|
@ -705,7 +704,7 @@ impl CheckOutputIntegrationTest {
|
|||
println!("root path {}", root.display());
|
||||
println!("deno_exe path {}", deno_exe.display());
|
||||
|
||||
let http_server_guard = if self.http_server {
|
||||
let _http_server_guard = if self.http_server {
|
||||
Some(http_server())
|
||||
} else {
|
||||
None
|
||||
|
@ -742,8 +741,6 @@ impl CheckOutputIntegrationTest {
|
|||
let status = process.wait().expect("failed to finish process");
|
||||
let exit_code = status.code().unwrap();
|
||||
|
||||
drop(http_server_guard);
|
||||
|
||||
actual = strip_ansi_codes(&actual).to_string();
|
||||
|
||||
if self.exit_code != exit_code {
|
||||
|
|
Loading…
Reference in a new issue