Skip to content

Commit

Permalink
Add flag and code to fail a build if it tries to run a local test.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 678795882
Change-Id: I2f098aa6893f1657b3f9a15f60ab1de7db970229
  • Loading branch information
Googler authored and copybara-github committed Sep 25, 2024
1 parent ee3fa9d commit cd90ba7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,14 @@ public static class TestOptions extends FragmentOptions {
+ "If false, a test runner that does not support sharding will lead to all tests "
+ "running in each shard.")
public boolean checkShardingSupport;

@Option(
name = "allow_local_tests",
defaultValue = "true",
documentationCategory = OptionDocumentationCategory.UNDOCUMENTED,
effectTags = {OptionEffectTag.EXECUTION},
help = "If true, Bazel will allow local tests to run.")
public boolean allowLocalTests;
}

private final TestOptions options;
Expand Down Expand Up @@ -439,6 +447,10 @@ public boolean checkShardingSupport() {
return options.checkShardingSupport;
}

public boolean allowLocalTests() {
return options.allowLocalTests;
}

/**
* Option converter that han handle two styles of value for "--runs_per_test":
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ private static ImmutableSet<Artifact> nonNullAsSet(Artifact... artifacts) {
this.isExecutedOnWindows = isExecutedOnWindows;
}

public boolean allowLocalTests() {
return testConfiguration.allowLocalTests();
}

@Override
public boolean mayModifySpawnOutputsAfterExecution() {
// Test actions modify test spawn outputs after execution:
Expand Down

0 comments on commit cd90ba7

Please sign in to comment.