From 1b52515e751fe548d87c9cb7479fba441c0ba907 Mon Sep 17 00:00:00 2001 From: Carlos Sessa Date: Thu, 7 Feb 2019 21:36:07 -0600 Subject: [PATCH] testShards = -1, shardTime = 119 broken (#491) --- test_runner/src/main/kotlin/ftl/shard/Shard.kt | 5 +++++ test_runner/src/test/kotlin/ftl/shard/ShardTest.kt | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/test_runner/src/main/kotlin/ftl/shard/Shard.kt b/test_runner/src/main/kotlin/ftl/shard/Shard.kt index 78ed9a9f4b..f35b6652e3 100644 --- a/test_runner/src/main/kotlin/ftl/shard/Shard.kt +++ b/test_runner/src/main/kotlin/ftl/shard/Shard.kt @@ -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) } diff --git a/test_runner/src/test/kotlin/ftl/shard/ShardTest.kt b/test_runner/src/test/kotlin/ftl/shard/ShardTest.kt index 45dc25166e..b17d9f238d 100644 --- a/test_runner/src/test/kotlin/ftl/shard/ShardTest.kt +++ b/test_runner/src/test/kotlin/ftl/shard/ShardTest.kt @@ -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) + } }