EA-371474 fixed bounds of sublist in isConsistedFrom function
authorSergei Vorobyov <sergey.vorobyov@jetbrains.com>
Fri, 24 Sep 2021 17:48:35 +0000 (20:48 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Mon, 27 Sep 2021 09:45:33 +0000 (09:45 +0000)
GitOrigin-RevId: dfba28a822eb30d9a6240c5e25fab3746f62c03e

plugins/gradle/java/src/execution/test/runner/AbstractGradleTestRunConfigurationProducer.kt
plugins/gradle/java/testSources/execution/test/runner/GradleTestRunConfigurationProducerTest.kt

index d6cd9d4c692f7e81f556753aaadded8a750eef0a..073507d8a93de36cda57cabad4e26b804e0a3223 100644 (file)
@@ -126,7 +126,7 @@ abstract class AbstractGradleTestRunConfigurationProducer<E : PsiElement, Ex : P
       val size = tile.size
       val index = indexOfSubList(reducer, tile)
       if (index >= 0) {
-        val subReducer = reducer.subList(index, size)
+        val subReducer = reducer.subList(index, index + size)
         subReducer.clear()
         subReducer.add(null)
       }
index 8b85a2747cab4f04cf0ed517c811e3998caedebc..d55e146b2d62d0ac24e483236281f8ddf43fc259 100644 (file)
@@ -326,4 +326,37 @@ class GradleTestRunConfigurationProducerTest : GradleTestRunConfigurationProduce
     assertConfigurationForTask("build --info -PmyKey=myVal -DmyKey=myVal", "build", projectElement)
     assertConfigurationForTask("test --debug -PmyKey=myVal -DmyKey=myVal", "test", projectElement)
   }
+
+  @Test
+  fun `test configurations are not from context`() {
+    val projectData = generateAndImportTemplateProject()
+    createAndAddRunConfiguration("""build :test --tests "TestCase"""").let { configuration ->
+      runReadActionAndWait {
+        val context = getContextByLocation(projectData["project"]["TestCase"].element)
+        val producer = getConfigurationProducer<TestClassGradleConfigurationProducer>()
+        assertFalse(producer.isConfigurationFromContext(configuration, context))
+      }
+    }
+    createAndAddRunConfiguration("""a b c d e f :test --tests "TestCase"""").let { configuration ->
+      runReadActionAndWait {
+        val context = getContextByLocation(projectData["project"]["TestCase"].element)
+        val producer = getConfigurationProducer<TestClassGradleConfigurationProducer>()
+        assertFalse(producer.isConfigurationFromContext(configuration, context))
+      }
+    }
+    createAndAddRunConfiguration("""build :test --tests "TestCase.test1"""").let { configuration ->
+      runReadActionAndWait {
+        val context = getContextByLocation(projectData["project"]["TestCase"]["test1"].element)
+        val producer = getConfigurationProducer<TestMethodGradleConfigurationProducer>()
+        assertFalse(producer.isConfigurationFromContext(configuration, context))
+      }
+    }
+    createAndAddRunConfiguration("""a b c d e f :test --tests "TestCase.test1"""").let { configuration ->
+      runReadActionAndWait {
+        val context = getContextByLocation(projectData["project"]["TestCase"]["test1"].element)
+        val producer = getConfigurationProducer<TestMethodGradleConfigurationProducer>()
+        assertFalse(producer.isConfigurationFromContext(configuration, context))
+      }
+    }
+  }
 }