fix compilation errors in windows

This commit is contained in:
Eric 2025-03-24 19:56:52 +11:00
parent b060c8d520
commit 6bb7457824
No known key found for this signature in database
2 changed files with 12 additions and 7 deletions

View File

@ -401,13 +401,15 @@ proc closeProcessStreams(test: IntegrationTest) {.async: (raises: []).} =
# Windows hangs when attempting to close the test's process streams, so try
# to kill the process externally.
try:
let cmdResult = await test.forceKillProcess("nim.exe", &"-d:TestId {test.testId}")
let cmdResult = await forceKillProcess("nim.exe", &"-d:TestId {test.testId}")
if cmdResult.status > 0:
error "Failed to forcefully kill windows test process",
port, exitCode = cmdResult.status, stderr = cmdResult.stdError
testId = test.testId, exitCode = cmdResult.status, stderr = cmdResult.stdError
else:
trace "Successfully killed windows test process by force",
port, exitCode = cmdResult.status, stdout = cmdResult.stdOutput
testId = test.testId,
exitCode = cmdResult.status,
stdout = cmdResult.stdOutput
except ValueError, OSError:
let eMsg = getCurrentExceptionMsg()
error "Failed to forcefully kill windows test process, bad path to command",
@ -415,10 +417,11 @@ proc closeProcessStreams(test: IntegrationTest) {.async: (raises: []).} =
except CancelledError as e:
discard
except AsyncProcessError as e:
error "Failed to forcefully kill windows test process", port, error = e.msg
error "Failed to forcefully kill windows test process",
testId = test.testId, error = e.msg
except AsyncProcessTimeoutError as e:
error "Timeout while forcefully killing windows test process",
port, error = e.msg
testId = test.testId, error = e.msg
proc teardownTest(test: IntegrationTest) {.async: (raises: []).} =
logScope:

View File

@ -1,4 +1,5 @@
import std/os
import std/strformat
import pkg/chronos
import pkg/chronos/asyncproc
import pkg/codex/logutils
@ -67,12 +68,13 @@ proc appendFile*(filename: string, content: string) {.raises: [IOError].} =
close(f)
when defined(windows):
proc forceKillProcess(
proc forceKillProcess*(
processName, matchingCriteria: string
): Future[CommandExResponse] {.
async: (
raises: [
AsyncProcessError, AsyncProcessTimeoutError, CancelledError, ValueError, OSError
AsyncProcessError, AsyncProcessTimeoutError, CancelledError, ValueError,
OSError,
]
)
.} =