diff --git a/nimlangserver.nimble b/nimlangserver.nimble index 576e275..c72afa1 100644 --- a/nimlangserver.nimble +++ b/nimlangserver.nimble @@ -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" diff --git a/testrunner.nim b/testrunner.nim index 7e66b76..1b60598 100644 --- a/testrunner.nim +++ b/testrunner.nim @@ -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: @@ -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()}::") @@ -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)) @@ -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) \ No newline at end of file