Skip to content
This repository has been archived by the owner on Sep 30, 2020. It is now read-only.

Commit

Permalink
fix: filter out missing simulations configured by static list
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Shepelyuk authored and eshepelyuk committed Sep 6, 2019
1 parent 1ebd283 commit 15394d5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ class GatlingRunTask extends DefaultTask {
scalaDirs.find { simu.startsWith(it) }.relativize(simu).join(".") - ".scala"
}
} else if (simulationFilter != null && simulationFilter instanceof Iterable<String>) {
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<String>, simulations: $simulationFilter")
}
Expand Down
24 changes: 16 additions & 8 deletions src/test/groovy/unit/GatlingRunTaskTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
}
}

0 comments on commit 15394d5

Please sign in to comment.