1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-21 15:04:11 -05:00

chore: remove print debugging from test server (#26529)

Accidentally added in https://github.com/denoland/deno/pull/26473/files
This commit is contained in:
David Sherret 2024-10-24 18:06:17 -04:00 committed by GitHub
parent 8dd6177c62
commit e162306247
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 65 additions and 32 deletions

View file

@ -78,6 +78,7 @@ impl DiagnosticLogger {
logger.write_all(text.as_ref().as_bytes()).unwrap();
logger.write_all(b"\n").unwrap();
}
#[allow(clippy::print_stderr)]
None => eprintln!("{}", text.as_ref()),
}
}

View file

@ -285,7 +285,10 @@ impl PathRef {
#[track_caller]
pub fn assert_matches_file(&self, wildcard_file: impl AsRef<Path>) -> &Self {
let wildcard_file = testdata_path().join(wildcard_file);
#[allow(clippy::print_stdout)]
{
println!("output path {}", wildcard_file);
}
let expected_text = wildcard_file.read_to_string();
self.assert_matches_text(&expected_text)
}

View file

@ -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;
@ -302,7 +299,10 @@ async fn get_tcp_listener_stream(
.collect::<Vec<_>>();
// Eye catcher for HttpServerCount
#[allow(clippy::print_stdout)]
{
println!("ready: {name} on {:?}", addresses);
}
futures::stream::select_all(listeners)
}
@ -345,7 +345,10 @@ struct HttpServerStarter {
impl Default for HttpServerStarter {
fn default() -> Self {
#[allow(clippy::print_stdout)]
{
println!("test_server starting...");
}
let mut test_server = Command::new(test_server_path())
.current_dir(testdata_path())
.stdout(Stdio::piped())
@ -360,7 +363,6 @@ impl Default for HttpServerStarter {
let mut ready_count = 0;
for maybe_line in lines {
if let Ok(line) = maybe_line {
eprintln!("LINE: {}", line);
if line.starts_with("ready:") {
ready_count += 1;
}
@ -480,6 +482,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}>>>");
@ -540,6 +543,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}>>>");
@ -564,6 +568,7 @@ pub fn deno_cmd_with_deno_dir(deno_dir: &TempDir) -> TestCommandBuilder {
.env("JSR_URL", jsr_registry_unset_url())
}
#[allow(clippy::print_stdout)]
pub fn run_powershell_script_file(
script_file_path: &str,
args: Vec<&str>,
@ -655,6 +660,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) => {

View file

@ -157,6 +157,7 @@ impl LspStdoutReader {
self.pending_messages.0.lock().len()
}
#[allow(clippy::print_stderr)]
pub fn output_pending_messages(&self) {
let messages = self.pending_messages.0.lock();
eprintln!("{:?}", messages);
@ -573,6 +574,7 @@ impl LspClientBuilder {
for line in stderr.lines() {
match line {
Ok(line) => {
#[allow(clippy::print_stderr)]
if print_stderr {
eprintln!("{}", line);
}
@ -587,11 +589,14 @@ impl LspClientBuilder {
continue;
}
Err(err) => {
#[allow(clippy::print_stderr)]
{
eprintln!("failed to parse perf record: {:#}", err);
}
}
}
}
}
tx.send(line).unwrap();
}
Err(err) => {
@ -782,11 +787,14 @@ impl LspClient {
std::thread::sleep(Duration::from_millis(20));
}
#[allow(clippy::print_stderr)]
{
eprintln!("==== STDERR OUTPUT ====");
for line in found_lines {
eprintln!("{}", line)
}
eprintln!("== END STDERR OUTPUT ==");
}
panic!("Timed out waiting on condition.")
}

View file

@ -103,7 +103,6 @@ impl TestNpmRegistry {
}
pub fn root_dir(&self) -> PathRef {
eprintln!("root {}", self.local_path);
tests_path().join("registry").join(&self.local_path)
}
@ -120,7 +119,6 @@ impl TestNpmRegistry {
}
pub fn registry_file(&self, name: &str) -> Result<Option<Vec<u8>>> {
eprintln!("registry file {}", name);
self.get_package_property(name, |p| p.registry_file.as_bytes().to_vec())
}
@ -138,7 +136,6 @@ impl TestNpmRegistry {
package_name: &str,
func: impl FnOnce(&CustomNpmPackage) -> TResult,
) -> Result<Option<TResult>> {
eprintln!("get package property {}", package_name);
// it's ok if multiple threads race here as they will do the same work twice
if !self.cache.lock().contains_key(package_name) {
match get_npm_package(&self.hostname, &self.local_path, package_name)? {
@ -155,7 +152,6 @@ impl TestNpmRegistry {
&self,
uri_path: &'s str,
) -> Option<(&'s str, &'s str)> {
eprintln!("GEETT {}", uri_path);
let prefix1 = format!("/{}/", DENOTEST_SCOPE_NAME);
let prefix2 = format!("/{}%2f", DENOTEST_SCOPE_NAME);
@ -198,10 +194,6 @@ fn get_npm_package(
local_path: &str,
package_name: &str,
) -> Result<Option<CustomNpmPackage>> {
eprintln!(
"get npm package {} {} {}",
registry_hostname, local_path, package_name
);
let registry_hostname = if package_name == "@denotest/tarballs-privateserver2"
{
"http://localhost:4262"

View file

@ -61,7 +61,10 @@ impl Pty {
if is_windows && *IS_CI {
// the pty tests don't really start up on the windows CI for some reason
// so ignore them for now
#[allow(clippy::print_stderr)]
{
eprintln!("Ignoring windows CI.");
}
false
} else {
true
@ -250,11 +253,14 @@ impl Pty {
}
let text = self.next_text();
#[allow(clippy::print_stderr)]
{
eprintln!(
"------ Start Full Text ------\n{:?}\n------- End Full Text -------",
String::from_utf8_lossy(&self.read_bytes)
);
eprintln!("Next text: {:?}", text);
}
false
}

View file

@ -42,7 +42,10 @@ where
let fut: Pin<Box<dyn Future<Output = Result<(), anyhow::Error>>>> =
async move {
let listener = TcpListener::bind(options.addr).await?;
#[allow(clippy::print_stdout)]
{
println!("ready: {}", options.addr);
}
loop {
let (stream, _) = listener.accept().await?;
let io = TokioIo::new(stream);
@ -58,6 +61,7 @@ where
if let Err(e) = fut.await {
let err_str = e.to_string();
#[allow(clippy::print_stderr)]
if !err_str.contains("early eof") {
eprintln!("{}: {:?}", options.error_msg, e);
}
@ -89,6 +93,7 @@ pub async fn run_server_with_acceptor<'a, A, F, S>(
if let Err(e) = fut.await {
let err_str = e.to_string();
#[allow(clippy::print_stderr)]
if !err_str.contains("early eof") {
eprintln!("{}: {:?}", error_msg, e);
}
@ -135,6 +140,7 @@ async fn hyper_serve_connection<I, F, S>(
if let Err(e) = result {
let err_str = e.to_string();
#[allow(clippy::print_stderr)]
if !err_str.contains("early eof") {
eprintln!("{}: {:?}", error_msg, e);
}

View file

@ -198,7 +198,6 @@ fn json_body(value: serde_json::Value) -> UnsyncBoxBody<Bytes, Infallible> {
/// Benchmark server that just serves "hello world" responses.
async fn hyper_hello(port: u16) {
println!("hyper hello");
let addr = SocketAddr::from(([127, 0, 0, 1], port));
let handler = move |_: Request<hyper::body::Incoming>| async move {
Ok::<_, anyhow::Error>(Response::new(UnsyncBoxBody::new(
@ -342,7 +341,10 @@ async fn get_tcp_listener_stream(
.collect::<Vec<_>>();
// Eye catcher for HttpServerCount
#[allow(clippy::print_stdout)]
{
println!("ready: {name} on {:?}", addresses);
}
futures::stream::select_all(listeners)
}
@ -358,7 +360,10 @@ async fn run_tls_client_auth_server(port: u16) {
while let Some(Ok(mut tls_stream)) = tls.next().await {
tokio::spawn(async move {
let Ok(handshake) = tls_stream.handshake().await else {
#[allow(clippy::print_stderr)]
{
eprintln!("Failed to handshake");
}
return;
};
// We only need to check for the presence of client certificates
@ -405,7 +410,6 @@ async fn absolute_redirect(
.collect();
if let Some(url) = query_params.get("redirect_to") {
println!("URL: {url:?}");
let redirect = redirect_resp(url.to_owned());
return Ok(redirect);
}
@ -413,7 +417,6 @@ async fn absolute_redirect(
if path.starts_with("/REDIRECT") {
let url = &req.uri().path()[9..];
println!("URL: {url:?}");
let redirect = redirect_resp(url.to_string());
return Ok(redirect);
}
@ -1357,6 +1360,7 @@ async fn wrap_client_auth_https_server(port: u16) {
// here. Rusttls ensures that they are valid and signed by the CA.
match handshake.has_peer_certificates {
true => { yield Ok(tls); },
#[allow(clippy::print_stderr)]
false => { eprintln!("https_client_auth: no valid client certificate"); },
};
}

View file

@ -76,6 +76,7 @@ pub async fn run_wss2_server(port: u16) {
let server: Handshake<_, Bytes> = h2.handshake(tls);
let mut server = match server.await {
Ok(server) => server,
#[allow(clippy::print_stdout)]
Err(e) => {
println!("Failed to handshake h2: {e:?}");
return;
@ -87,6 +88,7 @@ pub async fn run_wss2_server(port: u16) {
};
let (recv, send) = match conn {
Ok(conn) => conn,
#[allow(clippy::print_stdout)]
Err(e) => {
println!("Failed to accept a connection: {e:?}");
break;
@ -137,6 +139,7 @@ where
.map_err(|e| anyhow!("Error upgrading websocket connection: {}", e))
.unwrap();
#[allow(clippy::print_stderr)]
if let Err(e) = handler(ws).await {
eprintln!("Error in websocket connection: {}", e);
}
@ -152,6 +155,7 @@ where
.serve_connection(io, service)
.with_upgrades();
#[allow(clippy::print_stderr)]
if let Err(e) = conn.await {
eprintln!("websocket server error: {e:?}");
}
@ -162,16 +166,19 @@ async fn handle_wss_stream(
recv: Request<RecvStream>,
mut send: SendResponse<Bytes>,
) -> Result<(), h2::Error> {
#[allow(clippy::print_stderr)]
if recv.method() != Method::CONNECT {
eprintln!("wss2: refusing non-CONNECT stream");
send.send_reset(Reason::REFUSED_STREAM);
return Ok(());
}
#[allow(clippy::print_stderr)]
let Some(protocol) = recv.extensions().get::<h2::ext::Protocol>() else {
eprintln!("wss2: refusing no-:protocol stream");
send.send_reset(Reason::REFUSED_STREAM);
return Ok(());
};
#[allow(clippy::print_stderr)]
if protocol.as_str() != "websocket" && protocol.as_str() != "WebSocket" {
eprintln!("wss2: refusing non-websocket stream");
send.send_reset(Reason::REFUSED_STREAM);