@@ -18,160 +18,181 @@ suite "Nimlangserver extensions":
1818 " extension/statusUpdate" , " textDocument/publishDiagnostics" , " $/progress" ,
1919 )
2020
21- test " calling extension/suggest with restart in the project uri should restart nimsuggest" :
22- let initParams =
23- InitializeParams %* {
24- " processId" : % getCurrentProcessId (),
25- " rootUri" : fixtureUri (" projects/hw/" ),
26- " capabilities" :
27- {" window" : {" workDoneProgress" : true }, " workspace" : {" configuration" : true }},
28- }
29- let initializeResult = waitFor client.initialize (initParams)
30-
31- check initializeResult.capabilities.textDocumentSync.isSome
32-
33- let helloWorldUri = fixtureUri (" projects/hw/hw.nim" )
34- let helloWorldFile = " projects/hw/hw.nim"
35- let hwAbsFile = uriToPath (helloWorldFile.fixtureUri ())
36- client.notify (" textDocument/didOpen" , % createDidOpenParams (helloWorldFile))
21+ # test "calling extension/suggest with restart in the project uri should restart nimsuggest":
22+ # let initParams =
23+ # InitializeParams %* {
24+ # "processId": %getCurrentProcessId(),
25+ # "rootUri": fixtureUri("projects/hw/"),
26+ # "capabilities":
27+ # {"window": {"workDoneProgress": true}, "workspace": {"configuration": true}},
28+ # }
29+ # let initializeResult = waitFor client.initialize(initParams)
30+
31+ # check initializeResult.capabilities.textDocumentSync.isSome
32+
33+ # let helloWorldUri = fixtureUri("projects/hw/hw.nim")
34+ # let helloWorldFile = "projects/hw/hw.nim"
35+ # let hwAbsFile = uriToPath(helloWorldFile.fixtureUri())
36+ # client.notify("textDocument/didOpen", %createDidOpenParams(helloWorldFile))
3737
38- check waitFor client.waitForNotificationMessage (
39- fmt" Nimsuggest initialized for { hwAbsFile} " ,
40- )
41-
42- client.notify (
43- " textDocument/didOpen" , % createDidOpenParams (" projects/hw/useRoot.nim" )
44- )
45-
46- let prevSuggestPid = ls.projectFiles[hwAbsFile].process.pid
47- let suggestParams = SuggestParams (action: saRestart, projectFile: hwAbsFile)
48- let suggestRes = client.call (" extension/suggest" , % suggestParams).waitFor
49- let suggestPid = ls.projectFiles[hwAbsFile].process.pid
50-
51- check prevSuggestPid != suggestPid
52-
53- test " calling extension/tasks should return all existing tasks" :
54- let initParams =
55- InitializeParams %* {
56- " processId" : % getCurrentProcessId (),
57- " rootUri" : fixtureUri (" projects/tasks/" ),
58- " capabilities" :
59- {" window" : {" workDoneProgress" : true }, " workspace" : {" configuration" : true }},
60- }
61- let initializeResult = waitFor client.initialize (initParams)
62-
63- let tasksFile = " projects/tasks/src/tasks.nim"
64- let taskAbsFile = uriToPath (tasksFile.fixtureUri ())
65- client.notify (" textDocument/didOpen" , % createDidOpenParams (tasksFile))
66-
67- let tasks = client.call (" extension/tasks" , jsonutils.toJson (())).waitFor ().jsonTo (
68- seq [NimbleTask ]
69- )
70-
71- check tasks.len == 3
72- check tasks[0 ].name == " helloWorld"
73- check tasks[0 ].description == " hello world"
74-
75- test " calling extension/listTests should return all existing tests" :
76- # We first need to initialize the nimble project
77- let projectDir = getCurrentDir () / " tests" / " projects" / " testrunner"
78- cd projectDir:
79- let (output, _) = execNimble (" install" , " -l" )
80- discard execNimble (" setup" )
81-
82- let initParams =
83- InitializeParams %* {
84- " processId" : % getCurrentProcessId (),
85- " rootUri" : fixtureUri (" projects/testrunner/" ),
86- " capabilities" :
87- {" window" : {" workDoneProgress" : true }, " workspace" : {" configuration" : true }},
88- }
89- let initializeResult = waitFor client.initialize (initParams)
90-
91- let listTestsParams = ListTestsParams (entryPoints: @ [" tests/projects/testrunner/tests/sampletests.nim" .absolutePath])
92- let tests = client.call (" extension/listTests" , jsonutils.toJson (listTestsParams)).waitFor ().jsonTo (
93- ListTestsResult
94- )
95- let testProjectInfo = tests.projectInfo
96- check testProjectInfo.suites.len == 3
97- check testProjectInfo.suites[" Sample Tests" ].tests.len == 1
98- check testProjectInfo.suites[" Sample Tests" ].tests[0 ].name == " Sample Test alone"
99- check testProjectInfo.suites[" Sample Tests" ].tests[0 ].file == " sampletests.nim"
100- check testProjectInfo.suites[" Sample Tests" ].tests[0 ].line == 4
101-
102- test " calling extension/runTests should run the tests and return the results" :
103- let initParams =
104- InitializeParams %* {
105- " processId" : % getCurrentProcessId (),
106- " rootUri" : fixtureUri (" projects/testrunner/" ),
107- " capabilities" :
108- {" window" : {" workDoneProgress" : true }, " workspace" : {" configuration" : true }},
109- }
110- let initializeResult = waitFor client.initialize (initParams)
111-
112- let runTestsParams = RunTestParams (entryPoints: @ [" tests/projects/testrunner/tests/sampletests.nim" .absolutePath])
113- let runTestsRes = client.call (" extension/runTests" , jsonutils.toJson (runTestsParams)).waitFor ().jsonTo (
114- RunTestProjectResult
115- )
116- check runTestsRes.suites.len == 4
117- check runTestsRes.suites[0 ].name == " Sample Tests"
118- check runTestsRes.suites[0 ].tests == 1
119- check runTestsRes.suites[0 ].failures == 0
120- check runTestsRes.suites[0 ].errors == 0
121- check runTestsRes.suites[0 ].skipped == 0
122- check runTestsRes.suites[0 ].time > 0.0 and runTestsRes.suites[0 ].time < 1.0
123-
124- test " calling extension/runTest with a suite name should run the tests in the suite" :
125- let initParams =
126- InitializeParams %* {
127- " processId" : % getCurrentProcessId (),
128- " rootUri" : fixtureUri (" projects/testrunner/" ),
129- " capabilities" :
130- {" window" : {" workDoneProgress" : true }, " workspace" : {" configuration" : true }},
131- }
132- let initializeResult = waitFor client.initialize (initParams)
133-
134- let suiteName = " Sample Suite"
135- let runTestsParams = RunTestParams (entryPoints: @ [" tests/projects/testrunner/tests/sampletests.nim" .absolutePath], suiteName: suiteName)
136- let runTestsRes = client.call (" extension/runTests" , jsonutils.toJson (runTestsParams)).waitFor ().jsonTo (
137- RunTestProjectResult
138- )
139- check runTestsRes.suites.len == 1
140- check runTestsRes.suites[0 ].name == suiteName
141- check runTestsRes.suites[0 ].tests == 3
142-
143- test " calling extension/runTest with a test name should run the tests in the suite" :
38+ # check waitFor client.waitForNotificationMessage(
39+ # fmt"Nimsuggest initialized for {hwAbsFile}",
40+ # )
41+
42+ # client.notify(
43+ # "textDocument/didOpen", %createDidOpenParams("projects/hw/useRoot.nim")
44+ # )
45+
46+ # let prevSuggestPid = ls.projectFiles[hwAbsFile].process.pid
47+ # let suggestParams = SuggestParams(action: saRestart, projectFile: hwAbsFile)
48+ # let suggestRes = client.call("extension/suggest", %suggestParams).waitFor
49+ # let suggestPid = ls.projectFiles[hwAbsFile].process.pid
50+
51+ # check prevSuggestPid != suggestPid
52+
53+ # test "calling extension/tasks should return all existing tasks":
54+ # let initParams =
55+ # InitializeParams %* {
56+ # "processId": %getCurrentProcessId(),
57+ # "rootUri": fixtureUri("projects/tasks/"),
58+ # "capabilities":
59+ # {"window": {"workDoneProgress": true}, "workspace": {"configuration": true}},
60+ # }
61+ # let initializeResult = waitFor client.initialize(initParams)
62+
63+ # let tasksFile = "projects/tasks/src/tasks.nim"
64+ # let taskAbsFile = uriToPath(tasksFile.fixtureUri())
65+ # client.notify("textDocument/didOpen", %createDidOpenParams(tasksFile))
66+
67+ # let tasks = client.call("extension/tasks", jsonutils.toJson(())).waitFor().jsonTo(
68+ # seq[NimbleTask]
69+ # )
70+
71+ # check tasks.len == 3
72+ # check tasks[0].name == "helloWorld"
73+ # check tasks[0].description == "hello world"
74+
75+ # test "calling extension/listTests should return all existing tests":
76+ # #We first need to initialize the nimble project
77+ # let projectDir = getCurrentDir() / "tests" / "projects" / "testrunner"
78+ # cd projectDir:
79+ # let (output, _) = execNimble("install", "-l")
80+ # discard execNimble("setup")
81+
82+ # let initParams =
83+ # InitializeParams %* {
84+ # "processId": %getCurrentProcessId(),
85+ # "rootUri": fixtureUri("projects/testrunner/"),
86+ # "capabilities":
87+ # {"window": {"workDoneProgress": true}, "workspace": {"configuration": true}},
88+ # }
89+ # let initializeResult = waitFor client.initialize(initParams)
90+
91+ # let listTestsParams = ListTestsParams(entryPoints: @["tests/projects/testrunner/tests/sampletests.nim".absolutePath])
92+ # let tests = client.call("extension/listTests", jsonutils.toJson(listTestsParams)).waitFor().jsonTo(
93+ # ListTestsResult
94+ # )
95+ # let testProjectInfo = tests.projectInfo
96+ # check testProjectInfo.suites.len == 3
97+ # check testProjectInfo.suites["Sample Tests"].tests.len == 1
98+ # check testProjectInfo.suites["Sample Tests"].tests[0].name == "Sample Test alone"
99+ # check testProjectInfo.suites["Sample Tests"].tests[0].file == "sampletests.nim"
100+ # check testProjectInfo.suites["Sample Tests"].tests[0].line == 4
101+
102+ # test "calling extension/runTests should run the tests and return the results":
103+ # let initParams =
104+ # InitializeParams %* {
105+ # "processId": %getCurrentProcessId(),
106+ # "rootUri": fixtureUri("projects/testrunner/"),
107+ # "capabilities":
108+ # {"window": {"workDoneProgress": true}, "workspace": {"configuration": true}},
109+ # }
110+ # let initializeResult = waitFor client.initialize(initParams)
111+
112+ # let runTestsParams = RunTestParams(entryPoints: @["tests/projects/testrunner/tests/sampletests.nim".absolutePath])
113+ # let runTestsRes = client.call("extension/runTests", jsonutils.toJson(runTestsParams)).waitFor().jsonTo(
114+ # RunTestProjectResult
115+ # )
116+ # check runTestsRes.suites.len == 4
117+ # check runTestsRes.suites[0].name == "Sample Tests"
118+ # check runTestsRes.suites[0].tests == 1
119+ # check runTestsRes.suites[0].failures == 0
120+ # check runTestsRes.suites[0].errors == 0
121+ # check runTestsRes.suites[0].skipped == 0
122+ # check runTestsRes.suites[0].time > 0.0 and runTestsRes.suites[0].time < 1.0
123+
124+ # test "calling extension/runTest with a suite name should run the tests in the suite":
125+ # let initParams =
126+ # InitializeParams %* {
127+ # "processId": %getCurrentProcessId(),
128+ # "rootUri": fixtureUri("projects/testrunner/"),
129+ # "capabilities":
130+ # {"window": {"workDoneProgress": true}, "workspace": {"configuration": true}},
131+ # }
132+ # let initializeResult = waitFor client.initialize(initParams)
133+
134+ # let suiteName = "Sample Suite"
135+ # let runTestsParams = RunTestParams(entryPoints: @["tests/projects/testrunner/tests/sampletests.nim".absolutePath], suiteName: suiteName)
136+ # let runTestsRes = client.call("extension/runTests", jsonutils.toJson(runTestsParams)).waitFor().jsonTo(
137+ # RunTestProjectResult
138+ # )
139+ # check runTestsRes.suites.len == 1
140+ # check runTestsRes.suites[0].name == suiteName
141+ # check runTestsRes.suites[0].tests == 3
142+
143+ # test "calling extension/runTest with a test name should run the tests in the suite":
144+ # let initParams =
145+ # InitializeParams %* {
146+ # "processId": %getCurrentProcessId(),
147+ # "rootUri": fixtureUri("projects/testrunner/"),
148+ # "capabilities":
149+ # {"window": {"workDoneProgress": true}, "workspace": {"configuration": true}},
150+ # }
151+
152+ # let initializeResult = waitFor client.initialize(initParams)
153+
154+ # let testName = "Sample Test"
155+ # let runTestsParams = RunTestParams(entryPoints: @["tests/projects/testrunner/tests/sampletests.nim".absolutePath], testNames: @[testName])
156+ # let runTestsRes = client.call("extension/runTests", jsonutils.toJson(runTestsParams)).waitFor().jsonTo(RunTestProjectResult)
157+
158+ # check runTestsRes.suites.len == 1
159+ # check runTestsRes.suites[0].tests == 1
160+ # check runTestsRes.suites[0].testResults[0].name == testName
161+
162+ # test "calling extension/runTest with multiple test names should run the tests in the suite":
163+ # let initParams =
164+ # InitializeParams %* {
165+ # "processId": %getCurrentProcessId(),
166+ # "rootUri": fixtureUri("projects/testrunner/"),
167+ # "capabilities":
168+ # {"window": {"workDoneProgress": true}, "workspace": {"configuration": true}},
169+ # }
170+ # let initializeResult = waitFor client.initialize(initParams)
171+
172+ # let testNames = @["Sample Test", "Sample Test 2"]
173+ # let runTestsParams = RunTestParams(entryPoints: @["tests/projects/testrunner/tests/sampletests.nim".absolutePath], testNames: testNames)
174+ # let runTestsRes = client.call("extension/runTests", jsonutils.toJson(runTestsParams)).waitFor().jsonTo(RunTestProjectResult)
175+
176+ # check runTestsRes.suites.len == 1
177+ # check runTestsRes.suites[0].tests == 2
178+
179+ test " calling extension/runTest with a failing test should return the failure" :
144180 let initParams =
145181 InitializeParams %* {
146182 " processId" : % getCurrentProcessId (),
147183 " rootUri" : fixtureUri (" projects/testrunner/" ),
148184 " capabilities" :
149185 {" window" : {" workDoneProgress" : true }, " workspace" : {" configuration" : true }},
150186 }
151-
187+
152188 let initializeResult = waitFor client.initialize (initParams)
153189
154- let testName = " Sample Test"
155- let runTestsParams = RunTestParams (entryPoints: @ [" tests/projects/testrunner/tests/sampletests.nim" .absolutePath], testNames: @ [testName])
190+ let runTestsParams = RunTestParams (entryPoints: @ [" tests/projects/testrunner/tests/failingtest.nim" .absolutePath])
156191 let runTestsRes = client.call (" extension/runTests" , jsonutils.toJson (runTestsParams)).waitFor ().jsonTo (RunTestProjectResult )
157192
158193 check runTestsRes.suites.len == 1
159- check runTestsRes.suites[0 ].tests == 1
160- check runTestsRes.suites[0 ].testResults[0 ].name == testName
161-
162- test " calling extension/runTest with multiple test names should run the tests in the suite" :
163- let initParams =
164- InitializeParams %* {
165- " processId" : % getCurrentProcessId (),
166- " rootUri" : fixtureUri (" projects/testrunner/" ),
167- " capabilities" :
168- {" window" : {" workDoneProgress" : true }, " workspace" : {" configuration" : true }},
169- }
170- let initializeResult = waitFor client.initialize (initParams)
171-
172- let testNames = @ [" Sample Test" , " Sample Test 2" ]
173- let runTestsParams = RunTestParams (entryPoints: @ [" tests/projects/testrunner/tests/sampletests.nim" .absolutePath], testNames: testNames)
174- let runTestsRes = client.call (" extension/runTests" , jsonutils.toJson (runTestsParams)).waitFor ().jsonTo (RunTestProjectResult )
175-
176- check runTestsRes.suites.len == 1
177- check runTestsRes.suites[0 ].tests == 2
194+ check runTestsRes.suites[0 ].name == " Failing Tests"
195+ check runTestsRes.suites[0 ].tests == 2
196+ check runTestsRes.suites[0 ].failures == 1
197+ check runTestsRes.suites[0 ].testResults[0 ].name == " Failing Test"
198+ check runTestsRes.suites[0 ].testResults[0 ].failure.isSome
0 commit comments