Skip to content

Commit

Permalink
Remove unused methods in BuildViewTestCase.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 596998663
Change-Id: I325408031d49402579d7ce627ce60da773112d76
  • Loading branch information
katre authored and copybara-github committed Jan 9, 2024
1 parent e8b0907 commit 02e394a
Showing 1 changed file with 0 additions and 147 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,8 @@
import com.google.devtools.build.lib.analysis.actions.SpawnAction;
import com.google.devtools.build.lib.analysis.config.BuildConfigurationValue;
import com.google.devtools.build.lib.analysis.config.BuildOptions;
import com.google.devtools.build.lib.analysis.config.BuildOptionsView;
import com.google.devtools.build.lib.analysis.config.FragmentOptions;
import com.google.devtools.build.lib.analysis.config.InvalidConfigurationException;
import com.google.devtools.build.lib.analysis.config.transitions.NoTransition;
import com.google.devtools.build.lib.analysis.config.transitions.NullTransition;
import com.google.devtools.build.lib.analysis.config.transitions.PatchTransition;
import com.google.devtools.build.lib.analysis.configuredtargets.FileConfiguredTarget;
import com.google.devtools.build.lib.analysis.configuredtargets.RuleConfiguredTarget;
import com.google.devtools.build.lib.analysis.extra.ExtraAction;
Expand All @@ -124,12 +120,10 @@
import com.google.devtools.build.lib.packages.AspectClass;
import com.google.devtools.build.lib.packages.AspectDescriptor;
import com.google.devtools.build.lib.packages.AspectParameters;
import com.google.devtools.build.lib.packages.AttributeMap;
import com.google.devtools.build.lib.packages.ConfiguredAttributeMapper;
import com.google.devtools.build.lib.packages.ImplicitOutputsFunction.SafeImplicitOutputsFunction;
import com.google.devtools.build.lib.packages.NoSuchPackageException;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
import com.google.devtools.build.lib.packages.OutputFile;
import com.google.devtools.build.lib.packages.PackageFactory;
import com.google.devtools.build.lib.packages.PackageOverheadEstimator;
import com.google.devtools.build.lib.packages.PackageValidator;
Expand Down Expand Up @@ -414,10 +408,6 @@ protected final ConfiguredRuleClassProvider getRuleClassProvider() {
return ruleClassProvider;
}

protected final PackageFactory getPackageFactory() {
return pkgFactory;
}

protected StarlarkSemantics getStarlarkSemantics() {
return buildLanguageOptions.toStarlarkSemantics();
}
Expand Down Expand Up @@ -777,11 +767,6 @@ protected RuleContext getRuleContext(ConfiguredTarget target) throws Exception {
return view.getRuleContextForTesting(reporter, target, new StubAnalysisEnvironment());
}

protected RuleContext getRuleContext(
ConfiguredTarget target, AnalysisEnvironment analysisEnvironment) throws Exception {
return view.getRuleContextForTesting(reporter, target, analysisEnvironment);
}

/**
* Creates and returns a rule context to use for Starlark tests that is equivalent to the one that
* was used to create the given configured target.
Expand Down Expand Up @@ -1380,42 +1365,6 @@ protected static ImmutableList<String> pathfragmentsToStrings(List<PathFragment>
return pathFragments.stream().map(PathFragment::toString).collect(toImmutableList());
}

/**
* Asserts that targetName's outputs are exactly expectedOuts.
*
* @param targetName The label of a rule.
* @param expectedOuts The labels of the expected outputs of the rule.
*/
protected void assertOuts(String targetName, String... expectedOuts) throws Exception {
Rule ruleTarget = (Rule) getTarget(targetName);
for (String expectedOut : expectedOuts) {
Target outTarget = getTarget(expectedOut);
if (!(outTarget instanceof OutputFile)) {
fail("Target " + outTarget + " is not an output");
assertThat(((OutputFile) outTarget).getGeneratingRule()).isSameInstanceAs(ruleTarget);
// This ensures that the output artifact is wired up in the action graph
getConfiguredTarget(expectedOut);
}
}

Collection<OutputFile> outs = ruleTarget.getOutputFiles();
assertWithMessage("Mismatched outputs: " + outs)
.that(outs.size())
.isEqualTo(expectedOuts.length);
}

/** Asserts that there exists a configured target file for the given label. */
protected void assertConfiguredTargetExists(String label) throws Exception {
assertThat(getFileConfiguredTarget(label)).isNotNull();
}

/** Assert that the first label and the second label are both generated by the same command. */
protected void assertSameGeneratingAction(String labelA, String labelB) throws Exception {
assertWithMessage("Action for " + labelA + " did not match " + labelB)
.that(getGeneratingActionForLabel(labelB))
.isSameInstanceAs(getGeneratingActionForLabel(labelA));
}

protected Artifact getSourceArtifact(PathFragment rootRelativePath, Root root) {
return view.getArtifactFactory().getSourceArtifact(rootRelativePath, root);
}
Expand Down Expand Up @@ -1688,18 +1637,6 @@ protected Action getGeneratingActionForLabel(String label) throws Exception {
return getGeneratingAction(getArtifact(label));
}

