Convert CRLF to LF in the output of tested commands. D120623 fixes the same issue differently.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libcxx/test/libcxx/selftest/dsl/dsl.sh.py | ||
---|---|---|
252–253 | Please remove the comment, and just mention it (including that URL) in the commit message. | |
libcxx/utils/libcxx/test/dsl.py | ||
178–180 | I'm mildly confused how the re.search on line 174 could ever succeed, if out always contains \r\n in place of \n. Patterns treat \n as magic, maybe? with open(out_path, 'w', newline='\n') as f: ^^^^^^^^^^^^ I'd like (you) to explore whether we can similarly push the \r\n handling all the way down into the library layer here. Should we delegate the \r\n handling down into _executeScriptInternal? Should we delegate it down into whatever _executeScriptInternal calls? Etc. Maybe it ultimately ends up that all we need to do is change subprocess.call(~~~) into subprocess.call(~~~, translateNewlines=True) or something; that would be awesome. |
libcxx/test/libcxx/selftest/dsl/dsl.sh.py | ||
---|---|---|
252–253 | Ok, will do. | |
libcxx/utils/libcxx/test/dsl.py | ||
178–180 | Yes, that's a bit strange - it'd clearly be better to move the newline fixup before that at least. I tried moving the fix all the way into llvm/utils/lit/lit/TestRunner.py, into _executeShCmd, by adding universal_newlines=True to the call to subprocess.Popen(). That did indeed also solve the issue for this test, but that did instead break a handful of other tests - e.g. https://github.com/llvm/llvm-project/blob/main/llvm/test/MC/ELF/diff2.s, which runs a process which outputs binary data to stdout (where python fails to interpret the non-ascii chars as text). So while I guess we should clean up such tests to not do that, I'm not sure if there's any other semi-legitimate case we might be breaking. But we can at least hoist the filtering up to within _executeScriptInternal, directly after the call to lit.TestRunner.executeScriptInternal. |
Removed the verbose bug workaround comment from the code, moved the CRLF filtering up to right after the call to lit.TestRunner.executeScriptInternal.
My understanding is that the forsurethisisnotanexistinglocale fix is pretty much orthogonal to the rest of this patch, and is uncontroversial. Feel free to land that one-liner (with explanatory commit message as discussed above).
I think what you've got here now (replace('\r\n', '\n') in _executeScriptInternal) is better than what you originally proposed. D120623 also looks reasonable to me (but affects tests that libc++ doesn't own, so make sure you've pinged some people relevant to those tests). However, I think both of these are going to need more eyeballs than mine.
Rebased, after committing acf20001a01119ce02d5f2b0282e5a7c966ca12c on its own. (No action needed here right now, awaiting verdict on D120623 first.)
Please remove the comment, and just mention it (including that URL) in the commit message.