mirror of
https://github.com/denoland/deno.git
synced 2024-12-24 16:19:12 -05:00
chore: enable clippy::print_stdout and clippy::print_stderr (#23732)
1. Generally we should prefer to use the `log` crate. 2. I very often accidentally commit `eprintln`s. When we should use `println` or `eprintln`, it's not too bad to be a bit more verbose and ignore the lint rule.
This commit is contained in:
parent
e6dc4dfbff
commit
47f7bed677
52 changed files with 307 additions and 181 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -1453,6 +1453,7 @@ dependencies = [
|
|||
"dynasmrt",
|
||||
"libffi",
|
||||
"libffi-sys",
|
||||
"log",
|
||||
"serde",
|
||||
"serde-value",
|
||||
"serde_json",
|
||||
|
@ -1557,6 +1558,7 @@ dependencies = [
|
|||
"deno_core",
|
||||
"filetime",
|
||||
"fs3",
|
||||
"log",
|
||||
"once_cell",
|
||||
"os_pipe",
|
||||
"rand",
|
||||
|
|
|
@ -39,6 +39,7 @@ macro_rules! bench_or_profile {
|
|||
};
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
pub fn run_profiles(opts: &TestOpts, tests: Vec<TestDescAndFn>) {
|
||||
let tests = filter_tests(opts, tests);
|
||||
// let decs = tests.iter().map(|t| t.desc.clone()).collect();
|
||||
|
|
|
@ -3889,6 +3889,7 @@ fn eval_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
|||
// TODO(@satyarohith): remove this flag in 2.0.
|
||||
let as_typescript = matches.get_flag("ts");
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
if as_typescript {
|
||||
eprintln!(
|
||||
"⚠️ {}",
|
||||
|
@ -4218,6 +4219,8 @@ fn test_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
|||
let no_run = matches.get_flag("no-run");
|
||||
let trace_leaks =
|
||||
matches.get_flag("trace-ops") || matches.get_flag("trace-leaks");
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
if trace_leaks && matches.get_flag("trace-ops") {
|
||||
// We can't change this to use the log crate because its not configured
|
||||
// yet at this point since the flags haven't been parsed. This flag is
|
||||
|
@ -4267,10 +4270,17 @@ fn test_parse(flags: &mut Flags, matches: &mut ArgMatches) {
|
|||
// yet at this point since the flags haven't been parsed. This flag is
|
||||
// deprecated though so it's not worth changing the code to use the log
|
||||
// crate here and this is only done for testing anyway.
|
||||
eprintln!(
|
||||
"⚠️ {}",
|
||||
crate::colors::yellow("The `--jobs` flag is deprecated and will be removed in Deno 2.0.\nUse the `--parallel` flag with possibly the `DENO_JOBS` environment variable instead.\nLearn more at: https://docs.deno.com/runtime/manual/basics/env_variables"),
|
||||
);
|
||||
#[allow(clippy::print_stderr)]
|
||||
{
|
||||
eprintln!(
|
||||
"⚠️ {}",
|
||||
crate::colors::yellow(concat!(
|
||||
"The `--jobs` flag is deprecated and will be removed in Deno 2.0.\n",
|
||||
"Use the `--parallel` flag with possibly the `DENO_JOBS` environment variable instead.\n",
|
||||
"Learn more at: https://docs.deno.com/runtime/manual/basics/env_variables"
|
||||
)),
|
||||
);
|
||||
}
|
||||
if let Some(value) = matches.remove_one::<NonZeroUsize>("jobs") {
|
||||
Some(value)
|
||||
} else {
|
||||
|
|
|
@ -747,9 +747,12 @@ impl CliOptions {
|
|||
format!("for: {}", insecure_allowlist.join(", "))
|
||||
};
|
||||
let msg =
|
||||
format!("DANGER: TLS certificate validation is disabled {domains}");
|
||||
// use eprintln instead of log::warn so this always gets shown
|
||||
eprintln!("{}", colors::yellow(msg));
|
||||
format!("DANGER: TLS certificate validation is disabled {}", domains);
|
||||
#[allow(clippy::print_stderr)]
|
||||
{
|
||||
// use eprintln instead of log::warn so this always gets shown
|
||||
eprintln!("{}", colors::yellow(msg));
|
||||
}
|
||||
}
|
||||
|
||||
let maybe_lockfile = maybe_lockfile.filter(|_| !force_global_cache);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
#![allow(clippy::print_stdout)]
|
||||
#![allow(clippy::print_stderr)]
|
||||
|
||||
use deno_core::error::AnyError;
|
||||
use deno_core::serde_json;
|
||||
use deno_core::serde_json::Value;
|
||||
|
|
|
@ -739,6 +739,8 @@ async fn fetch_no_follow<'a>(
|
|||
Ok(FetchOnceResult::Code(body, result_headers))
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
#[allow(clippy::print_stderr)]
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::cache::GlobalHttpCache;
|
||||
|
|
|
@ -235,6 +235,7 @@ async fn run_subcommand(flags: Flags) -> Result<i32, AnyError> {
|
|||
handle.await?
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
fn setup_panic_hook() {
|
||||
// This function does two things inside of the panic hook:
|
||||
// - Tokio does not exit the process when a task panics, so we define a custom
|
||||
|
@ -259,6 +260,7 @@ fn setup_panic_hook() {
|
|||
}));
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
fn exit_with_message(message: &str, code: i32) -> ! {
|
||||
eprintln!(
|
||||
"{}: {}",
|
||||
|
@ -289,6 +291,7 @@ fn exit_for_error(error: AnyError) -> ! {
|
|||
exit_with_message(&error_string, error_code);
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
pub(crate) fn unstable_exit_cb(feature: &str, api_name: &str) {
|
||||
eprintln!(
|
||||
"Unstable API '{api_name}'. The `--unstable-{}` flag must be provided.",
|
||||
|
@ -298,6 +301,7 @@ pub(crate) fn unstable_exit_cb(feature: &str, api_name: &str) {
|
|||
}
|
||||
|
||||
// TODO(bartlomieju): remove when `--unstable` flag is removed.
|
||||
#[allow(clippy::print_stderr)]
|
||||
pub(crate) fn unstable_warn_cb(feature: &str, api_name: &str) {
|
||||
eprintln!(
|
||||
"⚠️ {}",
|
||||
|
@ -369,7 +373,9 @@ fn resolve_flags_and_init(
|
|||
|
||||
// TODO(bartlomieju): remove when `--unstable` flag is removed.
|
||||
if flags.unstable_config.legacy_flag_enabled {
|
||||
#[allow(clippy::print_stderr)]
|
||||
if matches!(flags.subcommand, DenoSubcommand::Check(_)) {
|
||||
// can't use log crate because that's not setup yet
|
||||
eprintln!(
|
||||
"⚠️ {}",
|
||||
colors::yellow(
|
||||
|
|
|
@ -36,6 +36,7 @@ use std::env::current_exe;
|
|||
|
||||
use crate::args::Flags;
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
pub(crate) fn unstable_exit_cb(feature: &str, api_name: &str) {
|
||||
eprintln!(
|
||||
"Unstable API '{api_name}'. The `--unstable-{}` flag must be provided.",
|
||||
|
@ -44,6 +45,7 @@ pub(crate) fn unstable_exit_cb(feature: &str, api_name: &str) {
|
|||
std::process::exit(70);
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
fn exit_with_message(message: &str, code: i32) -> ! {
|
||||
eprintln!(
|
||||
"{}: {}",
|
||||
|
@ -57,7 +59,7 @@ fn unwrap_or_exit<T>(result: Result<T, AnyError>) -> T {
|
|||
match result {
|
||||
Ok(value) => value,
|
||||
Err(error) => {
|
||||
let mut error_string = format!("{error:?}");
|
||||
let mut error_string = format!("{:?}", error);
|
||||
|
||||
if let Some(e) = error.downcast_ref::<JsError>() {
|
||||
error_string = format_js_error(e);
|
||||
|
|
|
@ -76,13 +76,13 @@ pub fn op_print(
|
|||
|
||||
if is_err {
|
||||
if let Err(err) = sender.send(StdioMsg::Stderr(msg.into())) {
|
||||
eprintln!("Failed to send stderr message: {}", err);
|
||||
log::error!("Failed to send stderr message: {}", err);
|
||||
}
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Err(err) = sender.send(StdioMsg::Stdout(msg.into())) {
|
||||
eprintln!("Failed to send stdout message: {}", err);
|
||||
log::error!("Failed to send stdout message: {}", err);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ impl JsonReporter {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
impl BenchReporter for JsonReporter {
|
||||
fn report_group_summary(&mut self) {}
|
||||
#[cold]
|
||||
|
@ -58,7 +59,7 @@ impl BenchReporter for JsonReporter {
|
|||
fn report_end(&mut self, _report: &BenchReport) {
|
||||
match write_json_to_stdout(self) {
|
||||
Ok(_) => (),
|
||||
Err(e) => println!("{e}"),
|
||||
Err(e) => println!("{}", e),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,6 +119,7 @@ impl ConsoleReporter {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
impl BenchReporter for ConsoleReporter {
|
||||
#[cold]
|
||||
fn report_plan(&mut self, plan: &BenchPlan) {
|
||||
|
|
|
@ -125,7 +125,10 @@ async fn bundle_action(
|
|||
);
|
||||
}
|
||||
} else {
|
||||
println!("{}", bundle_output.code);
|
||||
#[allow(clippy::print_stdout)]
|
||||
{
|
||||
println!("{}", bundle_output.code);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ struct SummaryCoverageReporter {
|
|||
file_reports: Vec<(CoverageReport, String)>,
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
impl SummaryCoverageReporter {
|
||||
pub fn new() -> SummaryCoverageReporter {
|
||||
SummaryCoverageReporter {
|
||||
|
@ -166,6 +167,7 @@ impl SummaryCoverageReporter {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
impl CoverageReporter for SummaryCoverageReporter {
|
||||
fn report(
|
||||
&mut self,
|
||||
|
@ -312,6 +314,7 @@ impl DetailedCoverageReporter {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
impl CoverageReporter for DetailedCoverageReporter {
|
||||
fn report(
|
||||
&mut self,
|
||||
|
@ -416,7 +419,7 @@ impl CoverageReporter for HtmlCoverageReporter {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
println!("HTML coverage report has been generated at {}", root_report);
|
||||
log::info!("HTML coverage report has been generated at {}", root_report);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -396,8 +396,8 @@ async fn format_source_files(
|
|||
}
|
||||
Err(e) => {
|
||||
let _g = output_lock.lock();
|
||||
eprintln!("Error formatting: {}", file_path.to_string_lossy());
|
||||
eprintln!(" {e}");
|
||||
log::error!("Error formatting: {}", file_path.to_string_lossy());
|
||||
log::error!(" {e}");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -495,6 +495,7 @@ fn format_stdin(fmt_options: FmtOptions, ext: &str) -> Result<(), AnyError> {
|
|||
let file_path = PathBuf::from(format!("_stdin.{ext}"));
|
||||
let formatted_text = format_file(&file_path, &source, &fmt_options.options)?;
|
||||
if fmt_options.check {
|
||||
#[allow(clippy::print_stdout)]
|
||||
if formatted_text.is_some() {
|
||||
println!("Not formatted stdin");
|
||||
}
|
||||
|
|
|
@ -97,6 +97,7 @@ pub async fn info(flags: Flags, info_flags: InfoFlags) -> Result<(), AnyError> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
fn print_cache_info(
|
||||
factory: &CliFactory,
|
||||
json: bool,
|
||||
|
|
|
@ -27,13 +27,13 @@ pub fn status() -> Result<(), AnyError> {
|
|||
if let Some(specs) = json_output.get("kernelspecs") {
|
||||
if let Some(specs_obj) = specs.as_object() {
|
||||
if specs_obj.contains_key("deno") {
|
||||
println!("✅ Deno kernel already installed");
|
||||
log::info!("✅ Deno kernel already installed");
|
||||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
println!("ℹ️ Deno kernel is not yet installed, run `deno jupyter --install` to set it up");
|
||||
log::warn!("ℹ️ Deno kernel is not yet installed, run `deno jupyter --install` to set it up");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -108,6 +108,6 @@ pub fn install() -> Result<(), AnyError> {
|
|||
}
|
||||
|
||||
let _ = std::fs::remove_dir(temp_dir);
|
||||
println!("✅ Deno kernelspec installed successfully.");
|
||||
log::info!("✅ Deno kernelspec installed successfully.");
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ impl JupyterServer {
|
|||
|
||||
let handle1 = deno_core::unsync::spawn(async move {
|
||||
if let Err(err) = Self::handle_heartbeat(&mut heartbeat).await {
|
||||
eprintln!("Heartbeat error: {}", err);
|
||||
log::error!("Heartbeat error: {}", err);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -85,14 +85,14 @@ impl JupyterServer {
|
|||
if let Err(err) =
|
||||
Self::handle_control(control_socket, cancel_handle).await
|
||||
{
|
||||
eprintln!("Control error: {}", err);
|
||||
log::error!("Control error: {}", err);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let handle3 = deno_core::unsync::spawn(async move {
|
||||
if let Err(err) = server.handle_shell(shell_socket).await {
|
||||
eprintln!("Shell error: {}", err);
|
||||
log::error!("Shell error: {}", err);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -137,7 +137,7 @@ impl JupyterServer {
|
|||
.await;
|
||||
|
||||
if let Err(err) = result {
|
||||
eprintln!("Output {} error: {}", name, err);
|
||||
log::error!("Output {} error: {}", name, err);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,10 +166,10 @@ impl JupyterServer {
|
|||
cancel_handle.cancel();
|
||||
}
|
||||
"interrupt_request" => {
|
||||
eprintln!("Interrupt request currently not supported");
|
||||
log::error!("Interrupt request currently not supported");
|
||||
}
|
||||
_ => {
|
||||
eprintln!(
|
||||
log::error!(
|
||||
"Unrecognized control message type: {}",
|
||||
msg.message_type()
|
||||
);
|
||||
|
@ -307,7 +307,7 @@ impl JupyterServer {
|
|||
// We don't handle these messages
|
||||
}
|
||||
_ => {
|
||||
eprintln!("Unrecognized shell message type: {}", msg.message_type());
|
||||
log::error!("Unrecognized shell message type: {}", msg.message_type());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,12 +386,13 @@ impl JupyterServer {
|
|||
tokio::time::sleep(std::time::Duration::from_millis(5)).await;
|
||||
} else if let Some(exception_details) = exception_details {
|
||||
// Determine the exception value and name
|
||||
let (name, message, stack) =
|
||||
if let Some(exception) = exception_details.exception {
|
||||
let result = self
|
||||
.repl_session
|
||||
.call_function_on_args(
|
||||
r#"
|
||||
let (name, message, stack) = if let Some(exception) =
|
||||
exception_details.exception
|
||||
{
|
||||
let result = self
|
||||
.repl_session
|
||||
.call_function_on_args(
|
||||
r#"
|
||||
function(object) {
|
||||
if (object instanceof Error) {
|
||||
const name = "name" in object ? String(object.name) : "";
|
||||
|
@ -404,32 +405,32 @@ impl JupyterServer {
|
|||
}
|
||||
}
|
||||
"#
|
||||
.into(),
|
||||
&[exception],
|
||||
)
|
||||
.await?;
|
||||
.into(),
|
||||
&[exception],
|
||||
)
|
||||
.await?;
|
||||
|
||||
match result.result.value {
|
||||
Some(serde_json::Value::String(str)) => {
|
||||
if let Ok(object) =
|
||||
serde_json::from_str::<HashMap<String, String>>(&str)
|
||||
{
|
||||
let get = |k| object.get(k).cloned().unwrap_or_default();
|
||||
(get("name"), get("message"), get("stack"))
|
||||
} else {
|
||||
eprintln!("Unexpected result while parsing JSON {str}");
|
||||
("".into(), "".into(), "".into())
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
eprintln!("Unexpected result while parsing exception {result:?}");
|
||||
match result.result.value {
|
||||
Some(serde_json::Value::String(str)) => {
|
||||
if let Ok(object) =
|
||||
serde_json::from_str::<HashMap<String, String>>(&str)
|
||||
{
|
||||
let get = |k| object.get(k).cloned().unwrap_or_default();
|
||||
(get("name"), get("message"), get("stack"))
|
||||
} else {
|
||||
log::error!("Unexpected result while parsing JSON {str}");
|
||||
("".into(), "".into(), "".into())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
eprintln!("Unexpectedly missing exception {exception_details:?}");
|
||||
("".into(), "".into(), "".into())
|
||||
};
|
||||
_ => {
|
||||
log::error!("Unexpected result while parsing exception {result:?}");
|
||||
("".into(), "".into(), "".into())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log::error!("Unexpectedly missing exception {exception_details:?}");
|
||||
("".into(), "".into(), "".into())
|
||||
};
|
||||
|
||||
let stack = if stack.is_empty() {
|
||||
format!(
|
||||
|
@ -546,7 +547,7 @@ async fn publish_result(
|
|||
if let Some(exception_details) = &response.exception_details {
|
||||
// If the object doesn't have a Jupyter.display method or it throws an
|
||||
// exception, we just ignore it and let the caller handle it.
|
||||
eprintln!("Exception encountered: {}", exception_details.text);
|
||||
log::error!("Exception encountered: {}", exception_details.text);
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
|
|
|
@ -279,6 +279,7 @@ fn collect_lint_files(
|
|||
.collect_file_patterns(files)
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
pub fn print_rules_list(json: bool, maybe_rules_tags: Option<Vec<String>>) {
|
||||
let lint_rules = if maybe_rules_tags.is_none() {
|
||||
rules::get_all_rules()
|
||||
|
@ -646,12 +647,12 @@ impl LintReporter for PrettyLintReporter {
|
|||
}
|
||||
}
|
||||
|
||||
eprintln!("{}", d.display());
|
||||
log::error!("{}", d.display());
|
||||
}
|
||||
|
||||
fn visit_error(&mut self, file_path: &str, err: &AnyError) {
|
||||
eprintln!("Error linting: {file_path}");
|
||||
eprintln!(" {err}");
|
||||
log::error!("Error linting: {file_path}");
|
||||
log::error!(" {err}");
|
||||
}
|
||||
|
||||
fn close(&mut self, check_count: usize) {
|
||||
|
@ -694,7 +695,7 @@ impl LintReporter for CompactLintReporter {
|
|||
match d.range() {
|
||||
Some((text_info, range)) => {
|
||||
let line_and_column = text_info.line_and_column_display(range.start);
|
||||
eprintln!(
|
||||
log::error!(
|
||||
"{}: line {}, col {} - {} ({})",
|
||||
d.specifier(),
|
||||
line_and_column.line_number,
|
||||
|
@ -704,14 +705,14 @@ impl LintReporter for CompactLintReporter {
|
|||
)
|
||||
}
|
||||
None => {
|
||||
eprintln!("{}: {} ({})", d.specifier(), d.message(), d.code())
|
||||
log::error!("{}: {} ({})", d.specifier(), d.message(), d.code())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn visit_error(&mut self, file_path: &str, err: &AnyError) {
|
||||
eprintln!("Error linting: {file_path}");
|
||||
eprintln!(" {err}");
|
||||
log::error!("Error linting: {file_path}");
|
||||
log::error!(" {err}");
|
||||
}
|
||||
|
||||
fn close(&mut self, check_count: usize) {
|
||||
|
@ -812,7 +813,10 @@ impl LintReporter for JsonLintReporter {
|
|||
fn close(&mut self, _check_count: usize) {
|
||||
sort_diagnostics(&mut self.diagnostics);
|
||||
let json = serde_json::to_string_pretty(&self);
|
||||
println!("{}", json.unwrap());
|
||||
#[allow(clippy::print_stdout)]
|
||||
{
|
||||
println!("{}", json.unwrap());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,11 @@ impl PublishDiagnosticsCollector {
|
|||
diagnostics.sort_by_cached_key(|d| d.sorting_key());
|
||||
|
||||
for diagnostic in diagnostics {
|
||||
eprint!("{}", diagnostic.display());
|
||||
// todo(https://github.com/denoland/deno_ast/issues/245): use log crate here
|
||||
#[allow(clippy::print_stderr)]
|
||||
{
|
||||
eprint!("{}", diagnostic.display());
|
||||
}
|
||||
if matches!(diagnostic.level(), DiagnosticLevel::Error) {
|
||||
errors += 1;
|
||||
}
|
||||
|
@ -48,18 +52,18 @@ impl PublishDiagnosticsCollector {
|
|||
}
|
||||
if errors > 0 {
|
||||
if has_slow_types_errors {
|
||||
eprintln!(
|
||||
log::error!(
|
||||
"This package contains errors for slow types. Fixing these errors will:\n"
|
||||
);
|
||||
eprintln!(
|
||||
log::error!(
|
||||
" 1. Significantly improve your package users' type checking performance."
|
||||
);
|
||||
eprintln!(" 2. Improve the automatic documentation generation.");
|
||||
eprintln!(" 3. Enable automatic .d.ts generation for Node.js.");
|
||||
eprintln!(
|
||||
log::error!(" 2. Improve the automatic documentation generation.");
|
||||
log::error!(" 3. Enable automatic .d.ts generation for Node.js.");
|
||||
log::error!(
|
||||
"\nDon't want to bother? You can choose to skip this step by"
|
||||
);
|
||||
eprintln!("providing the --allow-slow-types flag.\n");
|
||||
log::error!("providing the --allow-slow-types flag.\n");
|
||||
}
|
||||
|
||||
Err(anyhow!(
|
||||
|
|
|
@ -72,9 +72,10 @@ use super::check::TypeChecker;
|
|||
use self::paths::CollectedPublishPath;
|
||||
use self::tar::PublishableTarball;
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
fn ring_bell() {
|
||||
// ASCII code for the bell character.
|
||||
print!("\x07");
|
||||
eprint!("\x07");
|
||||
}
|
||||
|
||||
struct PreparedPublishPackage {
|
||||
|
@ -291,18 +292,19 @@ async fn get_auth_headers(
|
|||
.context("Failed to create interactive authorization")?;
|
||||
|
||||
let auth_url = format!("{}?code={}", auth.verification_url, auth.code);
|
||||
print!(
|
||||
"Visit {} to authorize publishing of",
|
||||
colors::cyan(&auth_url)
|
||||
);
|
||||
if packages.len() > 1 {
|
||||
println!(" {} packages", packages.len());
|
||||
let pkgs_text = if packages.len() > 1 {
|
||||
format!("{} packages", packages.len())
|
||||
} else {
|
||||
println!(" @{}/{}", packages[0].scope, packages[0].package);
|
||||
}
|
||||
format!("@{}/{}", packages[0].scope, packages[0].package)
|
||||
};
|
||||
log::warn!(
|
||||
"Visit {} to authorize publishing of {}",
|
||||
colors::cyan(&auth_url),
|
||||
pkgs_text,
|
||||
);
|
||||
|
||||
ring_bell();
|
||||
println!("{}", colors::gray("Waiting..."));
|
||||
log::info!("{}", colors::gray("Waiting..."));
|
||||
let _ = open::that_detached(&auth_url);
|
||||
|
||||
let interval = std::time::Duration::from_secs(auth.poll_interval);
|
||||
|
@ -323,7 +325,7 @@ async fn get_auth_headers(
|
|||
.await;
|
||||
match res {
|
||||
Ok(res) => {
|
||||
println!(
|
||||
log::info!(
|
||||
"{} {} {}",
|
||||
colors::green("Authorization successful."),
|
||||
colors::gray("Authenticated as"),
|
||||
|
@ -490,13 +492,13 @@ async fn ensure_scopes_and_packages_exist(
|
|||
};
|
||||
|
||||
ring_bell();
|
||||
println!(
|
||||
log::warn!(
|
||||
"'@{}/{}' doesn't exist yet. Visit {} to create the package",
|
||||
&package.scope,
|
||||
&package.package,
|
||||
colors::cyan_with_underline(&create_package_url)
|
||||
);
|
||||
println!("{}", colors::gray("Waiting..."));
|
||||
log::warn!("{}", colors::gray("Waiting..."));
|
||||
let _ = open::that_detached(&create_package_url);
|
||||
|
||||
let package_api_url = api::get_package_api_url(
|
||||
|
@ -510,7 +512,7 @@ async fn ensure_scopes_and_packages_exist(
|
|||
let response = client.get(&package_api_url).send().await?;
|
||||
if response.status() == 200 {
|
||||
let name = format!("@{}/{}", package.scope, package.package);
|
||||
println!("Package {} created", colors::green(name));
|
||||
log::info!("Package {} created", colors::green(name));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -615,7 +617,7 @@ async fn publish_package(
|
|||
provenance: bool,
|
||||
) -> Result<(), AnyError> {
|
||||
let client = http_client.client()?;
|
||||
println!(
|
||||
log::info!(
|
||||
"{} @{}/{}@{} ...",
|
||||
colors::intense_blue("Publishing"),
|
||||
package.scope,
|
||||
|
@ -649,7 +651,7 @@ async fn publish_package(
|
|||
)
|
||||
.unwrap();
|
||||
if task.status == "success" {
|
||||
println!(
|
||||
log::info!(
|
||||
"{} @{}/{}@{}",
|
||||
colors::yellow("Warning: Skipping, already published"),
|
||||
package.scope,
|
||||
|
@ -658,7 +660,7 @@ async fn publish_package(
|
|||
);
|
||||
return Ok(());
|
||||
}
|
||||
println!(
|
||||
log::info!(
|
||||
"{} @{}/{}@{}",
|
||||
colors::yellow("Already uploaded, waiting for publishing"),
|
||||
package.scope,
|
||||
|
@ -711,7 +713,7 @@ async fn publish_package(
|
|||
);
|
||||
}
|
||||
|
||||
println!(
|
||||
log::info!(
|
||||
"{} @{}/{}@{}",
|
||||
colors::green("Successfully published"),
|
||||
package.scope,
|
||||
|
@ -748,7 +750,7 @@ async fn publish_package(
|
|||
let bundle = provenance::generate_provenance(subject).await?;
|
||||
|
||||
let tlog_entry = &bundle.verification_material.tlog_entries[0];
|
||||
println!("{}",
|
||||
log::info!("{}",
|
||||
colors::green(format!(
|
||||
"Provenance transparency log available at https://search.sigstore.dev/?logIndex={}",
|
||||
tlog_entry.log_index
|
||||
|
@ -768,7 +770,7 @@ async fn publish_package(
|
|||
.await?;
|
||||
}
|
||||
|
||||
println!(
|
||||
log::info!(
|
||||
"{}",
|
||||
colors::gray(format!(
|
||||
"Visit {}@{}/{}@{} for details",
|
||||
|
@ -798,7 +800,7 @@ async fn prepare_packages_for_publishing(
|
|||
let cli_options = cli_factory.cli_options();
|
||||
|
||||
if members.len() > 1 {
|
||||
println!("Publishing a workspace...");
|
||||
log::info!("Publishing a workspace...");
|
||||
}
|
||||
|
||||
// create the module graph
|
||||
|
|
|
@ -490,7 +490,7 @@ impl ReplEditor {
|
|||
}
|
||||
|
||||
self.errored_on_history_save.store(true, Relaxed);
|
||||
eprintln!("Unable to save history file: {e}");
|
||||
log::warn!("Unable to save history file: {}", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ struct Repl {
|
|||
message_handler: RustylineSyncMessageHandler,
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
impl Repl {
|
||||
async fn run(&mut self) -> Result<(), AnyError> {
|
||||
loop {
|
||||
|
@ -61,7 +62,7 @@ impl Repl {
|
|||
break;
|
||||
}
|
||||
|
||||
println!("{output}");
|
||||
println!("{}", output);
|
||||
}
|
||||
Err(ReadlineError::Interrupted) => {
|
||||
if self.editor.should_exit_on_interrupt() {
|
||||
|
@ -75,7 +76,7 @@ impl Repl {
|
|||
break;
|
||||
}
|
||||
Err(err) => {
|
||||
println!("Error: {err:?}");
|
||||
println!("Error: {:?}", err);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -85,6 +86,7 @@ impl Repl {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
async fn read_line_and_poll(
|
||||
repl_session: &mut ReplSession,
|
||||
message_handler: &mut RustylineSyncMessageHandler,
|
||||
|
@ -152,6 +154,7 @@ async fn read_eval_file(
|
|||
Ok(file.into_text_decoded()?.source)
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
pub async fn run(flags: Flags, repl_flags: ReplFlags) -> Result<i32, AnyError> {
|
||||
let factory = CliFactory::from_flags(flags)?;
|
||||
let cli_options = factory.cli_options();
|
||||
|
|
|
@ -44,7 +44,11 @@ pub async fn execute_script(
|
|||
let task_name = match &task_flags.task {
|
||||
Some(task) => task,
|
||||
None => {
|
||||
print_available_tasks(&tasks_config, &package_json_scripts);
|
||||
print_available_tasks(
|
||||
&mut std::io::stdout(),
|
||||
&tasks_config,
|
||||
&package_json_scripts,
|
||||
)?;
|
||||
return Ok(1);
|
||||
}
|
||||
};
|
||||
|
@ -145,8 +149,14 @@ pub async fn execute_script(
|
|||
|
||||
Ok(0)
|
||||
} else {
|
||||
eprintln!("Task not found: {task_name}");
|
||||
print_available_tasks(&tasks_config, &package_json_scripts);
|
||||
log::error!("Task not found: {task_name}");
|
||||
if log::log_enabled!(log::Level::Error) {
|
||||
print_available_tasks(
|
||||
&mut std::io::stderr(),
|
||||
&tasks_config,
|
||||
&package_json_scripts,
|
||||
)?;
|
||||
}
|
||||
Ok(1)
|
||||
}
|
||||
}
|
||||
|
@ -239,48 +249,58 @@ fn collect_env_vars() -> HashMap<String, String> {
|
|||
}
|
||||
|
||||
fn print_available_tasks(
|
||||
// order can be important, so these use an index map
|
||||
writer: &mut dyn std::io::Write,
|
||||
tasks_config: &IndexMap<String, deno_config::Task>,
|
||||
package_json_scripts: &IndexMap<String, String>,
|
||||
) {
|
||||
eprintln!("{}", colors::green("Available tasks:"));
|
||||
) -> Result<(), std::io::Error> {
|
||||
writeln!(writer, "{}", colors::green("Available tasks:"))?;
|
||||
|
||||
let mut had_task = false;
|
||||
for (is_deno, (key, task)) in tasks_config
|
||||
.iter()
|
||||
.map(|(k, t)| (true, (k, t.clone())))
|
||||
.chain(
|
||||
package_json_scripts
|
||||
.iter()
|
||||
.filter(|(key, _)| !tasks_config.contains_key(*key))
|
||||
.map(|(k, v)| (false, (k, deno_config::Task::Definition(v.clone())))),
|
||||
)
|
||||
{
|
||||
eprintln!(
|
||||
"- {}{}",
|
||||
colors::cyan(key),
|
||||
if is_deno {
|
||||
"".to_string()
|
||||
} else {
|
||||
format!(" {}", colors::italic_gray("(package.json)"))
|
||||
}
|
||||
);
|
||||
let definition = match &task {
|
||||
deno_config::Task::Definition(definition) => definition,
|
||||
deno_config::Task::Commented { definition, .. } => definition,
|
||||
};
|
||||
if let deno_config::Task::Commented { comments, .. } = &task {
|
||||
let slash_slash = colors::italic_gray("//");
|
||||
for comment in comments {
|
||||
eprintln!(" {slash_slash} {}", colors::italic_gray(comment));
|
||||
if tasks_config.is_empty() && package_json_scripts.is_empty() {
|
||||
writeln!(
|
||||
writer,
|
||||
" {}",
|
||||
colors::red("No tasks found in configuration file")
|
||||
)?;
|
||||
} else {
|
||||
for (is_deno, (key, task)) in tasks_config
|
||||
.iter()
|
||||
.map(|(k, t)| (true, (k, t.clone())))
|
||||
.chain(
|
||||
package_json_scripts
|
||||
.iter()
|
||||
.filter(|(key, _)| !tasks_config.contains_key(*key))
|
||||
.map(|(k, v)| (false, (k, deno_config::Task::Definition(v.clone())))),
|
||||
)
|
||||
{
|
||||
writeln!(
|
||||
writer,
|
||||
"- {}{}",
|
||||
colors::cyan(key),
|
||||
if is_deno {
|
||||
"".to_string()
|
||||
} else {
|
||||
format!(" {}", colors::italic_gray("(package.json)"))
|
||||
}
|
||||
)?;
|
||||
let definition = match &task {
|
||||
deno_config::Task::Definition(definition) => definition,
|
||||
deno_config::Task::Commented { definition, .. } => definition,
|
||||
};
|
||||
if let deno_config::Task::Commented { comments, .. } = &task {
|
||||
let slash_slash = colors::italic_gray("//");
|
||||
for comment in comments {
|
||||
writeln!(
|
||||
writer,
|
||||
" {slash_slash} {}",
|
||||
colors::italic_gray(comment)
|
||||
)?;
|
||||
}
|
||||
}
|
||||
writeln!(writer, " {definition}")?;
|
||||
}
|
||||
eprintln!(" {definition}");
|
||||
had_task = true;
|
||||
}
|
||||
if !had_task {
|
||||
eprintln!(" {}", colors::red("No tasks found in configuration file"));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
struct NpxCommand;
|
||||
|
|
|
@ -442,6 +442,8 @@ impl TestEventSender {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
#[allow(clippy::print_stderr)]
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -1518,6 +1518,8 @@ pub async fn report_tests(
|
|||
&tests,
|
||||
&test_steps,
|
||||
);
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
if let Err(err) = reporter.flush_report(&elapsed, &tests, &test_steps) {
|
||||
eprint!("Test reporter failed to flush: {}", err)
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ pub struct DotTestReporter {
|
|||
summary: TestSummary,
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
impl DotTestReporter {
|
||||
pub fn new(cwd: Url) -> DotTestReporter {
|
||||
let console_width = if let Some(size) = crate::util::console::console_size()
|
||||
|
@ -80,6 +81,7 @@ fn fmt_cancelled() -> String {
|
|||
colors::gray("!").to_string()
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
impl TestReporter for DotTestReporter {
|
||||
fn report_register(&mut self, _description: &TestDescription) {}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ pub struct TapTestReporter {
|
|||
step_results: HashMap<usize, Vec<(TestStepDescription, TestStepResult)>>,
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
impl TapTestReporter {
|
||||
pub fn new(cwd: Url, is_concurrent: bool) -> TapTestReporter {
|
||||
TapTestReporter {
|
||||
|
@ -113,6 +114,7 @@ impl TapTestReporter {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
impl TestReporter for TapTestReporter {
|
||||
fn report_register(&mut self, _description: &TestDescription) {}
|
||||
|
||||
|
|
|
@ -274,23 +274,17 @@ pub fn check_for_upgrades(
|
|||
if let Some(upgrade_version) = update_checker.should_prompt() {
|
||||
if log::log_enabled!(log::Level::Info) && std::io::stderr().is_terminal() {
|
||||
if version::is_canary() {
|
||||
eprint!(
|
||||
"{} ",
|
||||
colors::green("A new canary release of Deno is available.")
|
||||
);
|
||||
eprintln!(
|
||||
"{}",
|
||||
log::info!(
|
||||
"{} {}",
|
||||
colors::green("A new canary release of Deno is available."),
|
||||
colors::italic_gray("Run `deno upgrade --canary` to install it.")
|
||||
);
|
||||
} else {
|
||||
eprint!(
|
||||
"{} {} → {} ",
|
||||
log::info!(
|
||||
"{} {} → {} {}",
|
||||
colors::green("A new release of Deno is available:"),
|
||||
colors::cyan(version::deno()),
|
||||
colors::cyan(&upgrade_version)
|
||||
);
|
||||
eprintln!(
|
||||
"{}",
|
||||
colors::cyan(&upgrade_version),
|
||||
colors::italic_gray("Run `deno upgrade` to install it.")
|
||||
);
|
||||
}
|
||||
|
|
|
@ -73,6 +73,7 @@ impl DebouncedReceiver {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
async fn error_handler<F>(watch_future: F) -> bool
|
||||
where
|
||||
F: Future<Output = Result<(), AnyError>>,
|
||||
|
@ -132,8 +133,9 @@ fn create_print_after_restart_fn(
|
|||
clear_screen: bool,
|
||||
) -> impl Fn() {
|
||||
move || {
|
||||
#[allow(clippy::print_stderr)]
|
||||
if clear_screen && std::io::stderr().is_terminal() {
|
||||
eprint!("{CLEAR_SCREEN}");
|
||||
eprint!("{}", CLEAR_SCREEN);
|
||||
}
|
||||
info!(
|
||||
"{} File change detected! Restarting!",
|
||||
|
|
|
@ -43,6 +43,8 @@ pub fn init_v8_flags(
|
|||
.into_iter()
|
||||
.skip(1)
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
if !unrecognized_v8_flags.is_empty() {
|
||||
for f in unrecognized_v8_flags {
|
||||
eprintln!("error: V8 did not recognize flag '{f}'");
|
||||
|
|
|
@ -868,6 +868,8 @@ fn create_web_worker_callback(
|
|||
})
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
#[allow(clippy::print_stderr)]
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -19,6 +19,7 @@ dlopen2.workspace = true
|
|||
dynasmrt = "1.2.3"
|
||||
libffi = "=3.2.0"
|
||||
libffi-sys = "=2.3.0"
|
||||
log.workspace = true
|
||||
serde.workspace = true
|
||||
serde-value = "0.7"
|
||||
serde_json = "1.0"
|
||||
|
|
|
@ -176,7 +176,7 @@ unsafe extern "C" fn deno_ffi_callback(
|
|||
let tc_scope = &mut TryCatch::new(scope);
|
||||
args.run(tc_scope);
|
||||
if tc_scope.exception().is_some() {
|
||||
eprintln!("Illegal unhandled exception in nonblocking callback.");
|
||||
log::error!("Illegal unhandled exception in nonblocking callback.");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -625,6 +625,7 @@ impl PollFrame for BrotliResponseStream {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
@ -18,6 +18,7 @@ async-trait.workspace = true
|
|||
deno_core.workspace = true
|
||||
filetime.workspace = true
|
||||
fs3.workspace = true
|
||||
log.workspace = true
|
||||
once_cell.workspace = true
|
||||
tokio.workspace = true
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ fn create_named_pipe_inner() -> io::Result<(RawHandle, RawHandle)> {
|
|||
// This should not happen, so we would like to get some better diagnostics here.
|
||||
// SAFETY: Printing last error for diagnostics
|
||||
unsafe {
|
||||
eprintln!(
|
||||
log::error!(
|
||||
"*** Unexpected server pipe failure '{pipe_name:?}': {:x}",
|
||||
GetLastError()
|
||||
);
|
||||
|
@ -99,7 +99,7 @@ fn create_named_pipe_inner() -> io::Result<(RawHandle, RawHandle)> {
|
|||
// SAFETY: Getting last error for diagnostics
|
||||
let error = unsafe { GetLastError() };
|
||||
// This should not happen, so we would like to get some better diagnostics here.
|
||||
eprintln!(
|
||||
log::error!(
|
||||
"*** Unexpected client pipe failure '{pipe_name:?}': {:x}",
|
||||
error
|
||||
);
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
#![allow(clippy::print_stdout)]
|
||||
#![allow(clippy::print_stderr)]
|
||||
|
||||
use std::path::Path;
|
||||
use std::rc::Rc;
|
||||
|
||||
|
|
|
@ -176,7 +176,7 @@ fn handle_ws_request(
|
|||
let websocket = match fut.await {
|
||||
Ok(w) => w,
|
||||
Err(err) => {
|
||||
eprintln!(
|
||||
log::error!(
|
||||
"Inspector server failed to upgrade to WS connection: {:?}",
|
||||
err
|
||||
);
|
||||
|
@ -194,7 +194,7 @@ fn handle_ws_request(
|
|||
rx: inbound_rx,
|
||||
};
|
||||
|
||||
eprintln!("Debugger session started.");
|
||||
log::info!("Debugger session started.");
|
||||
let _ = new_session_tx.unbounded_send(inspector_session_proxy);
|
||||
pump_websocket_messages(websocket, inbound_tx, outbound_rx).await;
|
||||
});
|
||||
|
@ -244,13 +244,13 @@ async fn server(
|
|||
let inspector_map = Rc::clone(&inspector_map_);
|
||||
let mut register_inspector_handler = pin!(register_inspector_rx
|
||||
.map(|info| {
|
||||
eprintln!(
|
||||
log::info!(
|
||||
"Debugger listening on {}",
|
||||
info.get_websocket_debugger_url(&info.host.to_string())
|
||||
);
|
||||
eprintln!("Visit chrome://inspect to connect to the debugger.");
|
||||
log::info!("Visit chrome://inspect to connect to the debugger.");
|
||||
if info.wait_for_session {
|
||||
eprintln!("Deno is waiting for debugger to connect.");
|
||||
log::info!("Deno is waiting for debugger to connect.");
|
||||
}
|
||||
if inspector_map.borrow_mut().insert(info.uuid, info).is_some() {
|
||||
panic!("Inspector UUID already in map");
|
||||
|
@ -277,7 +277,7 @@ async fn server(
|
|||
let listener = match TcpListener::from_std(listener) {
|
||||
Ok(l) => l,
|
||||
Err(err) => {
|
||||
eprintln!("Cannot start inspector server: {:?}", err);
|
||||
log::error!("Cannot start inspector server: {:?}", err);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
@ -293,7 +293,7 @@ async fn server(
|
|||
match accept_result {
|
||||
Ok((s, _)) => s,
|
||||
Err(err) => {
|
||||
eprintln!("Failed to accept inspector connection: {:?}", err);
|
||||
log::error!("Failed to accept inspector connection: {:?}", err);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -356,7 +356,7 @@ async fn server(
|
|||
tokio::select! {
|
||||
result = conn.as_mut() => {
|
||||
if let Err(err) = result {
|
||||
eprintln!("Failed to serve connection: {:?}", err);
|
||||
log::error!("Failed to serve connection: {:?}", err);
|
||||
}
|
||||
},
|
||||
_ = &mut shutdown_rx => {
|
||||
|
@ -409,7 +409,7 @@ async fn pump_websocket_messages(
|
|||
OpCode::Close => {
|
||||
// Users don't care if there was an error coming from debugger,
|
||||
// just about the fact that debugger did disconnect.
|
||||
eprintln!("Debugger session ended");
|
||||
log::info!("Debugger session ended");
|
||||
break 'pump;
|
||||
}
|
||||
_ => {
|
||||
|
|
|
@ -280,6 +280,7 @@ impl PermissionPrompter for TtyPrompter {
|
|||
return PromptResponse::Deny;
|
||||
};
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
if message.len() > MAX_PERMISSION_PROMPT_LENGTH {
|
||||
eprintln!("❌ Permission prompt length ({} bytes) was larger than the configured maximum length ({} bytes): denying request.", message.len(), MAX_PERMISSION_PROMPT_LENGTH);
|
||||
eprintln!("❌ WARNING: This may indicate that code is trying to bypass or hide permission check requests.");
|
||||
|
@ -298,6 +299,7 @@ impl PermissionPrompter for TtyPrompter {
|
|||
|
||||
// For security reasons we must consume everything in stdin so that previously
|
||||
// buffered data cannot affect the prompt.
|
||||
#[allow(clippy::print_stderr)]
|
||||
if let Err(err) = clear_stdin(&mut stdin_lock, &mut stderr_lock) {
|
||||
eprintln!("Error clearing stdin for permission prompt. {err:#}");
|
||||
return PromptResponse::Deny; // don't grant permission if this fails
|
||||
|
@ -336,6 +338,7 @@ impl PermissionPrompter for TtyPrompter {
|
|||
// Clear stdin each time we loop around in case the user accidentally pasted
|
||||
// multiple lines or otherwise did something silly to generate a torrent of
|
||||
// input. This doesn't work on Windows because `clear_stdin` has other side-effects.
|
||||
#[allow(clippy::print_stderr)]
|
||||
#[cfg(unix)]
|
||||
if let Err(err) = clear_stdin(&mut stdin_lock, &mut stderr_lock) {
|
||||
eprintln!("Error clearing stdin for permission prompt. {err:#}");
|
||||
|
|
|
@ -296,6 +296,7 @@ pub fn create_runtime_snapshot(
|
|||
let mut snapshot = std::fs::File::create(snapshot_path).unwrap();
|
||||
snapshot.write_all(&output.output).unwrap();
|
||||
|
||||
#[allow(clippy::print_stdout)]
|
||||
for path in output.files_loaded_during_snapshot {
|
||||
println!("cargo:rerun-if-changed={}", path.display());
|
||||
}
|
||||
|
|
|
@ -81,8 +81,9 @@ where
|
|||
let handle = tokio::runtime::Handle::current();
|
||||
let runtime_monitor = RuntimeMonitor::new(&handle);
|
||||
tokio::spawn(async move {
|
||||
#[allow(clippy::print_stderr)]
|
||||
for interval in runtime_monitor.intervals() {
|
||||
println!("{:#?}", interval);
|
||||
eprintln!("{:#?}", interval);
|
||||
// wait 500ms
|
||||
tokio::time::sleep(std::time::Duration::from_millis(
|
||||
metrics_interval,
|
||||
|
|
|
@ -805,6 +805,7 @@ impl WebWorker {
|
|||
|
||||
// TODO(mmastrac): we don't want to test this w/classic workers because
|
||||
// WPT triggers a failure here. This is only exposed via --enable-testing-features-do-not-use.
|
||||
#[allow(clippy::print_stderr)]
|
||||
if self.worker_type == WebWorkerType::Module {
|
||||
panic!(
|
||||
"coding error: either js is polling or the worker is terminated"
|
||||
|
@ -878,6 +879,7 @@ impl WebWorker {
|
|||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::print_stderr)]
|
||||
fn print_worker_error(
|
||||
error: &AnyError,
|
||||
name: &str,
|
||||
|
|
|
@ -279,6 +279,7 @@ pub fn create_op_metrics(
|
|||
max_len.set(max_len.get().max(decl.name.len()));
|
||||
let max_len = max_len.clone();
|
||||
Some(Rc::new(
|
||||
#[allow(clippy::print_stderr)]
|
||||
move |op: &deno_core::_ops::OpCtx, event, source| {
|
||||
eprintln!(
|
||||
"[{: >10.3}] {name:max_len$}: {event:?} {source:?}",
|
||||
|
@ -518,7 +519,7 @@ impl MainWorker {
|
|||
if !has_notified_of_inspector_disconnect
|
||||
.swap(true, std::sync::atomic::Ordering::SeqCst)
|
||||
{
|
||||
println!("Program finished. Waiting for inspector to disconnect to exit the process...");
|
||||
log::info!("Program finished. Waiting for inspector to disconnect to exit the process...");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
#![allow(clippy::print_stdout)]
|
||||
#![allow(clippy::print_stderr)]
|
||||
#![allow(clippy::undocumented_unsafe_blocks)]
|
||||
|
||||
use std::os::raw::c_void;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
#![allow(clippy::print_stdout)]
|
||||
#![allow(clippy::print_stderr)]
|
||||
|
||||
use pretty_assertions::assert_eq;
|
||||
use std::process::Command;
|
||||
use test_util::deno_cmd;
|
||||
|
|
|
@ -21,6 +21,7 @@ use test_util as util;
|
|||
use tokio::net::TcpStream;
|
||||
use tokio::time::timeout;
|
||||
use url::Url;
|
||||
use util::assert_contains;
|
||||
use util::assert_starts_with;
|
||||
use util::DenoChild;
|
||||
use util::TestContextBuilder;
|
||||
|
@ -94,12 +95,18 @@ impl InspectorTester {
|
|||
F: FnMut(&str) -> bool + 'static,
|
||||
{
|
||||
let stdout = child.stdout.take().unwrap();
|
||||
let stdout_lines =
|
||||
std::io::BufReader::new(stdout).lines().map(|r| r.unwrap());
|
||||
let stdout_lines = std::io::BufReader::new(stdout).lines().map(|r| {
|
||||
let line = r.unwrap();
|
||||
eprintln!("STDOUT: {}", line);
|
||||
line
|
||||
});
|
||||
|
||||
let stderr = child.stderr.take().unwrap();
|
||||
let mut stderr_lines =
|
||||
std::io::BufReader::new(stderr).lines().map(|r| r.unwrap());
|
||||
let mut stderr_lines = std::io::BufReader::new(stderr).lines().map(|r| {
|
||||
let line = r.unwrap();
|
||||
eprintln!("STDERR: {}", line);
|
||||
line
|
||||
});
|
||||
|
||||
let uri = extract_ws_url_from_stderr(&mut stderr_lines);
|
||||
|
||||
|
@ -810,7 +817,6 @@ async fn inspector_break_on_first_line_in_test() {
|
|||
let script = util::testdata_path().join("inspector/inspector_test.js");
|
||||
let child = util::deno_cmd()
|
||||
.arg("test")
|
||||
.arg("--quiet")
|
||||
.arg(inspect_flag_with_unique_port("--inspect-brk"))
|
||||
.arg(script)
|
||||
.env("NO_COLOR", "1")
|
||||
|
@ -877,10 +883,7 @@ async fn inspector_break_on_first_line_in_test() {
|
|||
|
||||
assert_starts_with!(&tester.stdout_line(), "running 1 test from");
|
||||
let line = tester.stdout_line();
|
||||
assert!(
|
||||
&line.contains("basic test ... ok"),
|
||||
"Missing content: {line}"
|
||||
);
|
||||
assert_contains!(line, "basic test ... ok");
|
||||
|
||||
tester.child.kill().unwrap();
|
||||
tester.child.wait().unwrap();
|
||||
|
@ -907,6 +910,7 @@ async fn inspector_with_ts_files() {
|
|||
let mut tester = InspectorTester::create(child, notification_filter).await;
|
||||
|
||||
tester.assert_stderr_for_inspect_brk();
|
||||
assert_eq!(&tester.stderr_line(), "Debugger session started.");
|
||||
|
||||
tester
|
||||
.send_many(&[
|
||||
|
@ -926,19 +930,19 @@ async fn inspector_with_ts_files() {
|
|||
|
||||
// receive messages with sources from this test
|
||||
let script1 = tester.recv().await;
|
||||
assert!(script1.contains("testdata/inspector/test.ts"));
|
||||
assert_contains!(script1, "testdata/inspector/test.ts");
|
||||
let script1_id = {
|
||||
let v: serde_json::Value = serde_json::from_str(&script1).unwrap();
|
||||
v["params"]["scriptId"].as_str().unwrap().to_string()
|
||||
};
|
||||
let script2 = tester.recv().await;
|
||||
assert!(script2.contains("testdata/inspector/foo.ts"));
|
||||
assert_contains!(script2, "testdata/inspector/foo.ts");
|
||||
let script2_id = {
|
||||
let v: serde_json::Value = serde_json::from_str(&script2).unwrap();
|
||||
v["params"]["scriptId"].as_str().unwrap().to_string()
|
||||
};
|
||||
let script3 = tester.recv().await;
|
||||
assert!(script3.contains("testdata/inspector/bar.js"));
|
||||
assert_contains!(script3, "testdata/inspector/bar.js");
|
||||
let script3_id = {
|
||||
let v: serde_json::Value = serde_json::from_str(&script3).unwrap();
|
||||
v["params"]["scriptId"].as_str().unwrap().to_string()
|
||||
|
@ -996,10 +1000,12 @@ async fn inspector_with_ts_files() {
|
|||
)
|
||||
.await;
|
||||
|
||||
let line = tester.stderr_line();
|
||||
assert_contains!(test_util::strip_ansi_codes(&line), "Check");
|
||||
assert_eq!(
|
||||
&tester.stdout_line(),
|
||||
"Program finished. Waiting for inspector to disconnect to exit the process..."
|
||||
);
|
||||
&tester.stderr_line(),
|
||||
"Program finished. Waiting for inspector to disconnect to exit the process..."
|
||||
);
|
||||
|
||||
tester.child.kill().unwrap();
|
||||
tester.child.wait().unwrap();
|
||||
|
@ -1194,7 +1200,6 @@ async fn inspector_break_on_first_line_npm_esm() {
|
|||
.new_command()
|
||||
.args_vec([
|
||||
"run",
|
||||
"--quiet",
|
||||
&inspect_flag_with_unique_port("--inspect-brk"),
|
||||
"npm:@denotest/bin/cli-esm",
|
||||
"this",
|
||||
|
@ -1262,7 +1267,6 @@ async fn inspector_break_on_first_line_npm_cjs() {
|
|||
.new_command()
|
||||
.args_vec([
|
||||
"run",
|
||||
"--quiet",
|
||||
&inspect_flag_with_unique_port("--inspect-brk"),
|
||||
"npm:@denotest/bin/cli-cjs",
|
||||
"this",
|
||||
|
@ -1331,7 +1335,6 @@ async fn inspector_error_with_npm_import() {
|
|||
.new_command()
|
||||
.args_vec([
|
||||
"run",
|
||||
"--quiet",
|
||||
"-A",
|
||||
&inspect_flag_with_unique_port("--inspect-brk"),
|
||||
&script.to_string_lossy(),
|
||||
|
@ -1394,7 +1397,6 @@ async fn inspector_wait() {
|
|||
.new_command()
|
||||
.args_vec([
|
||||
"run",
|
||||
"--quiet",
|
||||
"-A",
|
||||
&inspect_flag_with_unique_port("--inspect-wait"),
|
||||
&script.to_string_lossy(),
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
#![allow(clippy::print_stdout)]
|
||||
#![allow(clippy::print_stderr)]
|
||||
|
||||
// These files have `_tests.rs` suffix to make it easier to tell which file is
|
||||
// the test (ex. `lint_tests.rs`) and which is the implementation (ex. `lint.rs`)
|
||||
// when both are open, especially for two tabs in VS Code
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
#![allow(clippy::all)]
|
||||
#![allow(clippy::print_stdout)]
|
||||
#![allow(clippy::print_stderr)]
|
||||
#![allow(clippy::undocumented_unsafe_blocks)]
|
||||
|
||||
use std::ffi::c_void;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
#![allow(clippy::print_stdout)]
|
||||
#![allow(clippy::print_stderr)]
|
||||
|
||||
use std::process::Command;
|
||||
use test_util::deno_cmd;
|
||||
use test_util::deno_config_path;
|
||||
|
@ -80,8 +83,8 @@ fn napi_tests() {
|
|||
|
||||
if !output.status.success() {
|
||||
eprintln!("exit code {:?}", output.status.code());
|
||||
println!("stdout {stdout}");
|
||||
println!("stderr {stderr}");
|
||||
println!("stdout {}", stdout);
|
||||
println!("stderr {}", stderr);
|
||||
}
|
||||
assert!(output.status.success());
|
||||
}
|
||||
|
|
5
tests/testdata/inspector/inspector_test.js
vendored
5
tests/testdata/inspector/inspector_test.js
vendored
|
@ -1,3 +1,6 @@
|
|||
Deno.test("basic test", () => {
|
||||
console.log("test has finished running");
|
||||
const value = 1 + 1;
|
||||
if (value !== 2) {
|
||||
throw new Error("failed");
|
||||
}
|
||||
});
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// 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;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
||||
|
||||
#![allow(clippy::print_stdout)]
|
||||
#![allow(clippy::print_stderr)]
|
||||
|
||||
fn main() {
|
||||
setup_panic_hook();
|
||||
test_server::servers::run_all_servers();
|
||||
|
|
|
@ -162,6 +162,12 @@ async function clippy() {
|
|||
"warnings",
|
||||
"--deny",
|
||||
"clippy::unused_async",
|
||||
// generally prefer the `log` crate, but ignore
|
||||
// these print_* rules if necessary
|
||||
"--deny",
|
||||
"clippy::print_stderr",
|
||||
"--deny",
|
||||
"clippy::print_stdout",
|
||||
],
|
||||
stdout: "inherit",
|
||||
stderr: "inherit",
|
||||
|
|
Loading…
Reference in a new issue