Permalink
Browse files

Merge session/EL refactoring

  • Loading branch information...
2 parents 78104ae + 48b24f1 commit 7f79cc08277dee78e4cc0fd6334a244e5dc34120 Stephane Landelle committed Dec 22, 2012
Showing with 1,500 additions and 1,396 deletions.
  1. +142 −141 gatling-app/src/main/scala/com/excilys/ebi/gatling/app/Gatling.scala
  2. +167 −164 gatling-app/src/test/scala/com/excilys/ebi/gatling/app/test/CompileTest.scala
  3. +1 −1 ...ng-bundle/src/main/assembly/assembly-structure/user-files/simulations/advanced/SomeScenario.scala
  4. +1 −1 gatling-charts/src/main/scala/com/excilys/ebi/gatling/charts/report/GlobalReportGenerator.scala
  5. +1 −1 ...g-charts/src/main/scala/com/excilys/ebi/gatling/charts/report/RequestDetailsReportGenerator.scala
  6. +1 −1 gatling-charts/src/main/scala/com/excilys/ebi/gatling/charts/report/StatsReportGenerator.scala
  7. +7 −8 gatling-charts/src/main/scala/com/excilys/ebi/gatling/charts/result/reader/FileDataReader.scala
  8. +5 −3 gatling-charts/src/main/scala/com/excilys/ebi/gatling/charts/result/reader/Records.scala
  9. +1 −1 ...rts/src/main/scala/com/excilys/ebi/gatling/charts/result/reader/buffers/GeneralStatsBuffers.scala
  10. +1 −1 ...ts/src/main/scala/com/excilys/ebi/gatling/charts/result/reader/buffers/LatencyPerSecBuffers.scala
  11. +1 −1 ...s/src/main/scala/com/excilys/ebi/gatling/charts/result/reader/buffers/RequestsPerSecBuffers.scala
  12. +1 −1 ...c/main/scala/com/excilys/ebi/gatling/charts/result/reader/buffers/ResponseTimePerSecBuffers.scala
  13. +2 −1 ...rc/main/scala/com/excilys/ebi/gatling/charts/result/reader/buffers/ResponseTimeRangeBuffers.scala
  14. +1 −1 ...c/main/scala/com/excilys/ebi/gatling/charts/result/reader/buffers/TransactionsPerSecBuffers.scala
  15. +2 −2 gatling-charts/src/main/scala/com/excilys/ebi/gatling/charts/result/reader/buffers/package.scala
  16. +4 −0 gatling-core/pom.xml
  17. +20 −9 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/Predef.scala
  18. +6 −7 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/action/GroupAction.scala
  19. +4 −6 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/action/TryMaxAction.scala
  20. +19 −13 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/action/WhileAction.scala
  21. +4 −4 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/action/builder/GroupActionBuilder.scala
  22. +3 −5 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/action/builder/WhileActionBuilder.scala
  23. +14 −25 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/check/Check.scala
  24. +48 −37 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/check/CheckBuilder.scala
  25. +0 −24 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/check/CheckResult.scala
  26. +6 −3 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/check/package.scala
  27. +1 −1 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/result/message/DataWriterMessage.scala
  28. +3 −7 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/result/message/RequestStatus.scala
  29. +1 −1 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/result/reader/ChartRequestRecord.scala
  30. +2 −2 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/result/reader/DataReader.scala
  31. +2 −4 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/result/writer/ConsoleDataWriter.scala
  32. +1 −1 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/result/writer/DataWriter.scala
  33. +0 −83 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/session/ELParser.scala
  34. +104 −0 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/session/Expression.scala
  35. +51 −79 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/session/Session.scala
  36. +12 −12 ...ore/src/main/scala/com/excilys/ebi/gatling/core/session/handler/CounterBasedterationHandler.scala
  37. +8 −8 ...core/src/main/scala/com/excilys/ebi/gatling/core/session/handler/TimerBasedIterationHandler.scala
  38. +9 −4 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/session/package.scala
  39. +1 −1 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/structure/Assertions.scala
  40. +3 −3 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/structure/ConditionalStatements.scala
  41. +1 −1 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/structure/Feeds.scala
  42. +2 −2 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/structure/Groups.scala
  43. +29 −15 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/structure/Loops.scala
  44. +1 −1 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/structure/package.scala
  45. +0 −2 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/util/StringHelper.scala
  46. +43 −0 gatling-core/src/main/scala/com/excilys/ebi/gatling/core/util/TypeHelper.scala
  47. +0 −1 gatling-core/src/test/scala/com/excilys/ebi/gatling/core/result/message/RequestRecordSpec.scala
  48. +5 −6 gatling-core/src/test/scala/com/excilys/ebi/gatling/core/result/writer/FileDataWriterSpec.scala
  49. +67 −31 gatling-core/src/test/scala/com/excilys/ebi/gatling/core/session/ELParserSpec.scala
  50. +9 −9 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/Predef.scala
  51. +27 −18 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/action/HttpRequestAction.scala
  52. +7 −4 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/action/HttpRequestActionBuilder.scala
  53. +5 −6 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/ahc/GatlingAsyncHandlerActor.scala
  54. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/cache/CacheHandling.scala
  55. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/check/HttpCheck.scala
  56. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/check/HttpExtractorCheckBuilder.scala
  57. +3 −3 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/check/HttpMultipleCheckBuilder.scala
  58. +4 −4 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/check/HttpSingleCheckBuilder.scala
  59. +2 −2 ...tp/src/main/scala/com/excilys/ebi/gatling/http/check/after/HttpBodyResponseTimeCheckBuilder.scala
  60. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/check/body/HttpBodyCssCheckBuilder.scala
  61. +2 −2 ...ng-http/src/main/scala/com/excilys/ebi/gatling/http/check/body/HttpBodyJsonPathCheckBuilder.scala
  62. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/check/body/HttpBodyRegexCheckBuilder.scala
  63. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/check/body/HttpBodyStringCheckBuilder.scala
  64. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/check/body/HttpBodyXPathCheckBuilder.scala
  65. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/check/bodypart/ChecksumCheck.scala
  66. +2 −2 ...ng-http/src/main/scala/com/excilys/ebi/gatling/http/check/bodypart/HttpChecksumCheckBuilder.scala
  67. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/check/header/HttpHeaderCheckBuilder.scala
  68. +8 −3 ...g-http/src/main/scala/com/excilys/ebi/gatling/http/check/header/HttpHeaderRegexCheckBuilder.scala
  69. +2 −2 ...g-http/src/main/scala/com/excilys/ebi/gatling/http/check/status/CurrentLocationCheckBuilder.scala
  70. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/check/status/HttpStatusCheckBuilder.scala
  71. +7 −8 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/cookie/CookieHandling.scala
  72. +2 −3 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/referer/RefererHandling.scala
  73. +3 −3 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/request/HttpRequestBody.scala
  74. +80 −103 ...http/src/main/scala/com/excilys/ebi/gatling/http/request/builder/AbstractHttpRequestBuilder.scala
  75. +50 −53 ...la/com/excilys/ebi/gatling/http/request/builder/AbstractHttpRequestWithBodyAndParamsBuilder.scala
  76. +48 −47 .../main/scala/com/excilys/ebi/gatling/http/request/builder/AbstractHttpRequestWithBodyBuilder.scala
  77. +2 −2 ...g-http/src/main/scala/com/excilys/ebi/gatling/http/request/builder/DeleteHttpRequestBuilder.scala
  78. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/request/builder/GetHttpRequestBuilder.scala
  79. +2 −2 ...ing-http/src/main/scala/com/excilys/ebi/gatling/http/request/builder/HeadHttpRequestBuilder.scala
  80. +13 −14 ...ing-http/src/main/scala/com/excilys/ebi/gatling/http/request/builder/HttpRequestBaseBuilder.scala
  81. +2 −2 ...ing-http/src/main/scala/com/excilys/ebi/gatling/http/request/builder/PostHttpRequestBuilder.scala
  82. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/request/builder/PutHttpRequestBuilder.scala
  83. +16 −13 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/request/builder/UploadedFile.scala
  84. +2 −2 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/request/builder/package.scala
  85. +26 −8 gatling-http/src/main/scala/com/excilys/ebi/gatling/http/util/HttpHelper.scala
  86. +11 −9 gatling-maven-plugin/src/main/java/com/excilys/ebi/gatling/mojo/GatlingMojo.java
  87. +1 −1 gatling-metrics/src/main/scala/com/excilys/ebi/gatling/metrics/types/RequestMetrics.scala
  88. +2 −0 gatling-recorder/src/main/resources/templates/simulation.ssp
  89. +324 −321 gatling-recorder/src/main/scala/com/excilys/ebi/gatling/recorder/ui/frame/ConfigurationFrame.scala
  90. +6 −0 pom.xml
