Skip to content

Commit e162306

Browse files
authored
chore: remove print debugging from test server (denoland#26529)
Accidentally added in https://github.com/denoland/deno/pull/26473/files
1 parent 8dd6177 commit e162306

File tree

9 files changed

+65
-32
lines changed

9 files changed

+65
-32
lines changed

tests/util/server/src/builders.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ impl DiagnosticLogger {
7878
logger.write_all(text.as_ref().as_bytes()).unwrap();
7979
logger.write_all(b"\n").unwrap();
8080
}
81+
#[allow(clippy::print_stderr)]
8182
None => eprintln!("{}", text.as_ref()),
8283
}
8384
}

tests/util/server/src/fs.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,10 @@ impl PathRef {
285285
#[track_caller]
286286
pub fn assert_matches_file(&self, wildcard_file: impl AsRef<Path>) -> &Self {
287287
let wildcard_file = testdata_path().join(wildcard_file);
288-
println!("output path {}", wildcard_file);
288+
#[allow(clippy::print_stdout)]
289+
{
290+
println!("output path {}", wildcard_file);
291+
}
289292
let expected_text = wildcard_file.read_to_string();
290293
self.assert_matches_text(&expected_text)
291294
}

tests/util/server/src/lib.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
22

3-
#![allow(clippy::print_stdout)]
4-
#![allow(clippy::print_stderr)]
5-
63
use std::collections::HashMap;
74
use std::env;
85
use std::io::Write;
@@ -302,7 +299,10 @@ async fn get_tcp_listener_stream(
302299
.collect::<Vec<_>>();
303300

304301
// Eye catcher for HttpServerCount
305-
println!("ready: {name} on {:?}", addresses);
302+
#[allow(clippy::print_stdout)]
303+
{
304+
println!("ready: {name} on {:?}", addresses);
305+
}
306306

307307
futures::stream::select_all(listeners)
308308
}
@@ -345,7 +345,10 @@ struct HttpServerStarter {
345345

346346
impl Default for HttpServerStarter {
347347
fn default() -> Self {
348-
println!("test_server starting...");
348+
#[allow(clippy::print_stdout)]
349+
{
350+
println!("test_server starting...");
351+
}
349352
let mut test_server = Command::new(test_server_path())
350353
.current_dir(testdata_path())
351354
.stdout(Stdio::piped())
@@ -360,7 +363,6 @@ impl Default for HttpServerStarter {
360363
let mut ready_count = 0;
361364
for maybe_line in lines {
362365
if let Ok(line) = maybe_line {
363-
eprintln!("LINE: {}", line);
364366
if line.starts_with("ready:") {
365367
ready_count += 1;
366368
}
@@ -480,6 +482,7 @@ pub fn run_collect(
480482
} = prog.wait_with_output().expect("failed to wait on child");
481483
let stdout = String::from_utf8(stdout).unwrap();
482484
let stderr = String::from_utf8(stderr).unwrap();
485+
#[allow(clippy::print_stderr)]
483486
if expect_success != status.success() {
484487
eprintln!("stdout: <<<{stdout}>>>");
485488
eprintln!("stderr: <<<{stderr}>>>");
@@ -540,6 +543,7 @@ pub fn run_and_collect_output_with_args(
540543
} = deno.wait_with_output().expect("failed to wait on child");
541544
let stdout = String::from_utf8(stdout).unwrap();
542545
let stderr = String::from_utf8(stderr).unwrap();
546+
#[allow(clippy::print_stderr)]
543547
if expect_success != status.success() {
544548
eprintln!("stdout: <<<{stdout}>>>");
545549
eprintln!("stderr: <<<{stderr}>>>");
@@ -564,6 +568,7 @@ pub fn deno_cmd_with_deno_dir(deno_dir: &TempDir) -> TestCommandBuilder {
564568
.env("JSR_URL", jsr_registry_unset_url())
565569
}
566570

571+
#[allow(clippy::print_stdout)]
567572
pub fn run_powershell_script_file(
568573
script_file_path: &str,
569574
args: Vec<&str>,
@@ -655,6 +660,7 @@ impl<'a> CheckOutputIntegrationTest<'a> {
655660
}
656661

657662
pub fn wildcard_match(pattern: &str, text: &str) -> bool {
663+
#[allow(clippy::print_stderr)]
658664
match wildcard_match_detailed(pattern, text) {
659665
WildcardMatchResult::Success => true,
660666
WildcardMatchResult::Fail(debug_output) => {

tests/util/server/src/lsp.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ impl LspStdoutReader {
157157
self.pending_messages.0.lock().len()
158158
}
159159

160+
#[allow(clippy::print_stderr)]
160161
pub fn output_pending_messages(&self) {
161162
let messages = self.pending_messages.0.lock();
162163
eprintln!("{:?}", messages);
@@ -573,6 +574,7 @@ impl LspClientBuilder {
573574
for line in stderr.lines() {
574575
match line {
575576
Ok(line) => {
577+
#[allow(clippy::print_stderr)]
576578
if print_stderr {
577579
eprintln!("{}", line);
578580
}
@@ -587,7 +589,10 @@ impl LspClientBuilder {
587589
continue;
588590
}
589591
Err(err) => {
590-
eprintln!("failed to parse perf record: {:#}", err);
592+
#[allow(clippy::print_stderr)]
593+
{
594+
eprintln!("failed to parse perf record: {:#}", err);
595+
}
591596
}
592597
}
593598
}
@@ -782,11 +787,14 @@ impl LspClient {
782787
std::thread::sleep(Duration::from_millis(20));
783788
}
784789

785-
eprintln!("==== STDERR OUTPUT ====");
786-
for line in found_lines {
787-
eprintln!("{}", line)
790+
#[allow(clippy::print_stderr)]
791+
{
792+
eprintln!("==== STDERR OUTPUT ====");
793+
for line in found_lines {
794+
eprintln!("{}", line)
795+
}
796+
eprintln!("== END STDERR OUTPUT ==");
788797
}
789-
eprintln!("== END STDERR OUTPUT ==");
790798

791799
panic!("Timed out waiting on condition.")
792800
}

tests/util/server/src/npm.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ impl TestNpmRegistry {
103103
}
104104

105105
pub fn root_dir(&self) -> PathRef {
106-
eprintln!("root {}", self.local_path);
107106
tests_path().join("registry").join(&self.local_path)
108107
}
109108

@@ -120,7 +119,6 @@ impl TestNpmRegistry {
120119
}
121120

122121
pub fn registry_file(&self, name: &str) -> Result<Option<Vec<u8>>> {
123-
eprintln!("registry file {}", name);
124122
self.get_package_property(name, |p| p.registry_file.as_bytes().to_vec())
125123
}
126124

@@ -138,7 +136,6 @@ impl TestNpmRegistry {
138136
package_name: &str,
139137
func: impl FnOnce(&CustomNpmPackage) -> TResult,
140138
) -> Result<Option<TResult>> {
141-
eprintln!("get package property {}", package_name);
142139
// it's ok if multiple threads race here as they will do the same work twice
143140
if !self.cache.lock().contains_key(package_name) {
144141
match get_npm_package(&self.hostname, &self.local_path, package_name)? {
@@ -155,7 +152,6 @@ impl TestNpmRegistry {
155152
&self,
156153
uri_path: &'s str,
157154
) -> Option<(&'s str, &'s str)> {
158-
eprintln!("GEETT {}", uri_path);
159155
let prefix1 = format!("/{}/", DENOTEST_SCOPE_NAME);
160156
let prefix2 = format!("/{}%2f", DENOTEST_SCOPE_NAME);
161157

@@ -198,10 +194,6 @@ fn get_npm_package(
198194
local_path: &str,
199195
package_name: &str,
200196
) -> Result<Option<CustomNpmPackage>> {
201-
eprintln!(
202-
"get npm package {} {} {}",
203-
registry_hostname, local_path, package_name
204-
);
205197
let registry_hostname = if package_name == "@denotest/tarballs-privateserver2"
206198
{
207199
"http://localhost:4262"

tests/util/server/src/pty.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ impl Pty {
6161
if is_windows && *IS_CI {
6262
// the pty tests don't really start up on the windows CI for some reason
6363
// so ignore them for now
64-
eprintln!("Ignoring windows CI.");
64+
#[allow(clippy::print_stderr)]
65+
{
66+
eprintln!("Ignoring windows CI.");
67+
}
6568
false
6669
} else {
6770
true
@@ -250,11 +253,14 @@ impl Pty {
250253
}
251254

252255
let text = self.next_text();
253-
eprintln!(
254-
"------ Start Full Text ------\n{:?}\n------- End Full Text -------",
255-
String::from_utf8_lossy(&self.read_bytes)
256-
);
257-
eprintln!("Next text: {:?}", text);
256+
#[allow(clippy::print_stderr)]
257+
{
258+
eprintln!(
259+
"------ Start Full Text ------\n{:?}\n------- End Full Text -------",
260+
String::from_utf8_lossy(&self.read_bytes)
261+
);
262+
eprintln!("Next text: {:?}", text);
263+
}
258264

259265
false
260266
}

tests/util/server/src/servers/hyper_utils.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,10 @@ where
4242
let fut: Pin<Box<dyn Future<Output = Result<(), anyhow::Error>>>> =
4343
async move {
4444
let listener = TcpListener::bind(options.addr).await?;
45-
println!("ready: {}", options.addr);
45+
#[allow(clippy::print_stdout)]
46+
{
47+
println!("ready: {}", options.addr);
48+
}
4649
loop {
4750
let (stream, _) = listener.accept().await?;
4851
let io = TokioIo::new(stream);
@@ -58,6 +61,7 @@ where
5861

5962
if let Err(e) = fut.await {
6063
let err_str = e.to_string();
64+
#[allow(clippy::print_stderr)]
6165
if !err_str.contains("early eof") {
6266
eprintln!("{}: {:?}", options.error_msg, e);
6367
}
@@ -89,6 +93,7 @@ pub async fn run_server_with_acceptor<'a, A, F, S>(
8993

9094
if let Err(e) = fut.await {
9195
let err_str = e.to_string();
96+
#[allow(clippy::print_stderr)]
9297
if !err_str.contains("early eof") {
9398
eprintln!("{}: {:?}", error_msg, e);
9499
}
@@ -135,6 +140,7 @@ async fn hyper_serve_connection<I, F, S>(
135140

136141
if let Err(e) = result {
137142
let err_str = e.to_string();
143+
#[allow(clippy::print_stderr)]
138144
if !err_str.contains("early eof") {
139145
eprintln!("{}: {:?}", error_msg, e);
140146
}

tests/util/server/src/servers/mod.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ fn json_body(value: serde_json::Value) -> UnsyncBoxBody<Bytes, Infallible> {
198198

199199
/// Benchmark server that just serves "hello world" responses.
200200
async fn hyper_hello(port: u16) {
201-
println!("hyper hello");
202201
let addr = SocketAddr::from(([127, 0, 0, 1], port));
203202
let handler = move |_: Request<hyper::body::Incoming>| async move {
204203
Ok::<_, anyhow::Error>(Response::new(UnsyncBoxBody::new(
@@ -342,7 +341,10 @@ async fn get_tcp_listener_stream(
342341
.collect::<Vec<_>>();
343342

344343
// Eye catcher for HttpServerCount
345-
println!("ready: {name} on {:?}", addresses);
344+
#[allow(clippy::print_stdout)]
345+
{
346+
println!("ready: {name} on {:?}", addresses);
347+
}
346348

347349
futures::stream::select_all(listeners)
348350
}
@@ -358,7 +360,10 @@ async fn run_tls_client_auth_server(port: u16) {
358360
while let Some(Ok(mut tls_stream)) = tls.next().await {
359361
tokio::spawn(async move {
360362
let Ok(handshake) = tls_stream.handshake().await else {
361-
eprintln!("Failed to handshake");
363+
#[allow(clippy::print_stderr)]
364+
{
365+
eprintln!("Failed to handshake");
366+
}
362367
return;
363368
};
364369
// We only need to check for the presence of client certificates
@@ -405,15 +410,13 @@ async fn absolute_redirect(
405410
.collect();
406411

407412
if let Some(url) = query_params.get("redirect_to") {
408-
println!("URL: {url:?}");
409413
let redirect = redirect_resp(url.to_owned());
410414
return Ok(redirect);
411415
}
412416
}
413417

414418
if path.starts_with("/REDIRECT") {
415419
let url = &req.uri().path()[9..];
416-
println!("URL: {url:?}");
417420
let redirect = redirect_resp(url.to_string());
418421
return Ok(redirect);
419422
}
@@ -1357,6 +1360,7 @@ async fn wrap_client_auth_https_server(port: u16) {
13571360
// here. Rusttls ensures that they are valid and signed by the CA.
13581361
match handshake.has_peer_certificates {
13591362
true => { yield Ok(tls); },
1363+
#[allow(clippy::print_stderr)]
13601364
false => { eprintln!("https_client_auth: no valid client certificate"); },
13611365
};
13621366
}

tests/util/server/src/servers/ws.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ pub async fn run_wss2_server(port: u16) {
7676
let server: Handshake<_, Bytes> = h2.handshake(tls);
7777
let mut server = match server.await {
7878
Ok(server) => server,
79+
#[allow(clippy::print_stdout)]
7980
Err(e) => {
8081
println!("Failed to handshake h2: {e:?}");
8182
return;
@@ -87,6 +88,7 @@ pub async fn run_wss2_server(port: u16) {
8788
};
8889
let (recv, send) = match conn {
8990
Ok(conn) => conn,
91+
#[allow(clippy::print_stdout)]
9092
Err(e) => {
9193
println!("Failed to accept a connection: {e:?}");
9294
break;
@@ -137,6 +139,7 @@ where
137139
.map_err(|e| anyhow!("Error upgrading websocket connection: {}", e))
138140
.unwrap();
139141

142+
#[allow(clippy::print_stderr)]
140143
if let Err(e) = handler(ws).await {
141144
eprintln!("Error in websocket connection: {}", e);
142145
}
@@ -152,6 +155,7 @@ where
152155
.serve_connection(io, service)
153156
.with_upgrades();
154157

158+
#[allow(clippy::print_stderr)]
155159
if let Err(e) = conn.await {
156160
eprintln!("websocket server error: {e:?}");
157161
}
@@ -162,16 +166,19 @@ async fn handle_wss_stream(
162166
recv: Request<RecvStream>,
163167
mut send: SendResponse<Bytes>,
164168
) -> Result<(), h2::Error> {
169+
#[allow(clippy::print_stderr)]
165170
if recv.method() != Method::CONNECT {
166171
eprintln!("wss2: refusing non-CONNECT stream");
167172
send.send_reset(Reason::REFUSED_STREAM);
168173
return Ok(());
169174
}
175+
#[allow(clippy::print_stderr)]
170176
let Some(protocol) = recv.extensions().get::<h2::ext::Protocol>() else {
171177
eprintln!("wss2: refusing no-:protocol stream");
172178
send.send_reset(Reason::REFUSED_STREAM);
173179
return Ok(());
174180
};
181+
#[allow(clippy::print_stderr)]
175182
if protocol.as_str() != "websocket" && protocol.as_str() != "WebSocket" {
176183
eprintln!("wss2: refusing non-websocket stream");
177184
send.send_reset(Reason::REFUSED_STREAM);

0 commit comments

Comments
 (0)