This is an archive of the discontinued LLVM Phabricator instance.

[lit] Test /dev/null support on Windows.
ClosedPublic

Authored by mtrofin on Mar 21 2018, 11:10 PM.

Diff Detail

Event Timeline

mtrofin created this revision.Mar 21 2018, 11:10 PM

This might be a dumb question, but in Windows you can use NUL instead of /dev/null. Instead of all this hackery around temp files, why don't we just replace /dev/null with NUL?

rnk added a comment.Mar 22 2018, 12:42 PM

This might be a dumb question, but in Windows you can use NUL instead of /dev/null. Instead of all this hackery around temp files, why don't we just replace /dev/null with NUL?

We should do that, but I consider it future work. It will require more testing. I have a feeling if you just say open("NUL", mode) you will create a file called "NUL" in the cwd. It's not something you can feed to generic filesystem APIs.

utils/lit/tests/unit/TestRunner.py
105

This should match the 4 space indent.

In D44771#1046003, @rnk wrote:

I have a feeling if you just say open("NUL", mode) you will create a file called "NUL" in the cwd. It's not something you can feed to generic filesystem APIs.

No, it won't create a file named NUL. The special file names are handled at a relatively low level in the Windows stack (below _open). You would have to use a namespace escape like \\?\ to avoid having Windows treat your special file name as a regular name. The special names are: CON, PRN, AUX, NUL, COM1, COM2, COM3, COM4, COM5, COM6, COM7, COM8, COM9, LPT1, LPT2, LPT3, LPT4, LPT5, LPT6, LPT7, LPT8, and LPT9.

mtrofin updated this revision to Diff 139606.Mar 23 2018, 9:39 AM

Spaces (2->4)

mtrofin marked an inline comment as done.Mar 23 2018, 9:39 AM
rnk requested changes to this revision.Mar 23 2018, 11:45 AM

I ran the tests, and the unit tests don't pass because the /dev/null replacement happens much later during test execution, not command parsing. Unit testing the text executor would require much more faking/mocking than is really worth it. I would be comfortable making this change include a revert of rL328157. That will exercise the new replacement enough.

This revision now requires changes to proceed.Mar 23 2018, 11:45 AM
mtrofin updated this revision to Diff 139633.Mar 23 2018, 12:04 PM

Revert "[llvm-profdata] Use "-o /dev/null" in invalid-profdata.test"

mtrofin updated this revision to Diff 139728.Mar 24 2018, 12:01 PM
  • [lit] windows dev null shshell test
rnk accepted this revision.Mar 26 2018, 10:41 AM

Looks good after reverting the unit test that didn't work.

utils/lit/tests/Inputs/shtest-shell/dev-null.txt
1 ↗(On Diff #139728)

New test looks good, thanks!

utils/lit/tests/unit/TestRunner.py
108

This test still fails because the parser doesn't do the replacement. You need to revert changes to this file and probably testrunner-custom-parsers/test.txt before committing or tests will fail on Windows.

This revision is now accepted and ready to land.Mar 26 2018, 10:41 AM
mtrofin updated this revision to Diff 139859.Mar 26 2018, 3:39 PM

Revert old test changes.

This revision was automatically updated to reflect the committed changes.