Skip to content

Commit

Permalink
Automated rollback of commit 4607ad4.
Browse files Browse the repository at this point in the history
*** Reason for rollback ***

[]

*** Original change description ***

Automated rollback of commit 76b42af.

*** Reason for rollback ***

The internal tests were fixed.

*** Original change description ***

Automated rollback of commit 750f0a1.

*** Reason for rollback ***

This CL breaks internal tests.

*** Original change description ***

Fix `_validation` output group merging

While cd72583 made it so that a rul...

***

PiperOrigin-RevId: 678831804
Change-Id: I7725ff31af4c184c79162249283018d808b6b41e
  • Loading branch information
Googler authored and keertk committed Oct 2, 2024
1 parent f4d92d4 commit bb3f329
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 57 deletions.
1 change: 0 additions & 1 deletion src/main/java/com/google/devtools/build/lib/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,6 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster",
"//src/main/java/com/google/devtools/build/lib/analysis:analysis_options",
"//src/main/java/com/google/devtools/build/lib/analysis:analysis_phase_complete_event",
"//src/main/java/com/google/devtools/build/lib/analysis:aspect_collection",
"//src/main/java/com/google/devtools/build/lib/analysis:blaze_directories",
"//src/main/java/com/google/devtools/build/lib/analysis:blaze_version_info",
"//src/main/java/com/google/devtools/build/lib/analysis:build_info_event",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,6 @@
*/
@Immutable
public final class AspectCollection {
/** The name of the native aspect that collects validation outputs. */
public static final String VALIDATION_ASPECT_NAME = "ValidateTarget";

/** aspects that should be visible to a dependency */
private final ImmutableSet<AspectDeps> usedAspects;

Expand Down Expand Up @@ -286,14 +283,11 @@ public static AspectCollection create(Iterable<Aspect> aspectPath)
ImmutableList.copyOf(aspectMap.entrySet()).reverse()) {
for (AspectDescriptor depAspectDescriptor : deps.keySet()) {
Aspect depAspect = aspectMap.get(depAspectDescriptor);
// As any aspect can add validation outputs, the special validation aspect that collects
// their outputs has to depend on all aspects.
if (depAspect
.getDefinition()
.getRequiredProvidersForAspects()
.isSatisfiedBy(aspect.getValue().getDefinition().getAdvertisedProviders())
|| depAspect.getDefinition().requires(aspect.getValue())
|| depAspect.getAspectClass().getName().equals(VALIDATION_ASPECT_NAME)) {
|| depAspect.getDefinition().requires(aspect.getValue())) {
deps.get(depAspectDescriptor).add(aspect.getKey());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,6 @@ public static OutputGroupInfo merge(List<OutputGroupInfo> providers) throws Merg
"Output group " + VALIDATION + " provided twice with incompatible depset orders");
}
}
if (!validationOutputs.isEmpty()) {
outputGroups.put(VALIDATION, validationOutputs.build());
}
return createInternal(ImmutableMap.copyOf(outputGroups));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.devtools.build.lib.analysis.AnalysisOptions;
import com.google.devtools.build.lib.analysis.AspectCollection;
import com.google.devtools.build.lib.analysis.OutputGroupInfo;
import com.google.devtools.build.lib.analysis.TopLevelArtifactContext;
import com.google.devtools.build.lib.analysis.ViewCreationFailedException;
Expand Down Expand Up @@ -58,6 +57,7 @@
* as --keep_going, --jobs, etc.
*/
public class BuildRequest implements OptionsProvider {
public static final String VALIDATION_ASPECT_NAME = "ValidateTarget";

private static final ImmutableList<Class<? extends OptionsBase>> MANDATORY_OPTIONS =
ImmutableList.of(
Expand Down Expand Up @@ -429,8 +429,8 @@ public TopLevelArtifactContext getTopLevelArtifactContext() {
public ImmutableList<String> getAspects() {
List<String> aspects = getBuildOptions().aspects;
ImmutableList.Builder<String> result = ImmutableList.<String>builder().addAll(aspects);
if (!aspects.contains(AspectCollection.VALIDATION_ASPECT_NAME) && useValidationAspect()) {
result.add(AspectCollection.VALIDATION_ASPECT_NAME);
if (!aspects.contains(VALIDATION_ASPECT_NAME) && useValidationAspect()) {
result.add(VALIDATION_ASPECT_NAME);
}
return result.build();
}
Expand All @@ -453,7 +453,7 @@ public ImmutableMap<String, String> getAspectsParameters() throws ViewCreationFa
}
}

/** Whether {@value AspectCollection#VALIDATION_ASPECT_NAME} is in use. */
/** Whether {@value #VALIDATION_ASPECT_NAME} is in use. */
public boolean useValidationAspect() {
return validationMode() == OutputGroupInfo.ValidationMode.ASPECT;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.actions.Artifact;
import com.google.devtools.build.lib.analysis.AspectCollection;
import com.google.devtools.build.lib.analysis.ConfiguredAspect;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.FileProvider;
Expand Down Expand Up @@ -390,7 +389,7 @@ private static PartitionedAspectKeys partitionAspectKeys(
var aspectsToPrintBuilder = ImmutableSet.<AspectKey>builder();
var validationAspectsBuilder = ImmutableList.<AspectKey>builder();
for (AspectKey key : keys) {
if (Objects.equals(key.getAspectClass().getName(), AspectCollection.VALIDATION_ASPECT_NAME)) {
if (Objects.equals(key.getAspectClass().getName(), BuildRequest.VALIDATION_ASPECT_NAME)) {
validationAspectsBuilder.add(key);
} else {
aspectsToPrintBuilder.add(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/actions:commandline_item",
"//src/main/java/com/google/devtools/build/lib/analysis:analysis_cluster",
"//src/main/java/com/google/devtools/build/lib/analysis:analysis_options",
"//src/main/java/com/google/devtools/build/lib/analysis:aspect_collection",
"//src/main/java/com/google/devtools/build/lib/analysis:blaze_version_info",
"//src/main/java/com/google/devtools/build/lib/analysis:config/build_configuration",
"//src/main/java/com/google/devtools/build/lib/analysis:config/build_options",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.devtools.build.lib.analysis.AspectCollection;
import com.google.devtools.build.lib.analysis.ConfiguredTarget;
import com.google.devtools.build.lib.analysis.config.CoreOptions;
import com.google.devtools.build.lib.buildtool.BuildRequest;
Expand Down Expand Up @@ -244,7 +243,7 @@ private static DetailedExitCode analyzeTestResults(
if (buildRequest.useValidationAspect()) {
validatedTargets =
buildResult.getSuccessfulAspects().stream()
.filter(key -> AspectCollection.VALIDATION_ASPECT_NAME.equals(key.getAspectName()))
.filter(key -> BuildRequest.VALIDATION_ASPECT_NAME.equals(key.getAspectName()))
.map(AspectKey::getBaseConfiguredTargetKey)
.collect(ImmutableSet.toImmutableSet());
} else {
Expand Down
40 changes: 3 additions & 37 deletions src/test/shell/integration/validation_actions_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,9 @@ function test_validation_actions_flags() {
expect_log "Target //validation_actions:foo0 up-to-date:"
}

function setup_validation_tool_aspect() {
function test_validation_actions_in_rule_and_aspect() {
setup_test_project

mkdir -p aspect
cat > aspect/BUILD <<'EOF'
exports_files(["aspect_validation_tool"])
Expand Down Expand Up @@ -546,45 +548,10 @@ EOF
echo "aspect validation output" > $1
EOF
chmod +x aspect/aspect_validation_tool
}

function test_validation_actions_in_rule_and_aspect_no_use_validation_aspect() {
setup_test_project
setup_validation_tool_aspect
setup_passing_validation_action

bazel build --run_validations --aspects=//aspect:def.bzl%validation_aspect \
--noexperimental_use_validation_aspect \
//validation_actions:foo0 >& "$TEST_log" || fail "Expected build to succeed"
expect_log "Target //validation_actions:foo0 up-to-date:"
expect_log "validation_actions/foo0.main"
assert_exists bazel-bin/validation_actions/foo0.validation
assert_exists bazel-bin/validation_actions/foo0.aspect_validation

cat > aspect/aspect_validation_tool <<'EOF'
#!/bin/bash
echo "aspect validation failed!"
exit 1
EOF

bazel build --run_validations --aspects=//aspect:def.bzl%validation_aspect \
--noexperimental_use_validation_aspect \
//validation_actions:foo0 >& "$TEST_log" && fail "Expected build to fail"
expect_log "aspect validation failed!"
}

function test_validation_actions_in_rule_and_aspect_use_validation_aspect() {
setup_test_project
setup_validation_tool_aspect
setup_passing_validation_action

bazel build --run_validations --aspects=//aspect:def.bzl%validation_aspect \
--experimental_use_validation_aspect \
//validation_actions:foo0 >& "$TEST_log" || fail "Expected build to succeed"
expect_log "Target //validation_actions:foo0 up-to-date:"
expect_log "validation_actions/foo0.main"
assert_exists bazel-bin/validation_actions/foo0.validation
assert_exists bazel-bin/validation_actions/foo0.aspect_validation

cat > aspect/aspect_validation_tool <<'EOF'
#!/bin/bash
Expand All @@ -593,7 +560,6 @@ exit 1
EOF

bazel build --run_validations --aspects=//aspect:def.bzl%validation_aspect \
--experimental_use_validation_aspect \
//validation_actions:foo0 >& "$TEST_log" && fail "Expected build to fail"
expect_log "aspect validation failed!"
}
Expand Down

0 comments on commit bb3f329

Please sign in to comment.