From 15394d57ce1d9160366993c4a298590184134ee5 Mon Sep 17 00:00:00 2001 From: Evgeny Shepelyuk Date: Thu, 5 Sep 2019 10:39:39 +0300 Subject: [PATCH] fix: filter out missing simulations configured by static list --- .../gradle/gatling/GatlingRunTask.groovy | 6 ++++- .../groovy/unit/GatlingRunTaskTest.groovy | 24 ++++++++++++------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/main/groovy/com/github/lkishalmi/gradle/gatling/GatlingRunTask.groovy b/src/main/groovy/com/github/lkishalmi/gradle/gatling/GatlingRunTask.groovy index ce51461..10b3748 100644 --- a/src/main/groovy/com/github/lkishalmi/gradle/gatling/GatlingRunTask.groovy +++ b/src/main/groovy/com/github/lkishalmi/gradle/gatling/GatlingRunTask.groovy @@ -48,7 +48,11 @@ class GatlingRunTask extends DefaultTask { scalaDirs.find { simu.startsWith(it) }.relativize(simu).join(".") - ".scala" } } else if (simulationFilter != null && simulationFilter instanceof Iterable) { - retval = simulationFilter + def scalaDirs = project.sourceSets.gatling.scala.srcDirs + retval = simulationFilter.findAll { simuClz -> + def file = simuClz.replaceAll("\\.", "/") + scalaDirs.any { new File(it, "${file}.scala").exists() } + } } else { throw new IllegalArgumentException("`simulations` property neither Closure nor Iterable, simulations: $simulationFilter") } diff --git a/src/test/groovy/unit/GatlingRunTaskTest.groovy b/src/test/groovy/unit/GatlingRunTaskTest.groovy index 4e7dc95..600930a 100644 --- a/src/test/groovy/unit/GatlingRunTaskTest.groovy +++ b/src/test/groovy/unit/GatlingRunTaskTest.groovy @@ -86,9 +86,7 @@ class GatlingRunTaskTest extends GatlingUnitSpec { when: 'fake source dirs without simulations' project.sourceSets { - gatling { - scala.srcDirs = [overridenSrc] - } + gatling.scala.srcDirs = [overridenSrc] } then: gatlingRunTask.resolveSimulations().size() == 0 @@ -106,9 +104,7 @@ class GatlingRunTaskTest extends GatlingUnitSpec { when: 'fake source dirs without simulations' project.sourceSets { - gatling { - scala.srcDir overridenSrc - } + gatling.scala.srcDir overridenSrc } then: gatlingRunTask.resolveSimulations().size() == 2 @@ -126,10 +122,22 @@ class GatlingRunTaskTest extends GatlingUnitSpec { } def "should fail if extension static list is not in sourceSet"() { - + when: 'fake source dirs without simulations and static list' + project.sourceSets { + gatling.scala.srcDirs = ["test/gatling/scala"] + } + project.gatling { simulations = ["computerdatabase.BasicSimulation"] } + then: + gatlingRunTask.resolveSimulations().size() == 0 } def "should fail if gatlingRun static list is not in sourceSet"() { - + when: 'fake source dirs without simulations and static list' + project.sourceSets { + gatling.scala.srcDirs = ["test/gatling/scala"] + } + project.gatlingRun { simulations = ["computerdatabase.BasicSimulation"] } + then: + gatlingRunTask.resolveSimulations().size() == 0 } }