@@ -81,15 +81,18 @@ proc listTests*(
81
81
stdoutHandle = AsyncProcess .Pipe ,
82
82
)
83
83
try :
84
- let (rawOutput, error, res) = await readOutputUntilExit (process, 15 .seconds)
84
+ let (error, res) = await readErrorOutputUntilExit (process, 15 .seconds)
85
85
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)
92
94
else :
95
+ let rawOutput = await process.stdoutStream.readAllOutput ()
93
96
debug " list test raw output" , rawOutput = rawOutput
94
97
result = extractTestInfo (rawOutput)
95
98
finally :
@@ -108,6 +111,7 @@ proc runTests*(
108
111
error " Entry point does not exist" , entryPoint = entryPoint
109
112
return RunTestProjectResult ()
110
113
let resultFile = (getTempDir () / " result.xml" ).absolutePath
114
+ removeFile (resultFile)
111
115
var args = @ [" c" , " -r" , entryPoint , fmt" --xml:{ resultFile} " ]
112
116
if suiteName.isSome:
113
117
args.add (fmt" { suiteName.get ()} ::" )
@@ -124,8 +128,7 @@ proc runTests*(
124
128
)
125
129
ls.testRunProcess = some (process)
126
130
try :
127
- removeFile (resultFile)
128
- let (output, error, res) = await readOutputUntilExit (process, 15 .seconds)
131
+ let (error, res) = await readErrorOutputUntilExit (process, 15 .seconds)
129
132
if res != 0 : # When a test fails, the process will exit with a non-zero code
130
133
if fileExists (resultFile):
131
134
result = parseTestResults (readFile (resultFile))
@@ -136,18 +139,20 @@ proc runTests*(
136
139
error " An error occurred while running tests"
137
140
error " Error from process" , error = error
138
141
result = RunTestProjectResult (fullOutput: error)
139
- result .fullOutput = output
142
+ result .fullOutput = error
140
143
else :
144
+ let output = await process.stdoutStream.readAllOutput ()
141
145
let xmlContent = readFile (resultFile)
142
146
# echo "XML CONTENT: ", xmlContent
143
147
result = parseTestResults (xmlContent)
144
148
result .fullOutput = output
145
- removeFile (resultFile)
149
+
146
150
except Exception as e:
147
151
let processOutput = string .fromBytes (process.stdoutStream.read ().await)
148
152
error " An error occurred while running tests" , error = e.msg
149
153
error " Output from process" , output = processOutput
150
154
finally :
155
+ removeFile (resultFile)
151
156
await shutdownChildProcess (process)
152
157
if ls.testRunProcess.isSome:
153
158
ls.testRunProcess = none (AsyncProcessRef )
0 commit comments