|
5 | 5 |
|
6 | 6 | package org.rustSlowTests.cargo.runconfig.test
|
7 | 7 |
|
8 |
| -import com.intellij.execution.configurations.RunConfiguration |
9 |
| -import com.intellij.execution.testframework.TestProxyRoot |
10 | 8 | import com.intellij.execution.testframework.sm.runner.SMTestProxy
|
11 |
| -import com.intellij.execution.testframework.sm.runner.ui.SMTRunnerConsoleView |
12 |
| -import com.intellij.openapi.util.Disposer |
13 |
| -import com.intellij.util.ui.UIUtil |
14 |
| -import org.rust.stdext.removeLast |
15 |
| -import org.rustSlowTests.cargo.runconfig.RunConfigurationTestBase |
16 | 9 |
|
17 |
| -class TestRunnerTest : RunConfigurationTestBase() { |
| 10 | +class CargoTestRunnerTest : CargoTestRunnerTestBase() { |
18 | 11 |
|
19 | 12 | fun `test test statuses`() {
|
20 | 13 | val testProject = buildProject {
|
@@ -265,13 +258,13 @@ class TestRunnerTest : RunConfigurationTestBase() {
|
265 | 258 | val configuration = createTestRunConfigurationFromContext()
|
266 | 259 | val root = executeAndGetTestRoot(configuration)
|
267 | 260 |
|
268 |
| - val test = findTestByName("tests::test", root) |
| 261 | + val test = root.findTestByName("tests::test") |
269 | 262 | assertEquals("cargo:test://tests::test", test.locationUrl)
|
270 | 263 |
|
271 |
| - val mod = findTestByName("tests::test_mod", root) |
| 264 | + val mod = root.findTestByName("tests::test_mod") |
272 | 265 | assertEquals("cargo:suite://tests::test_mod", mod.locationUrl)
|
273 | 266 |
|
274 |
| - val testInner = findTestByName("tests::test_mod::test", root) |
| 267 | + val testInner = root.findTestByName("tests::test_mod::test") |
275 | 268 | assertEquals("cargo:test://tests::test_mod::test", testInner.locationUrl)
|
276 | 269 | }
|
277 | 270 |
|
@@ -307,31 +300,18 @@ class TestRunnerTest : RunConfigurationTestBase() {
|
307 | 300 | val configuration = createTestRunConfigurationFromContext()
|
308 | 301 | val root = executeAndGetTestRoot(configuration)
|
309 | 302 |
|
310 |
| - val test1 = findTestByName("tests::test1", root) |
| 303 | + val test1 = root.findTestByName("tests::test1") |
311 | 304 | check(test1.duration!! > 1000) { "The `test1` duration too short" }
|
312 | 305 |
|
313 |
| - val test2 = findTestByName("tests::test2", root) |
| 306 | + val test2 = root.findTestByName("tests::test2") |
314 | 307 | check(test2.duration!! < 100) { "The `test2` duration too long" }
|
315 | 308 |
|
316 |
| - val mod = findTestByName("tests", root) |
| 309 | + val mod = root.findTestByName("tests") |
317 | 310 | check(mod.duration!! == test1.duration!! + test2.duration!!) {
|
318 | 311 | "The `tests` mod duration is not the sum of durations of containing tests"
|
319 | 312 | }
|
320 | 313 | }
|
321 | 314 |
|
322 |
| - private fun executeAndGetTestRoot(configuration: RunConfiguration): SMTestProxy.SMRootTestProxy { |
323 |
| - val result = execute(configuration) |
324 |
| - val executionConsole = result.executionConsole as SMTRunnerConsoleView |
325 |
| - val testsRootNode = executionConsole.resultsViewer.testsRootNode |
326 |
| - with(result.processHandler) { |
327 |
| - startNotify() |
328 |
| - waitFor() |
329 |
| - } |
330 |
| - UIUtil.dispatchAllInvocationEvents() |
331 |
| - Disposer.dispose(executionConsole) |
332 |
| - return testsRootNode |
333 |
| - } |
334 |
| - |
335 | 315 | private fun checkTestTree(expectedFormattedTestTree: String) {
|
336 | 316 | val configuration = createTestRunConfigurationFromContext()
|
337 | 317 | val root = executeAndGetTestRoot(configuration)
|
@@ -363,26 +343,5 @@ class TestRunnerTest : RunConfigurationTestBase() {
|
363 | 343 | formatLevel(child, level + 1)
|
364 | 344 | }
|
365 | 345 | }
|
366 |
| - |
367 |
| - private fun findTestByName(testFullName: String, root: SMTestProxy.SMRootTestProxy): SMTestProxy { |
368 |
| - val fullNameBuffer = mutableListOf<String>() |
369 |
| - |
370 |
| - fun find(test: SMTestProxy): SMTestProxy? { |
371 |
| - if (test !is TestProxyRoot) { |
372 |
| - fullNameBuffer.add(test.name) |
373 |
| - } |
374 |
| - if (testFullName == fullNameBuffer.joinToString("::")) return test |
375 |
| - for (child in test.children) { |
376 |
| - val result = find(child) |
377 |
| - if (result != null) return result |
378 |
| - } |
379 |
| - if (test !is TestProxyRoot) { |
380 |
| - fullNameBuffer.removeLast() |
381 |
| - } |
382 |
| - return null |
383 |
| - } |
384 |
| - |
385 |
| - return checkNotNull(find(root)) { "Could not find the test" } |
386 |
| - } |
387 | 346 | }
|
388 | 347 | }
|
0 commit comments