Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
crates/oxc_formatter/tests/fixtures/** text=auto eol=lf
apps/oxfmt/tests/fixtures/** text=auto eol=lf
apps/oxlint/test/fixtures/** text=auto eol=lf
13 changes: 2 additions & 11 deletions crates/oxc_formatter/tests/fixtures/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ fn generate_snapshot(path: &Path, source_text: &str) -> String {
}

let options = parse_format_options(&option_json);
let formatted = normalize_newlines(format_source(source_text, source_type, options));
let formatted = format_source(source_text, source_type, options);
snapshot.push_str(&formatted);
snapshot.push('\n');
}
Expand All @@ -199,7 +199,7 @@ fn generate_snapshot(path: &Path, source_text: &str) -> String {

/// Helper function to run a test for a single file
fn test_file(path: &Path) {
let source_text = normalize_newlines(fs::read_to_string(path).unwrap());
let source_text = fs::read_to_string(path).unwrap();
let snapshot = generate_snapshot(path, &source_text);
let snapshot_path = current_dir().unwrap().join(path.parent().unwrap());
let snapshot_name = path.file_name().unwrap().to_str().unwrap();
Expand All @@ -215,14 +215,5 @@ fn test_file(path: &Path) {
});
}

#[expect(clippy::disallowed_methods)]
fn normalize_newlines(text: String) -> String {
if !text.contains('\r') {
return text;
}

text.replace("\r\n", "\n")
}

// Include auto-generated test functions from build.rs
include!(concat!(env!("OUT_DIR"), "/generated_tests.rs"));
Loading