Skip to content

Issue runner #339

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

Merged
merged 2 commits into from
Apr 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nimlangserver.nimble
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mode = ScriptMode.Verbose

packageName = "nimlangserver"
version = "1.10.2"
version = "1.12.0"
author = "The core Nim team"
description = "Nim language server for IDEs"
license = "MIT"
Expand Down
27 changes: 16 additions & 11 deletions testrunner.nim
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,18 @@ proc listTests*(
stdoutHandle = AsyncProcess.Pipe,
)
try:
let (rawOutput, error, res) = await readOutputUntilExit(process, 15.seconds)
let (error, res) = await readErrorOutputUntilExit(process, 15.seconds)
if res != 0:
error "Failed to list tests", nimPath = nimPath, entryPoint = entryPoint, res = res
error "An error occurred while listing tests"
for line in error.splitLines:
error "Error line: ", line = line
error "Command args: ", args = args
result = TestProjectInfo(error: some error)
result = extractTestInfo(error)
if result.suites.len == 0:
error "Failed to list tests", nimPath = nimPath, entryPoint = entryPoint, res = res
error "An error occurred while listing tests"
for line in error.splitLines:
error "Error line: ", line = line
error "Command args: ", args = args
result = TestProjectInfo(error: some error)
else:
let rawOutput = await process.stdoutStream.readAllOutput()
debug "list test raw output", rawOutput = rawOutput
result = extractTestInfo(rawOutput)
finally:
Expand All @@ -108,6 +111,7 @@ proc runTests*(
error "Entry point does not exist", entryPoint = entryPoint
return RunTestProjectResult()
let resultFile = (getTempDir() / "result.xml").absolutePath
removeFile(resultFile)
var args = @["c", "-r", entryPoint , fmt"--xml:{resultFile}"]
if suiteName.isSome:
args.add(fmt"{suiteName.get()}::")
Expand All @@ -124,8 +128,7 @@ proc runTests*(
)
ls.testRunProcess = some(process)
try:
removeFile(resultFile)
let (output, error, res) = await readOutputUntilExit(process, 15.seconds)
let (error, res) = await readErrorOutputUntilExit(process, 15.seconds)
if res != 0: #When a test fails, the process will exit with a non-zero code
if fileExists(resultFile):
result = parseTestResults(readFile(resultFile))
Expand All @@ -136,18 +139,20 @@ proc runTests*(
error "An error occurred while running tests"
error "Error from process", error = error
result = RunTestProjectResult(fullOutput: error)
result.fullOutput = output
result.fullOutput = error
else:
let output = await process.stdoutStream.readAllOutput()
let xmlContent = readFile(resultFile)
# echo "XML CONTENT: ", xmlContent
result = parseTestResults(xmlContent)
result.fullOutput = output
removeFile(resultFile)

except Exception as e:
let processOutput = string.fromBytes(process.stdoutStream.read().await)
error "An error occurred while running tests", error = e.msg
error "Output from process", output = processOutput
finally:
removeFile(resultFile)
await shutdownChildProcess(process)
if ls.testRunProcess.isSome:
ls.testRunProcess = none(AsyncProcessRef)