Skip to content

Commit

Permalink
Make --test_sharding_strategy=forced=k have a deterministic options…
Browse files Browse the repository at this point in the history
… checksum.

`TestShardingStrategyForced` didn't implement `toString`, so an incremental build with `--test_sharding_strategy=forced=k` with no change to `k` was invalidating all test targets (or all configured targets if `--notrim_test_configuration`).

PiperOrigin-RevId: 718512597
Change-Id: I2dc174e02f5a072ea0378d87c30d26e55173b651
  • Loading branch information
justinhorvitz authored and copybara-github committed Jan 22, 2025
1 parent c38bed0 commit a0a2c25
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,9 @@ final class TestShardingStrategyForced implements TestShardingStrategy {
public int getNumberOfShards(int shardCountFromAttr) {
return forcedShardsCount;
}

@Override
public String toString() {
return "forced=" + forcedShardsCount;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,32 @@ public void testShardingForced() throws Exception {
assertSharded(getConfiguredTarget("//javatests/jt:RGT_many"), 5);
}

@Test
public void testShardingForced_equalValue_equalChecksum() throws Exception {
useConfiguration("--test_sharding_strategy=forced=5");
var config1 = getTargetConfiguration();

initializeSkyframeExecutor();

useConfiguration("--test_sharding_strategy=forced=5");
var config2 = getTargetConfiguration();

assertThat(config2).isEqualTo(config1);
}

@Test
public void testShardingForced_differentValue_differentChecksum() throws Exception {
useConfiguration("--test_sharding_strategy=forced=5");
var config1 = getTargetConfiguration();

initializeSkyframeExecutor();

useConfiguration("--test_sharding_strategy=forced=6");
var config2 = getTargetConfiguration();

assertThat(config2).isNotEqualTo(config1);
}

@Test
public void testFlakyAttributeValidation() throws Exception {
scratch.file(
Expand Down

0 comments on commit a0a2c25

Please sign in to comment.