Skip to content

Commit

Permalink
testShards = -1, shardTime = 119 broken (#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
Macarse authored Feb 8, 2019
1 parent 1ea9488 commit 1b52515
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test_runner/src/main/kotlin/ftl/shard/Shard.kt
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ object Shard {

val shardsByTime = Math.ceil(testsTotalTime / args.shardTime).toInt()

// If there is no limit, use the calculated amount
if (args.testShards == -1) {
return shardsByTime
}

// We need to respect the testShards
return Math.min(shardsByTime, args.testShards)
}
Expand Down
9 changes: 9 additions & 0 deletions test_runner/src/test/kotlin/ftl/shard/ShardTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,13 @@ class ShardTest {

assertThat(result).isEqualTo(2)
}

@Test
fun createShardsByShardTime_unlimitedShardsShouldReturnTheRightAmount() {
val testsToRun = listOf("a/a", "b/b", "c/c", "d/d", "e/e", "f/f", "g/g")
val suite = sample()
val result = Shard.shardCountByTime(testsToRun, suite, mockArgs(-1, 7))

assertThat(result).isEqualTo(3)
}
}

0 comments on commit 1b52515

Please sign in to comment.