Skip to content

Commit

Permalink
feat: rm extraneous LF from result mismatch output
Browse files Browse the repository at this point in the history
Co-authored-by: echolinq <[email protected]>
Co-authored-by: Shahar "Dawn" Or <[email protected]>
  • Loading branch information
3 people committed Jan 14, 2024
1 parent ffbb041 commit 51e9aa6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
8 changes: 2 additions & 6 deletions crates/eelco/src/app/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,11 @@ impl State {
} => 'arm: {
acc.push(ch.into());

let Some(stripped_crlf_once) = acc.strip_suffix("\r\n") else {
let Some(stripped_crlf_twice) = acc.strip_suffix("\r\n\r\n") else {
break 'arm vec![];
};

if !stripped_crlf_once.ends_with("\r\n") {
break 'arm vec![];
}

let sanitized = Self::sanitize(stripped_crlf_once)?;
let sanitized = Self::sanitize(stripped_crlf_twice)?;

if sanitized != expected_result.as_str() {
anyhow::bail!(indoc::formatdoc! {"
Expand Down
4 changes: 3 additions & 1 deletion crates/eelco/src/repl/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ impl TryFrom<(LFLine, LFLine)> for ReplEntry {
fn try_from((query, response): (LFLine, LFLine)) -> Result<Self, Self::Error> {
Ok(Self {
query: query.try_into()?,
expected_result: ExpectedResult(response.as_str().to_owned()),
expected_result: ExpectedResult(
response.as_str().strip_suffix('\n').unwrap().to_owned(),
),
})
}
}
Expand Down
3 changes: 1 addition & 2 deletions crates/eelco/tests/repl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ fn result_mismatch() {

eelco.assert().failure().stderr(formatdoc! {r#"
Error: {file_path}:1
actual (sanitized): "2\n"
actual (sanitized): "2"
expected : 3
"#});
});
}
Expand Down

0 comments on commit 51e9aa6

Please sign in to comment.