diff --git a/crates/rome_cli/src/traversal.rs b/crates/rome_cli/src/traversal.rs index 96ec86314af..d143d9dbe79 100644 --- a/crates/rome_cli/src/traversal.rs +++ b/crates/rome_cli/src/traversal.rs @@ -840,7 +840,8 @@ fn process_file(ctx: &TraversalOptions, path: &Path, file_id: FileId) -> FileRes // In format mode the diagnostics have already been checked for errors // at this point, so they can just be dropped now since we don't want // to print syntax warnings for the format command - let result = if result.diagnostics.is_empty() || ctx.execution.is_format() { + let no_diagnostics = result.diagnostics.is_empty() && result.skipped_diagnostics == 0; + let result = if no_diagnostics || ctx.execution.is_format() { FileStatus::Success } else { FileStatus::Message(Message::Diagnostics { diff --git a/crates/rome_cli/tests/commands/check.rs b/crates/rome_cli/tests/commands/check.rs index b624a9d92ed..0c222c541d0 100644 --- a/crates/rome_cli/tests/commands/check.rs +++ b/crates/rome_cli/tests/commands/check.rs @@ -557,7 +557,6 @@ fn upgrade_severity() { let messages = &console.out_buffer; - dbg!(&result); assert_eq!( messages .iter() @@ -729,10 +728,7 @@ fn fs_error_dereferenced_symlink() { assert_cli_snapshot(SnapshotPayload::new( module_path!(), - #[cfg(target_family = "unix")] - "fs_error_dereferenced_symlink_unix", - #[cfg(target_os = "windows")] - "fs_error_dereferenced_symlink_windows", + "fs_error_dereferenced_symlink", fs, console, result, @@ -790,10 +786,7 @@ fn fs_error_infinite_symlink_exapansion() { assert_cli_snapshot(SnapshotPayload::new( module_path!(), - #[cfg(target_family = "unix")] - "fs_error_infinite_symlink_exapansion_unix", - #[cfg(target_os = "windows")] - "fs_error_infinite_symlink_exapansion_windows", + "fs_error_infinite_symlink_expansion", fs, console, result, @@ -947,7 +940,8 @@ fn max_diagnostics_default() { let mut fs = MemoryFileSystem::default(); let mut console = BufferConsole::default(); - for i in 0..60 { + // Creates 40 diagnostics. + for i in 0..20 { let file_path = PathBuf::from(format!("src/file_{i}.js")); fs.insert(file_path, LINT_ERROR.as_bytes()); } @@ -981,11 +975,6 @@ fn max_diagnostics_default() { console.out_buffer = filtered_messages; - for i in 0..60 { - let file_path = format!("src/file_{i}.js"); - fs.remove(Path::new(&file_path)); - } - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "max_diagnostics_default", @@ -1002,7 +991,7 @@ fn max_diagnostics() { let mut fs = MemoryFileSystem::default(); let mut console = BufferConsole::default(); - for i in 0..60 { + for i in 0..10 { let file_path = PathBuf::from(format!("src/file_{i}.js")); fs.insert(file_path, LINT_ERROR.as_bytes()); } @@ -1041,11 +1030,6 @@ fn max_diagnostics() { console.out_buffer = filtered_messages; - for i in 0..60 { - let file_path = format!("src/file_{i}.js"); - fs.remove(Path::new(&file_path)); - } - assert_cli_snapshot(SnapshotPayload::new( module_path!(), "max_diagnostics", diff --git a/crates/rome_cli/tests/commands/format.rs b/crates/rome_cli/tests/commands/format.rs index 6de7a461787..b351ca36e98 100644 --- a/crates/rome_cli/tests/commands/format.rs +++ b/crates/rome_cli/tests/commands/format.rs @@ -499,7 +499,6 @@ fn applies_custom_trailing_comma() { file.read_to_string(&mut content) .expect("failed to read file from memory FS"); - dbg!(&content); assert_eq!(content, APPLY_TRAILING_COMMA_AFTER); drop(file); @@ -572,7 +571,6 @@ fn with_semicolons_options() { file.read_to_string(&mut content) .expect("failed to read file from memory FS"); - dbg!(&content); assert_eq!(content, "statement()\n"); drop(file); diff --git a/crates/rome_cli/tests/snap_test.rs b/crates/rome_cli/tests/snap_test.rs index e4788d7d44a..b2b42694ff1 100644 --- a/crates/rome_cli/tests/snap_test.rs +++ b/crates/rome_cli/tests/snap_test.rs @@ -128,10 +128,7 @@ fn redact_snapshot(input: &str) -> Cow<'_, str> { replace(&mut output, ¤t_exe, "rome"); } - // Replace the path to the temporary directory with "" - let temp_dir = temp_dir().display().to_string(); - let temp_dir = temp_dir.trim_end_matches(MAIN_SEPARATOR); - replace(&mut output, temp_dir, ""); + output = replace_temp_dir(output); // Normalize Windows-specific path separators to "/" if cfg!(windows) { @@ -173,6 +170,46 @@ fn redact_snapshot(input: &str) -> Cow<'_, str> { output } +/// Replace the path to the temporary directory with "" +/// And normalizes the count of `-` at the end of the diagnostic +fn replace_temp_dir(input: Cow) -> Cow { + let mut result = String::new(); + let mut rest = input.as_ref(); + + let temp_dir = temp_dir().display().to_string(); + let temp_dir = temp_dir.trim_end_matches(MAIN_SEPARATOR); + + while let Some(index) = rest.find(temp_dir) { + let (before, after) = rest.split_at(index); + + result.push_str(before); + result.push_str(""); + + let after = after.split_at(temp_dir.len()).1; + let header_line = after.lines().next().unwrap(); + + match header_line.split_once('\u{2501}') { + Some((between_temp_and_line, _)) => { + // Diagnostic header line, normalize the horizontal line + result.push_str(between_temp_and_line); + result.push_str(&"\u{2501}".repeat(20)); + rest = after.split_at(header_line.len()).1; + } + None => { + // Not a header line, only replace tempdir + rest = after; + } + } + } + + if result.is_empty() { + input + } else { + result.push_str(rest); + Cow::Owned(result) + } +} + fn replace(input: &mut Cow, from: &str, to: &str) { let mut rest = &**input; let mut result = String::new(); diff --git a/crates/rome_cli/tests/snapshots/main_commands_check/fs_error_dereferenced_symlink_unix.snap b/crates/rome_cli/tests/snapshots/main_commands_check/fs_error_dereferenced_symlink.snap similarity index 87% rename from crates/rome_cli/tests/snapshots/main_commands_check/fs_error_dereferenced_symlink_unix.snap rename to crates/rome_cli/tests/snapshots/main_commands_check/fs_error_dereferenced_symlink.snap index 749f86e7ca1..5f46a473816 100644 --- a/crates/rome_cli/tests/snapshots/main_commands_check/fs_error_dereferenced_symlink_unix.snap +++ b/crates/rome_cli/tests/snapshots/main_commands_check/fs_error_dereferenced_symlink.snap @@ -11,7 +11,7 @@ no files were processed in the specified paths. # Emitted Messages ```block -/rome_test_broken_symlink/broken_symlink internalError/fs ━━━━━━━━━━ +/rome_test_broken_symlink/broken_symlink internalError/fs ━━━━━━━━━━━━━━━━━━━━ ! Dereferenced symlink diff --git a/crates/rome_cli/tests/snapshots/main_commands_check/fs_error_dereferenced_symlink_windows.snap b/crates/rome_cli/tests/snapshots/main_commands_check/fs_error_dereferenced_symlink_windows.snap deleted file mode 100644 index 749f86e7ca1..00000000000 --- a/crates/rome_cli/tests/snapshots/main_commands_check/fs_error_dereferenced_symlink_windows.snap +++ /dev/null @@ -1,27 +0,0 @@ ---- -source: crates/rome_cli/tests/snap_test.rs -expression: content ---- -# Termination Message - -```block -no files were processed in the specified paths. -``` - -# Emitted Messages - -```block -/rome_test_broken_symlink/broken_symlink internalError/fs ━━━━━━━━━━ - - ! Dereferenced symlink - - i Rome encountered a file system entry that is a broken symbolic link: /rome_test_broken_symlink/broken_symlink - - -``` - -```block -Checked 0 file(s) in