Skip to content

Commit

Permalink
Add the random shuffle setting for the backlog (false by default) (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
derwasp authored Sep 26, 2019
1 parent c3bab06 commit 3f7459f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/main/kotlin/albelli/junit/synnefo/api/Synnefo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ constructor(clazz: Class<*>) : ParentRunner<FeatureRunner>(clazz) {
runnerInfoList.add(SynnefoRunnerInfo(synnefoProperties, scenario, line))
}
}

if (opt.shuffleBacklogBeforeExecution)
runnerInfoList.shuffle()
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/main/kotlin/albelli/junit/synnefo/api/SynnefoOptions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ annotation class SynnefoOptions(
/**
* @return the name of the zipped artifacts file
*/
val outputFileName: String = "runResults.zip"
val outputFileName: String = "runResults.zip",
/**
* @return value indicating whether we should shuffle the backlog of tasks before scheduling them in CodeBuild
*/
val shuffleBacklogBeforeExecution: Boolean = false
)

@Retention(RetentionPolicy.RUNTIME)
@Target(AnnotationTarget.CLASS)
annotation class SynnefoOptionsGroup(vararg val value: SynnefoOptions)
14 changes: 12 additions & 2 deletions src/main/kotlin/albelli/junit/synnefo/runtime/SynnefoProperties.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@ import albelli.junit.synnefo.api.SynnefoOptions
import albelli.junit.synnefo.api.SynnefoRunLevel
import albelli.junit.synnefo.runtime.exceptions.SynnefoException
import cucumber.api.CucumberOptions
import software.amazon.awssdk.core.interceptor.Context
import java.net.URI

internal class SynnefoProperties(
val threads: Int ,
val threads: Int,
val runLevel: SynnefoRunLevel,
val reportTargetDir: String,
val cucumberOptions: CucumberOptions,
Expand All @@ -20,6 +21,7 @@ internal class SynnefoProperties(
val bucketOutputFolder: String,
val outputFileName: String,
val cucumberForcedTags: String,
val shuffleBacklogBeforeExecution: Boolean,
val classPath: String,
val featurePaths: List<URI>)
{
Expand All @@ -37,9 +39,10 @@ internal class SynnefoProperties(
getAnyVar("bucketOutputFolder", opt.bucketOutputFolder),
getAnyVar("outputFileName", opt.outputFileName),
opt.cucumberForcedTags,
getAnyVar("shuffleBacklogBeforeExecution", opt.shuffleBacklogBeforeExecution),
"",
listOf()
)
)

constructor(opt: SynnefoProperties, classPath: String, featurePaths: List<URI>): this(
opt.threads,
Expand All @@ -55,6 +58,7 @@ internal class SynnefoProperties(
opt.bucketOutputFolder,
opt.outputFileName,
opt.cucumberForcedTags,
opt.shuffleBacklogBeforeExecution,
classPath,
featurePaths
)
Expand Down Expand Up @@ -91,6 +95,12 @@ internal class SynnefoProperties(
return anyVar ?: default
}

private fun getAnyVar(varName: String, default: Boolean) : Boolean
{
val anyVar = getAnyVar(varName)
return anyVar?.toBoolean() ?: default
}

@Throws(SynnefoException::class)
private fun getAnyVarOrFail(varName: String, default: String) : String
{
Expand Down

0 comments on commit 3f7459f

Please sign in to comment.