Skip to content

Commit

Permalink
Normalize line endings when parsing files
Browse files Browse the repository at this point in the history
  • Loading branch information
bglw committed May 21, 2024
1 parent 0114873 commit 9308680
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions toolproof/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ mod interactive;
mod logging;
mod options;
mod parser;
mod platforms;
mod runner;
mod segments;
mod snapshot_writer;
Expand Down
3 changes: 2 additions & 1 deletion toolproof/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use serde_json::{Map, Value};

use crate::{
errors::ToolproofInputError,
platforms::normalize_line_endings,
segments::{ToolproofSegment, ToolproofSegments},
ToolproofTestFile, ToolproofTestStep, ToolproofTestStepState,
};
Expand Down Expand Up @@ -127,7 +128,7 @@ pub fn parse_file(s: &str, p: PathBuf) -> Result<ToolproofTestFile, ToolproofInp

ToolproofTestInput {
parsed: raw_test,
original_source: s.to_string(),
original_source: normalize_line_endings(s),
file_path: p.to_slash_lossy().into_owned(),
file_directory: p
.parent()
Expand Down
3 changes: 3 additions & 0 deletions toolproof/src/platforms.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pub fn normalize_line_endings(s: impl AsRef<str>) -> String {
s.as_ref().replace("\r\n", "\n")
}

0 comments on commit 9308680

Please sign in to comment.