When using lit's internal shell, RUN lines like the following
accidentally execute an external diff instead of lit's internal
diff:
# RUN: program | diff file - # RUN: not diff file1 file2 | FileCheck %s
Such cases exist now, in clang/test/Analysis for example. We are
preparing patches to ensure lit's internal diff is called in such
cases, which will then fail because lit's internal diff cannot
currently be used in pipelines and doesn't recognize - as a
command-line option.
To enable pipelines, this patch moves lit's diff implementation into
an out-of-process script, similar to lit's cat implementation. A
follow-up patch will implement - to mean stdin.
Also, when lit's diff prints differences to stdout in Windows, this
patch ensures it always terminate lines with \n not \r\n. That
way, strict FileCheck directives checking the diff output succeed in
both Linux and Windows. This wasn't an issue when diff was internal
to lit because diff didn't then write to the true stdout, which is
where the \n -> \r\n conversion happened in Python.
I've also seen "a" and "U1" in my searches.
Does this correctly handle combined short options? e.g. "-aub" which I see used a fair amount.
I didn't notice --strip-trailing-cr anywhere but presumably the original author needed it, so probably should keep it.
I was going to say we don't need to bother with "r" but then I found a case that used it!