diff options
Diffstat (limited to 'tests/util/server/src/lib.rs')
-rw-r--r-- | tests/util/server/src/lib.rs | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/tests/util/server/src/lib.rs b/tests/util/server/src/lib.rs index 88e8287e0..89dc1ffc3 100644 --- a/tests/util/server/src/lib.rs +++ b/tests/util/server/src/lib.rs @@ -1,8 +1,5 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -#![allow(clippy::print_stdout)] -#![allow(clippy::print_stderr)] - use std::collections::HashMap; use std::env; use std::io::Write; @@ -55,6 +52,7 @@ static GUARD: Lazy<Mutex<HttpServerCount>> = Lazy::new(Default::default); pub fn env_vars_for_npm_tests() -> Vec<(String, String)> { vec![ ("NPM_CONFIG_REGISTRY".to_string(), npm_registry_url()), + ("NODEJS_ORG_MIRROR".to_string(), nodejs_org_mirror_url()), ("NO_COLOR".to_string(), "1".to_string()), ] } @@ -133,6 +131,7 @@ pub fn env_vars_for_jsr_npm_tests() -> Vec<(String, String)> { ), ("DISABLE_JSR_PROVENANCE".to_string(), "true".to_string()), ("NO_COLOR".to_string(), "1".to_string()), + ("NODEJS_ORG_MIRROR".to_string(), nodejs_org_mirror_url()), ] } @@ -178,27 +177,41 @@ pub fn deno_config_path() -> PathRef { /// Test server registry url. pub fn npm_registry_url() -> String { - "http://localhost:4260/".to_string() + format!("http://localhost:{}/", servers::PUBLIC_NPM_REGISTRY_PORT) } pub fn npm_registry_unset_url() -> String { "http://NPM_CONFIG_REGISTRY.is.unset".to_string() } +pub fn nodejs_org_mirror_url() -> String { + format!( + "http://127.0.0.1:{}/", + servers::NODEJS_ORG_MIRROR_SERVER_PORT + ) +} + +pub fn nodejs_org_mirror_unset_url() -> String { + "http://NODEJS_ORG_MIRROR.is.unset".to_string() +} + pub fn jsr_registry_url() -> String { - "http://127.0.0.1:4250/".to_string() + format!("http://127.0.0.1:{}/", servers::JSR_REGISTRY_SERVER_PORT) } pub fn rekor_url() -> String { - "http://127.0.0.1:4251".to_string() + format!("http://127.0.0.1:{}", servers::PROVENANCE_MOCK_SERVER_PORT) } pub fn fulcio_url() -> String { - "http://127.0.0.1:4251".to_string() + format!("http://127.0.0.1:{}", servers::PROVENANCE_MOCK_SERVER_PORT) } pub fn gha_token_url() -> String { - "http://127.0.0.1:4251/gha_oidc?test=true".to_string() + format!( + "http://127.0.0.1:{}/gha_oidc?test=true", + servers::PROVENANCE_MOCK_SERVER_PORT + ) } pub fn jsr_registry_unset_url() -> String { @@ -302,12 +315,15 @@ async fn get_tcp_listener_stream( .collect::<Vec<_>>(); // Eye catcher for HttpServerCount - println!("ready: {name} on {:?}", addresses); + #[allow(clippy::print_stdout)] + { + println!("ready: {name} on {:?}", addresses); + } futures::stream::select_all(listeners) } -pub const TEST_SERVERS_COUNT: usize = 30; +pub const TEST_SERVERS_COUNT: usize = 33; #[derive(Default)] struct HttpServerCount { @@ -345,7 +361,10 @@ struct HttpServerStarter { impl Default for HttpServerStarter { fn default() -> Self { - println!("test_server starting..."); + #[allow(clippy::print_stdout)] + { + println!("test_server starting..."); + } let mut test_server = Command::new(test_server_path()) .current_dir(testdata_path()) .stdout(Stdio::piped()) @@ -479,6 +498,7 @@ pub fn run_collect( } = prog.wait_with_output().expect("failed to wait on child"); let stdout = String::from_utf8(stdout).unwrap(); let stderr = String::from_utf8(stderr).unwrap(); + #[allow(clippy::print_stderr)] if expect_success != status.success() { eprintln!("stdout: <<<{stdout}>>>"); eprintln!("stderr: <<<{stderr}>>>"); @@ -539,6 +559,7 @@ pub fn run_and_collect_output_with_args( } = deno.wait_with_output().expect("failed to wait on child"); let stdout = String::from_utf8(stdout).unwrap(); let stderr = String::from_utf8(stderr).unwrap(); + #[allow(clippy::print_stderr)] if expect_success != status.success() { eprintln!("stdout: <<<{stdout}>>>"); eprintln!("stderr: <<<{stderr}>>>"); @@ -560,9 +581,11 @@ pub fn deno_cmd_with_deno_dir(deno_dir: &TempDir) -> TestCommandBuilder { TestCommandBuilder::new(deno_dir.clone()) .env("DENO_DIR", deno_dir.path()) .env("NPM_CONFIG_REGISTRY", npm_registry_unset_url()) + .env("NODEJS_ORG_MIRROR", nodejs_org_mirror_unset_url()) .env("JSR_URL", jsr_registry_unset_url()) } +#[allow(clippy::print_stdout)] pub fn run_powershell_script_file( script_file_path: &str, args: Vec<&str>, @@ -654,6 +677,7 @@ impl<'a> CheckOutputIntegrationTest<'a> { } pub fn wildcard_match(pattern: &str, text: &str) -> bool { + #[allow(clippy::print_stderr)] match wildcard_match_detailed(pattern, text) { WildcardMatchResult::Success => true, WildcardMatchResult::Fail(debug_output) => { |