@@ -22,6 +22,7 @@ import com.excilys.ebi.gatling.app.CommandLineConstants._
import com.excilys.ebi.gatling.charts.report.ReportsGenerator
import com.excilys.ebi.gatling.core.config.{ GatlingFiles, GatlingPropertiesBuilder }
import com.excilys.ebi.gatling.core.config.GatlingConfiguration
+import com.excilys.ebi.gatling.core.config.GatlingConfiguration.configuration
import com.excilys.ebi.gatling.core.result.reader.DataReader
import com.excilys.ebi.gatling.core.runner.{ Runner, Selection }
import com.excilys.ebi.gatling.core.scenario.configuration.Simulation
@@ -36,150 +37,150 @@ import scopt.OptionParser
*/
object Gatling extends Logging {
- val SUCCESS = 0
- val INCORRECT_ARGUMENTS = 1
- val SIMULATION_CHECK_FAILED = 2
-
- /**
- * Entry point of Application
- *
- * @param args Arguments of the main method
- */
- def main(args: Array[String]) {
- sys.exit(runGatling(args))
- }
-
- def fromMap(props: JMap[String, Any]) = {
- GatlingConfiguration.setUp(props)
- new Gatling().start
- }
-
- def runGatling(args: Array[String]) = {
- val props = new GatlingPropertiesBuilder
-
- val cliOptsParser = new OptionParser("gatling") {
- opt(CLI_NO_REPORTS, CLI_NO_REPORTS_ALIAS, "Runs simulation but does not generate reports", { props.noReports })
- opt(CLI_REPORTS_ONLY, CLI_REPORTS_ONLY_ALIAS, "<directoryName>", "Generates the reports for the simulation in <directoryName>", { v: String => props.reportsOnly(v) })
- opt(CLI_DATA_FOLDER, CLI_DATA_FOLDER_ALIAS, "<directoryPath>", "Uses <directoryPath> as the absolute path of the directory where feeders are stored", { v: String => props.dataDirectory(v) })
- opt(CLI_RESULTS_FOLDER, CLI_RESULTS_FOLDER_ALIAS, "<directoryPath>", "Uses <directoryPath> as the absolute path of the directory where results are stored", { v: String => props.resultsDirectory(v) })
- opt(CLI_REQUEST_BODIES_FOLDER, CLI_REQUEST_BODIES_FOLDER_ALIAS, "<directoryPath>", "Uses <directoryPath> as the absolute path of the directory where request bodies are stored", { v: String => props.requestBodiesDirectory(v) })
- opt(CLI_SIMULATIONS_FOLDER, CLI_SIMULATIONS_FOLDER_ALIAS, "<directoryPath>", "Uses <directoryPath> to discover simulations that could be run", { v: String => props.sourcesDirectory(v) })
- opt(CLI_SIMULATIONS_BINARIES_FOLDER, CLI_SIMULATIONS_BINARIES_FOLDER_ALIAS, "<directoryPath>", "Uses <directoryPath> to discover already compiled simulations", { v: String => props.binariesDirectory(v) })
- opt(CLI_SIMULATION, CLI_SIMULATION_ALIAS, "<className>", "Runs <className> simulation", { v: String => props.clazz(v) })
- opt(CLI_OUTPUT_DIRECTORY_BASE_NAME, CLI_OUTPUT_DIRECTORY_BASE_NAME_ALIAS, "<name>", "Use <name> for the base name of the output directory", { v: String => props.outputDirectoryBaseName(v) })
- }
-
- // if arguments are incorrect, usage message is displayed
- if (cliOptsParser.parse(args)) fromMap(props.build)
- else INCORRECT_ARGUMENTS
- }
+ val SUCCESS = 0
+ val INCORRECT_ARGUMENTS = 1
+ val SIMULATION_CHECK_FAILED = 2
+
+ /**
+ * Entry point of Application
+ *
+ * @param args Arguments of the main method
+ */
+ def main(args: Array[String]) {
+ sys.exit(runGatling(args))
+ }
+
+ def fromMap(props: JMap[String, Any]) = {
+ GatlingConfiguration.setUp(props)
+ new Gatling().start
+ }
+
+ def runGatling(args: Array[String]) = {
+ val props = new GatlingPropertiesBuilder
+
+ val cliOptsParser = new OptionParser("gatling") {
+ opt(CLI_NO_REPORTS, CLI_NO_REPORTS_ALIAS, "Runs simulation but does not generate reports", { props.noReports })
+ opt(CLI_REPORTS_ONLY, CLI_REPORTS_ONLY_ALIAS, "<directoryName>", "Generates the reports for the simulation in <directoryName>", { v: String => props.reportsOnly(v) })
+ opt(CLI_DATA_FOLDER, CLI_DATA_FOLDER_ALIAS, "<directoryPath>", "Uses <directoryPath> as the absolute path of the directory where feeders are stored", { v: String => props.dataDirectory(v) })
+ opt(CLI_RESULTS_FOLDER, CLI_RESULTS_FOLDER_ALIAS, "<directoryPath>", "Uses <directoryPath> as the absolute path of the directory where results are stored", { v: String => props.resultsDirectory(v) })
+ opt(CLI_REQUEST_BODIES_FOLDER, CLI_REQUEST_BODIES_FOLDER_ALIAS, "<directoryPath>", "Uses <directoryPath> as the absolute path of the directory where request bodies are stored", { v: String => props.requestBodiesDirectory(v) })
+ opt(CLI_SIMULATIONS_FOLDER, CLI_SIMULATIONS_FOLDER_ALIAS, "<directoryPath>", "Uses <directoryPath> to discover simulations that could be run", { v: String => props.sourcesDirectory(v) })
+ opt(CLI_SIMULATIONS_BINARIES_FOLDER, CLI_SIMULATIONS_BINARIES_FOLDER_ALIAS, "<directoryPath>", "Uses <directoryPath> to discover already compiled simulations", { v: String => props.binariesDirectory(v) })
+ opt(CLI_SIMULATION, CLI_SIMULATION_ALIAS, "<className>", "Runs <className> simulation", { v: String => props.clazz(v) })
+ opt(CLI_OUTPUT_DIRECTORY_BASE_NAME, CLI_OUTPUT_DIRECTORY_BASE_NAME_ALIAS, "<name>", "Use <name> for the base name of the output directory", { v: String => props.outputDirectoryBaseName(v) })
+ }
+
+ // if arguments are incorrect, usage message is displayed
+ if (cliOptsParser.parse(args)) fromMap(props.build)
+ else INCORRECT_ARGUMENTS
+ }
}
class Gatling extends Logging {
- import GatlingConfiguration.configuration
-
- private def defaultOutputDirectoryBaseName(clazz: Class[Simulation]) = configuration.simulation.outputDirectoryBaseName.getOrElse(formatToFilename(clazz.getSimpleName))
-
- def start = {
- val (outputDirectoryName, simulation) = GatlingFiles.reportsOnlyDirectory.map((_, None))
- .getOrElse {
- val simulations = GatlingFiles.binariesDirectory
- .map(SimulationClassLoader.fromClasspathBinariesDirectory) // expect simulations to have been pre-compiled (ex: IDE)
- .getOrElse(SimulationClassLoader.fromSourcesDirectory(GatlingFiles.sourcesDirectory))
- .simulationClasses(configuration.simulation.clazz)
- .sortWith(_.getName < _.getName)
-
- val selection = configuration.simulation.clazz.map { _ =>
- val simulation = simulations.head
- val outputDirectoryBaseName = defaultOutputDirectoryBaseName(simulation)
- new Selection(simulation, outputDirectoryBaseName, outputDirectoryBaseName)
- }.getOrElse(interactiveSelect(simulations))
-
- val (runId, simulation) = new Runner(selection).run
- (runId, Some(simulation))
- }
-
- val dataReader = DataReader.newInstance(outputDirectoryName)
-
- val result = simulation match {
- case Some(simulation) => if (checkSimulation(simulation, dataReader)) Gatling.SUCCESS else Gatling.SIMULATION_CHECK_FAILED
- case None => Gatling.SUCCESS
- }
-
- if (!configuration.charting.noReports) generateReports(outputDirectoryName, dataReader)
-
- result
- }
-
- private def interactiveSelect(simulations: List[Class[Simulation]]): Selection = {
-
- val simulation = selectSimulationClass(simulations)
-
- val myDefaultOutputDirectoryBaseName = defaultOutputDirectoryBaseName(simulation)
-
- println("Select simulation id (default is '" + myDefaultOutputDirectoryBaseName + "'). Accepted characters are a-z, A-Z, 0-9, - and _")
- val simulationId = {
- val userInput = Console.readLine.trim
-
- require(userInput.matches("[\\w-_]*"), userInput + " contains illegal characters")
-
- if (!userInput.isEmpty) userInput else myDefaultOutputDirectoryBaseName
- }
-
- println("Select run description (optional)")
- val runDescription = Console.readLine.trim
-
- new Selection(simulation, simulationId, runDescription)
- }
-
- private def selectSimulationClass(simulations: List[Class[Simulation]]): Class[Simulation] = {
-
- val selection = simulations.size match {
- case 0 =>
- // If there is no simulation file
- println("There is no simulation script. Please check that your scripts are in user-files/simulations")
- sys.exit
- case 1 =>
- info(simulations.head.getName + " is the only simulation, executing it.")
- 0
- case size =>
- println("Choose a simulation number:")
- for ((simulation, index) <- simulations.zipWithIndex) {
- println(" [" + index + "] " + simulation.getName)
- }
- Console.readInt
- }
-
- val validRange = 0 until simulations.size
- if (validRange contains selection)
- simulations(selection)
- else {
- println("Invalid selection, must be in " + validRange)
- selectSimulationClass(simulations)
- }
- }
-
- /**
- * This method call the statistics module to generate the charts and statistics
- *
- * @param outputDirectoryName The directory from which the simulation.log will be parsed
- */
- private def generateReports(outputDirectoryName: String, dataReader: DataReader) {
- println("Generating reports...")
- val start = currentTimeMillis
- val indexFile = ReportsGenerator.generateFor(outputDirectoryName, dataReader)
- println("Reports generated in " + (currentTimeMillis - start) / 1000 + "s.")
- println("Please open the following file : " + indexFile)
- }
-
- private def checkSimulation(simulation: Simulation, dataReader: DataReader) = {
- val successful = Assertion.assertThat(simulation.assertions, dataReader)
-
- if (successful) println("Simulation successful.")
- else println("Simulation failed.")
-
- successful
- }
+ import GatlingConfiguration.configuration
+
+ private def defaultOutputDirectoryBaseName(clazz: Class[Simulation]) = configuration.simulation.outputDirectoryBaseName.getOrElse(formatToFilename(clazz.getSimpleName))
+
+ def start = {
+ val (outputDirectoryName, simulation) = GatlingFiles.reportsOnlyDirectory.map((_, None))
+ .getOrElse {
+ val simulations = GatlingFiles.binariesDirectory
+ .map(SimulationClassLoader.fromClasspathBinariesDirectory) // expect simulations to have been pre-compiled (ex: IDE)
+ .getOrElse(SimulationClassLoader.fromSourcesDirectory(GatlingFiles.sourcesDirectory))
+ .simulationClasses(configuration.simulation.clazz)
+ .sortWith(_.getName < _.getName)
+
+ val selection = configuration.simulation.clazz.map { _ =>
+ val simulation = simulations.head
+ val outputDirectoryBaseName = defaultOutputDirectoryBaseName(simulation)
+ new Selection(simulation, outputDirectoryBaseName, outputDirectoryBaseName)
+ }.getOrElse(interactiveSelect(simulations))
+
+ val (runId, simulation) = new Runner(selection).run
+ (runId, Some(simulation))
+ }
+
+ val dataReader = DataReader.newInstance(outputDirectoryName)
+
+ val result = simulation match {
+ case Some(simulation) => if (checkSimulation(simulation, dataReader)) Gatling.SUCCESS else Gatling.SIMULATION_CHECK_FAILED
+ case None => Gatling.SUCCESS
+ }
+
+ if (!configuration.charting.noReports) generateReports(outputDirectoryName, dataReader)
+
+ result
+ }
+
+ private def interactiveSelect(simulations: List[Class[Simulation]]): Selection = {
+
+ val simulation = selectSimulationClass(simulations)
+
+ val myDefaultOutputDirectoryBaseName = defaultOutputDirectoryBaseName(simulation)
+
+ println("Select simulation id (default is '" + myDefaultOutputDirectoryBaseName + "'). Accepted characters are a-z, A-Z, 0-9, - and _")
+ val simulationId = {
+ val userInput = Console.readLine.trim
+
+ require(userInput.matches("[\\w-_]*"), userInput + " contains illegal characters")
+
+ if (!userInput.isEmpty) userInput else myDefaultOutputDirectoryBaseName
+ }
+
+ println("Select run description (optional)")
+ val runDescription = Console.readLine.trim
+
+ new Selection(simulation, simulationId, runDescription)
+ }
+
+ private def selectSimulationClass(simulations: List[Class[Simulation]]): Class[Simulation] = {
+
+ val selection = simulations.size match {
+ case 0 =>
+ // If there is no simulation file
+ println("There is no simulation script. Please check that your scripts are in user-files/simulations")
+ sys.exit
+ case 1 =>
+ info(simulations.head.getName + " is the only simulation, executing it.")
+ 0
+ case size =>
+ println("Choose a simulation number:")
+ for ((simulation, index) <- simulations.zipWithIndex) {
+ println(" [" + index + "] " + simulation.getName)
+ }
+ Console.readInt
+ }
+
+ val validRange = 0 until simulations.size
+ if (validRange contains selection)
+ simulations(selection)
+ else {
+ println("Invalid selection, must be in " + validRange)
+ selectSimulationClass(simulations)
+ }
+ }
+
+ /**
+ * This method call the statistics module to generate the charts and statistics
+ *
+ * @param outputDirectoryName The directory from which the simulation.log will be parsed
+ */
+ private def generateReports(outputDirectoryName: String, dataReader: DataReader) {
+ println("Generating reports...")
+ val start = currentTimeMillis
+ val indexFile = ReportsGenerator.generateFor(outputDirectoryName, dataReader)
+ println("Reports generated in " + (currentTimeMillis - start) / 1000 + "s.")
+ println("Please open the following file : " + indexFile)
+ }
+
+ private def checkSimulation(simulation: Simulation, dataReader: DataReader) = {
+ val successful = Assertion.assertThat(simulation.assertions, dataReader)
+
+ if (successful) println("Simulation successful.")
+ else println("Simulation failed.")
+
+ successful
+ }
}
Oops, something went wrong.

0 comments on commit 7f79cc0

Please sign in to comment.