Skip to content

Commit 9b29e91

Browse files
authored
Handles compiles errors in the tests (#327)
1 parent d178132 commit 9b29e91

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

protocol/types.nim

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,6 +1057,7 @@ type
10571057
TestProjectInfo* = object
10581058
entryPoints*: seq[string]
10591059
suites*: Table[string, TestSuiteInfo]
1060+
error*: Option[string]
10601061

10611062
ListTestsParams* = object
10621063
entryPoints*: seq[string] #can be patterns? if empty we could do the same as nimble does or just run `nimble test args`
@@ -1080,8 +1081,8 @@ type
10801081

10811082
RunTestParams* = object
10821083
entryPoints*: seq[string]
1083-
suiteName*: string #Optional, if provided, only run tests in the suite. Takes precedence over testName
1084-
testNames*: seq[string] #Optional, if provided, only run the specific tests
1084+
suiteName*: Option[string] #Optional, if provided, only run tests in the suite. Takes precedence over testName
1085+
testNames*: Option[seq[string]] #Optional, if provided, only run the specific tests
10851086

10861087
RunTestProjectResult* = object
10871088
suites*: seq[RunTestSuiteResult]

routes.nim

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,9 +868,8 @@ proc runTests*(
868868
if nimPath.isNone:
869869
error "Nim path not found when running tests"
870870
return RunTestProjectResult()
871-
let suiteName = if params.suiteName == "": none(string) else: some(params.suiteName)
872871
let workspaceRoot = ls.initializeParams.getRootPath
873-
await runTests(params.entryPoints, nimPath.get(), suiteName, params.testNames, workspaceRoot)
872+
await runTests(params.entryPoints, nimPath.get(), params.suiteName, params.testNames.get(@[]), workspaceRoot)
874873

875874
#Notifications
876875
proc initialized*(ls: LanguageServer, _: JsonNode): Future[void] {.async.} =

testrunner.nim

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,9 @@ proc listTests*(
5555
let res = await process.waitForExit(15.seconds)
5656
if res != 0:
5757
error "Failed to list tests", nimPath = nimPath, entryPoint = entryPoint, res = res
58-
error "An error occurred while listing tests", error = string.fromBytes(process.stderrStream.read().await)
58+
let error = string.fromBytes(process.stderrStream.read().await)
59+
error "An error occurred while listing tests", error = error
60+
result = TestProjectInfo(error: some error)
5961
else:
6062
let rawOutput = string.fromBytes(process.stdoutStream.read().await)
6163
result = extractTestInfo(rawOutput)

0 commit comments

Comments
 (0)