protected static String fileName(Artifact artifact) {
return artifact.getExecPathString();
}

protected static String fileName(FileConfiguredTarget target) {
return fileName(target.getArtifact());
}

protected String fileName(String name) throws Exception {
return fileName(getFileConfiguredTarget(name));
}

protected Path getOutputPath() {
return directories.getOutputPath(ruleClassProvider.getRunfilesPrefix());
}
Expand Down Expand Up @@ -1850,33 +1787,6 @@ protected ImmutableList<Action> getExtraActionActions(ConfiguredTarget target) {
return ImmutableList.copyOf(result);
}

/** Returns all extra actions for that target (including transitive actions). */
protected ImmutableList<ExtraAction> getTransitiveExtraActionActions(ConfiguredTarget target) {
ImmutableList.Builder<ExtraAction> result = new ImmutableList.Builder<>();
for (Artifact artifact :
target
.getProvider(ExtraActionArtifactsProvider.class)
.getTransitiveExtraActionArtifacts()
.toList()) {
Action action = getGeneratingAction(artifact);
if (action instanceof ExtraAction) {
result.add((ExtraAction) action);
}
}
return result.build();
}

protected ImmutableList<Action> getFilesToBuildActions(ConfiguredTarget target) {
List<Action> result = new ArrayList<>();
for (Artifact artifact : getFilesToBuild(target).toList()) {
Action action = getGeneratingAction(artifact);
if (action != null) {
result.add(action);
}
}
return ImmutableList.copyOf(result);
}

protected ImmutableList<Action> getActions(String label, Class<?> actionClass) throws Exception {
return ((RuleConfiguredTarget) getConfiguredTarget(label))
.getActions().stream()
Expand Down Expand Up @@ -1915,12 +1825,6 @@ protected static NestedSet<Artifact> getFilesToRun(TransitiveInfoCollection targ
return target.getProvider(FilesToRunProvider.class).getFilesToRun();
}

protected NestedSet<Artifact> getFilesToRun(Label label) {
return getConfiguredTarget(label, targetConfig)
.getProvider(FilesToRunProvider.class)
.getFilesToRun();
}

protected NestedSet<Artifact> getFilesToRun(String label) throws Exception {
return getConfiguredTarget(label).getProvider(FilesToRunProvider.class).getFilesToRun();
}
Expand Down Expand Up @@ -1949,30 +1853,6 @@ protected BuildConfigurationValue getExecConfiguration() {
return execConfig;
}

/**
* Returns the configuration created by applying the given transition to the source configuration.
*
* @throws AssertionError if the transition couldn't be evaluated
*/
protected BuildConfigurationValue getConfiguration(
BuildConfigurationValue fromConfig, PatchTransition transition) throws InterruptedException {
if (transition == NoTransition.INSTANCE) {
return fromConfig;
} else if (transition == NullTransition.INSTANCE) {
return null;
} else {
try {
return skyframeExecutor.getConfigurationForTesting(
reporter,
transition.patch(
new BuildOptionsView(fromConfig.getOptions(), transition.requiresOptionFragments()),
eventCollector));
} catch (InvalidConfigurationException e) {
throw new AssertionError(e);
}
}
}

private BuildConfigurationValue getConfiguration(String label) {
try {
return getConfiguration(getConfiguredTarget(label));
Expand All @@ -1981,32 +1861,10 @@ private BuildConfigurationValue getConfiguration(String label) {
}
}

protected final BuildConfigurationValue getConfiguration(BuildConfigurationKey configurationKey) {
return skyframeExecutor.getConfiguration(reporter, configurationKey);
}

protected final BuildConfigurationValue getConfiguration(ConfiguredTarget ct) {
return skyframeExecutor.getConfiguration(reporter, ct.getConfigurationKey());
}

/** Returns an attribute value retriever for the given rule for the target configuration. */
protected AttributeMap attributes(RuleConfiguredTarget ct) {
ConfiguredTargetAndData ctad;
try {
ctad = getConfiguredTargetAndData(ct.getLabel().toString());
} catch (LabelSyntaxException
| StarlarkTransition.TransitionException
| InvalidConfigurationException
| InterruptedException e) {
throw new RuntimeException(e);
}
return getMapperFromConfiguredTargetAndTarget(ctad);
}

protected AttributeMap attributes(ConfiguredTarget rule) {
return attributes((RuleConfiguredTarget) rule);
}

protected void useLoadingOptions(String... options) throws OptionsParsingException {
customLoadingOptions = Options.parse(LoadingOptions.class, options).getOptions();
}
Expand Down Expand Up @@ -2145,11 +2003,6 @@ protected static String getErrorMsgNonEmptyList(
"in %s attribute of %s rule %s: attribute must be non empty", attrName, ruleType, ruleName);
}

protected static String getErrorMsgMandatoryMissing(String attrName, String ruleType) {
return String.format(
"missing value for mandatory attribute '%s' in '%s' rule", attrName, ruleType);
}

protected static String getErrorMsgWrongAttributeValue(String value, String... expected) {
return String.format(
"has to be one of %s instead of '%s'",
Expand Down

0 comments on commit 02e394a

Please sign in to comment.