Skip to content

Commit 67660ce

Browse files
committed
ci(formatter): Use gitattributes for CRLF normalization
1 parent 51c1c45 commit 67660ce

File tree

3 files changed

+4
-12
lines changed

3 files changed

+4
-12
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
crates/oxc_formatter/tests/fixtures/** text=auto eol=lf
12
apps/oxfmt/tests/fixtures/** text=auto eol=lf
23
apps/oxlint/test/fixtures/** text=auto eol=lf

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ jobs:
6363
- run: git diff --exit-code # Must commit everything
6464

6565
test-windows:
66-
if: ${{ github.ref_name == 'main' }}
66+
# if: ${{ github.ref_name == 'main' }}
6767
name: Test Windows
6868
runs-on: windows-latest
6969
steps:

crates/oxc_formatter/tests/fixtures/mod.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ fn generate_snapshot(path: &Path, source_text: &str) -> String {
187187
}
188188

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

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

218-
#[expect(clippy::disallowed_methods)]
219-
fn normalize_newlines(text: String) -> String {
220-
if !text.contains('\r') {
221-
return text;
222-
}
223-
224-
text.replace("\r\n", "\n")
225-
}
226-
227218
// Include auto-generated test functions from build.rs
228219
include!(concat!(env!("OUT_DIR"), "/generated_tests.rs"));

0 commit comments

Comments
 (0)