INNER CODE UNIT · Python
line_ending_counts
uxlfoundation/oneDAL · dev/release_tests/compare_release_trees.py:540
def line_ending_counts(data):
crlf = data.count(b"\r\n")
lf = data.count(b"\n") - crlf
cr = data.count(b"\r") - crlf
return crlf, lf, cr
def describe_text_mismatch(make_root, bazel_root, path):
"""Summarise *how* two text files differ, so a CI log is enough to diagnose.
Printing only the path leaves the reader unable to tell a line-ending
difference from a content one without reproducing the build, which on
Windows means a multi-hour job.
"""
make_bytes = (make_root / path).read_bytes()
bazel_bytes = (bazel_root / path).read_bytes()
make_eol = line_ending_counts(make_bytes)
bazel_eol = line_ending_counts(bazel_bytes)