Skip to content

Commit b0e97ed

Browse files
authored
Issue runner (#339)
* Bumps 1.12.0 * Fixes an issue in the test runner
1 parent 4cddf13 commit b0e97ed

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

testrunner.nim

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,18 @@ proc listTests*(
8181
stdoutHandle = AsyncProcess.Pipe,
8282
)
8383
try:
84-
let (rawOutput, error, res) = await readOutputUntilExit(process, 15.seconds)
84+
let (error, res) = await readErrorOutputUntilExit(process, 15.seconds)
8585
if res != 0:
86-
error "Failed to list tests", nimPath = nimPath, entryPoint = entryPoint, res = res
87-
error "An error occurred while listing tests"
88-
for line in error.splitLines:
89-
error "Error line: ", line = line
90-
error "Command args: ", args = args
91-
result = TestProjectInfo(error: some error)
86+
result = extractTestInfo(error)
87+
if result.suites.len == 0:
88+
error "Failed to list tests", nimPath = nimPath, entryPoint = entryPoint, res = res
89+
error "An error occurred while listing tests"
90+
for line in error.splitLines:
91+
error "Error line: ", line = line
92+
error "Command args: ", args = args
93+
result = TestProjectInfo(error: some error)
9294
else:
95+
let rawOutput = await process.stdoutStream.readAllOutput()
9396
debug "list test raw output", rawOutput = rawOutput
9497
result = extractTestInfo(rawOutput)
9598
finally:
@@ -108,6 +111,7 @@ proc runTests*(
108111
error "Entry point does not exist", entryPoint = entryPoint
109112
return RunTestProjectResult()
110113
let resultFile = (getTempDir() / "result.xml").absolutePath
114+
removeFile(resultFile)
111115
var args = @["c", "-r", entryPoint , fmt"--xml:{resultFile}"]
112116
if suiteName.isSome:
113117
args.add(fmt"{suiteName.get()}::")
@@ -124,8 +128,7 @@ proc runTests*(
124128
)
125129
ls.testRunProcess = some(process)
126130
try:
127-
removeFile(resultFile)
128-
let (output, error, res) = await readOutputUntilExit(process, 15.seconds)
131+
let (error, res) = await readErrorOutputUntilExit(process, 15.seconds)
129132
if res != 0: #When a test fails, the process will exit with a non-zero code
130133
if fileExists(resultFile):
131134
result = parseTestResults(readFile(resultFile))
@@ -136,18 +139,20 @@ proc runTests*(
136139
error "An error occurred while running tests"
137140
error "Error from process", error = error
138141
result = RunTestProjectResult(fullOutput: error)
139-
result.fullOutput = output
142+
result.fullOutput = error
140143
else:
144+
let output = await process.stdoutStream.readAllOutput()
141145
let xmlContent = readFile(resultFile)
142146
# echo "XML CONTENT: ", xmlContent
143147
result = parseTestResults(xmlContent)
144148
result.fullOutput = output
145-
removeFile(resultFile)
149+
146150
except Exception as e:
147151
let processOutput = string.fromBytes(process.stdoutStream.read().await)
148152
error "An error occurred while running tests", error = e.msg
149153
error "Output from process", output = processOutput
150154
finally:
155+
removeFile(resultFile)
151156
await shutdownChildProcess(process)
152157
if ls.testRunProcess.isSome:
153158
ls.testRunProcess = none(AsyncProcessRef)

0 commit comments

Comments
 (0)