Skip to content

Commit d171bd7

Browse files
committed
Compare format output without carriage returns in the spacing test
The formatter writes CRLF on Windows, so the new rewatch format test failed there on line endings alone; it now strips them before comparing. Signed-off-by: Roland Peelen <roland@magic.dev>
1 parent 2fd7cd9 commit d171bd7

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎rewatch/tests/format/06-format-experimental-multiline-item-spacing.sh‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ expected='module A = {
1818
let y = 2
1919
let z = 3'
2020

21+
# The formatter writes CRLF on Windows. $(...) drops the trailing newline, so
22+
# compare against the input without it.
2123
without=$(printf '%s' "$input" | "$REWATCH_EXECUTABLE" format --stdin .res)
22-
# $(...) drops the trailing newline, so compare against the input without it
23-
if [ $? -ne 0 ] || [ "$without" != "${input%$'\n'}" ]; then
24+
status=$?
25+
without=$(printf '%s' "$without" | tr -d '\r')
26+
if [ $status -ne 0 ] || [ "$without" != "${input%$'\n'}" ]; then
2427
error "Format changed spacing without the experimental feature"
2528
echo "$without"
2629
exit 1
@@ -37,6 +40,7 @@ fs.writeFileSync("rescript.json", JSON.stringify(j,null,2));
3740
with=$(printf '%s' "$input" | "$REWATCH_EXECUTABLE" format --stdin .res)
3841
status=$?
3942
mv rescript.json.bak rescript.json
43+
with=$(printf '%s' "$with" | tr -d '\r')
4044

4145
if [ $status -ne 0 ] || [ "$with" != "$expected" ]; then
4246
error "Format did not space multi-line items with MultilineItemSpacing"

0 commit comments

Comments
 (0)