Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.0.0] Fix Autoloads skyframe injection #24310

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,11 @@ public final int hashCode() {
// These fields are used to generate all other private fields.
// Thus, other fields don't need to be included in hash code.
return Objects.hash(
autoloadedSymbols, removedSymbols, partiallyRemovedSymbols, reposDisallowingAutoloads);
bzlmodEnabled,
autoloadedSymbols,
removedSymbols,
partiallyRemovedSymbols,
reposDisallowingAutoloads);
}

@Override
Expand All @@ -538,7 +542,8 @@ public final boolean equals(Object that) {
AutoloadSymbols other = (AutoloadSymbols) that;
// These fields are used to generate all other private fields.
// Thus, other fields don't need to be included in comparison.
return this.autoloadedSymbols.equals(other.autoloadedSymbols)
return this.bzlmodEnabled == other.bzlmodEnabled
&& this.autoloadedSymbols.equals(other.autoloadedSymbols)
&& this.removedSymbols.equals(other.removedSymbols)
&& this.partiallyRemovedSymbols.equals(other.partiallyRemovedSymbols)
&& this.reposDisallowingAutoloads.equals(other.reposDisallowingAutoloads);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright 2024 The Bazel Authors. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.devtools.build.lib.bazel.rules;

import static com.google.common.truth.Truth.assertThat;

import com.google.common.collect.ImmutableList;
import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
import com.google.devtools.build.lib.packages.AutoloadSymbols;
import com.google.devtools.build.lib.skyframe.PrecomputedValue;
import com.google.devtools.build.skyframe.EvaluationContext;
import com.google.devtools.build.skyframe.SkyKey;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

@RunWith(JUnit4.class)
public class AutoloadSymbolsTest extends BuildViewTestCase {

private static final SkyKey AUTOLOAD_SYMBOLS_KEY = AutoloadSymbols.AUTOLOAD_SYMBOLS.getKey();
private static final ImmutableList<SkyKey> KEYS_TO_EVALUATE =
ImmutableList.of(AUTOLOAD_SYMBOLS_KEY);

@Test
public void bzlmodFlagUpdatesAutoloadConfig() throws Exception {
EvaluationContext context =
EvaluationContext.newBuilder().setParallelism(1).setEventHandler(reporter).build();

setBuildLanguageOptions("--enable_bzlmod");
AutoloadSymbols value1 = evaluateAutoloads(context);
setBuildLanguageOptions("--noenable_bzlmod");
AutoloadSymbols value2 = evaluateAutoloads(context);

assertThat(value1).isNotSameInstanceAs(value2);
}

private AutoloadSymbols evaluateAutoloads(EvaluationContext context) throws InterruptedException {
return (AutoloadSymbols)
((PrecomputedValue)
skyframeExecutor
.getEvaluator()
.evaluate(KEYS_TO_EVALUATE, context)
.get(AUTOLOAD_SYMBOLS_KEY))
.get();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,15 @@ java_library(
"//src/main/java/com/google/devtools/build/lib/bazel/rules",
"//src/main/java/com/google/devtools/build/lib/cmdline",
"//src/main/java/com/google/devtools/build/lib/packages",
"//src/main/java/com/google/devtools/build/lib/packages:autoload_symbols",
"//src/main/java/com/google/devtools/build/lib/rules:core_workspace_rules",
"//src/main/java/com/google/devtools/build/lib/rules/config",
"//src/main/java/com/google/devtools/build/lib/rules/core",
"//src/main/java/com/google/devtools/build/lib/skyframe:precomputed_value",
"//src/main/java/com/google/devtools/build/lib/util:os",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/java/com/google/devtools/build/skyframe",
"//src/main/java/com/google/devtools/build/skyframe:skyframe-objects",
"//src/main/java/com/google/devtools/common/options",
"//src/test/java/com/google/devtools/build/lib/analysis/util",
"//third_party:guava",
Expand Down
Loading