Skip to content

Commit

Permalink
Split up how default flags are added in AnalysisTestCases.
Browse files Browse the repository at this point in the history
Not all of these flags are needed for all tests; some tests may break WITH the
excess flags.

Progress on #6524.

PiperOrigin-RevId: 242658845
  • Loading branch information
mstaib authored and copybara-github committed Apr 9, 2019
1 parent e4aac3e commit 62f9d39
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,18 @@ public abstract class AnalysisTestCase extends FoundationTestCase {

/** All the flags that can be passed to {@link BuildView#update}. */
public enum Flag {
// The --keep_going flag.
KEEP_GOING,
// Configurations that only include the fragments a target needs to properly analyze.
TRIMMED_CONFIGURATIONS,
SKYFRAME_PREPARE_ANALYSIS
// The --skyframe_prepare_analysis flag.
SKYFRAME_PREPARE_ANALYSIS,
// Flags for visibility to default to public.
PUBLIC_VISIBILITY,
// Flags for CPU to work (be set to k8) in test mode.
CPU_K8,
// Flags from TestConstants.PRODUCT_SPECIFIC_FLAGS.
PRODUCT_SPECIFIC_FLAGS
}

/** Helper class to make it easy to enable and disable flags. */
Expand Down Expand Up @@ -280,8 +288,15 @@ public final void useConfiguration(String... args) throws Exception {
LoadingPhaseThreadsOption.class,
LoadingOptions.class),
ruleClassProvider.getConfigurationOptions()));
optionsParser.parse("--default_visibility=public", "--cpu=k8", "--host_cpu=k8");
optionsParser.parse(TestConstants.PRODUCT_SPECIFIC_FLAGS);
if (defaultFlags().contains(Flag.PUBLIC_VISIBILITY)) {
optionsParser.parse("--default_visibility=public");
}
if (defaultFlags().contains(Flag.CPU_K8)) {
optionsParser.parse("--cpu=k8", "--host_cpu=k8");
}
if (defaultFlags().contains(Flag.PRODUCT_SPECIFIC_FLAGS)) {
optionsParser.parse(TestConstants.PRODUCT_SPECIFIC_FLAGS);
}
optionsParser.parse(args);
if (defaultFlags().contains(Flag.TRIMMED_CONFIGURATIONS)) {
optionsParser.parse("--experimental_dynamic_configs=on");
Expand All @@ -291,7 +306,10 @@ public final void useConfiguration(String... args) throws Exception {
}

protected FlagBuilder defaultFlags() {
return new FlagBuilder();
return new FlagBuilder()
.with(Flag.PUBLIC_VISIBILITY)
.with(Flag.CPU_K8)
.with(Flag.PRODUCT_SPECIFIC_FLAGS);
}

protected Action getGeneratingAction(Artifact artifact) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2752,7 +2752,7 @@ public void aspectOnAspectAttrConflict() throws Exception {
public static final class WithKeepGoing extends SkylarkDefinedAspectsTest {
@Override
protected FlagBuilder defaultFlags() {
return new FlagBuilder().with(Flag.KEEP_GOING);
return super.defaultFlags().with(Flag.KEEP_GOING);
}

@Override
Expand Down

0 comments on commit 62f9d39

Please sign in to comment.