-
Notifications
You must be signed in to change notification settings - Fork 2
Mstoker/windows #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Mstoker/windows #29
Conversation
… true for testWindowsTrue()
…tform. false/true tests work now
…rn the string instead of the empty string. Refined windows tests (some still fail)
…o process struct. Removed some debug printing
…t to test outside a test suite
…tion deep in swift libs and then bailed.
…ods from libuv for quoting command arguments and searching the execution path. Used the quoting method to quote arguments.
… same time possible
…ynchronous write within an async context
… changing the environment. Failed tests early that were blocking on Windows. Test suite now runs to completion
…to restrict handles inherited by the child process
…causing a hang on Windows).
…ends FileManager as that type already posesses a 'nullDevice' property, but lacks its path.
… variable directly on Windows
let pipe = FDPipe() | ||
_ = async(fdMap: [ .stdout: pipe.fileHandleForWriting.fileDescriptor ]) | ||
pipe.fileHandleForWriting.close() | ||
// TODO: Previously, this returned a FileHandle, but the test using it fails without returning an FDFileHandle, because otherwise, on return, the FDFileHandle is deallocate and calls close(). Can maintain liveness of the FDFileHandle in some way without changing the interface of this call? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To do that, just duplicate the handle
throw InvalidString(data: data, encoding: encoding) | ||
} | ||
guard let trimStop = string.lastIndex(where: { $0 != "\n" }) else { | ||
// TODO: Shoudn't this return `string`? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, the string is all newlines and should be completely trimmed.
self.spawner = PosixSpawn() | ||
#elseif canImport(Glibc) | ||
self.spawner = LinuxSpawn() | ||
#elseif canImport(ucrt) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is mismatched with the import statement at the top of the file. They should both have the same #condition.
} | ||
|
||
static let NtSuspendProcess: (ProcessInformation) -> Int32 = { | ||
// TODO: Tie into (undocumented) NtSuspendProcess() syscall |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be a noop
} else if signal == SIGSTOP { | ||
// Method borrowed from https://github.com/giampaolo/psutil/blob/a7e70bb66d5823f2cdcdf0f950bdbf26875058b4/psutil/arch/windows/proc.c#L539 | ||
// See also https://ntopcode.wordpress.com/2018/01/16/anatomy-of-the-thread-suspension-mechanism-in-windows-windows-internals/ | ||
_ = Self.NtSuspendProcess(process) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These errors shouldn't be ignored
let parentFDMax = fdMap.keys.max() ?? -1 | ||
var childHandleArray = Array<HANDLE?>(repeating: nil, count: Int(parentFDMax + 1)) | ||
for (parentFD, childFD) in fdMap { | ||
childHandleArray[Int(parentFD)] = Self.osHandle(for: childFD) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
childHandleArray[Int(parentFD)] = Self.osHandle(for: childFD) | |
childHandleArray[Int(parentFD)] = osHandle(for: childFD) |
} | ||
|
||
private init?(_ handles: [HANDLE?]) { | ||
let handles = !shouldDuplicate ? handles : handles.map { Self.duplicate($0) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Self
shouldn't be used in classes unless you're absolutely sure you want to dispatch based on the dynamic type.
|
||
func testAbsPath() { | ||
#if os(Windows) | ||
XCTAssertEqual(try? cmd("C:\\Windows\\System32\\cmd.exe", "/C", "ECHO 1").runString(), "1\r\n") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the wrong answer. runString is supposed to remove the newline
let cProgramExecutable = "writer-\(id)" | ||
#endif | ||
|
||
try cmd("cat").input(cProgram).output(overwritingFile: cProgramFile).run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be put in the temp directory, not the current folder
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This script has been made non-executable
try to fix open call on windows
Adds Windows support to swsh, while trying to avoid the most grievous of sins.