Skip to content

Commit 175a18d

Browse files
meteorcloudycopybara-github
authored andcommitted
Enable Bzlmod in shell integration tests
Working towards: #18958 Closes #19785 PiperOrigin-RevId: 573215173 Change-Id: I2b1f24d01f22966df76c6d5ccfaa6ef5cbbfd12f
1 parent 4064d78 commit 175a18d

51 files changed

Lines changed: 261 additions & 187 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

examples/java-starlark/src/main/java/com/example/myproject/Greeter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ public static String convertStreamToString(InputStream is) throws Exception {
2929
public void hello(String obj) throws Exception {
3030
String greeting = "Hello";
3131
try {
32-
String greetFile = getRunfiles()
33-
+ "/io_bazel/examples/java-starlark/src/main/resources/greeting.txt";
32+
String greetFile =
33+
getRunfiles() + "/_main/examples/java-starlark/src/main/resources/greeting.txt";
3434
greeting = convertStreamToString(new FileInputStream(greetFile));
3535
} catch (FileNotFoundException e) {
3636
// use default.

src/main/java/com/google/devtools/build/lib/rules/repository/RepositoryDelegatorFunction.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ public SkyValue compute(SkyKey skyKey, Environment env)
340340
// The repository isn't on the file system, there is nothing we can do.
341341
throw new RepositoryFunctionException(
342342
new IOException(
343-
"to fix, run\n\tbazel fetch //...\nExternal repository "
343+
"External repository "
344344
+ repositoryName.getNameWithAt()
345345
+ " not found and fetching repositories is disabled."),
346346
Transience.TRANSIENT);

src/main/java/com/google/devtools/build/lib/skyframe/SkyframeExecutor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2709,7 +2709,7 @@ public RepositoryMapping getMainRepoMapping(
27092709
DetailedExitCode.of(
27102710
FailureDetail.newBuilder()
27112711
.setExternalRepository(FailureDetails.ExternalRepository.getDefaultInstance())
2712-
.setMessage("unknown error during computation of main repo mapping")
2712+
.setMessage("error during computation of main repo mapping: " + e.getMessage())
27132713
.build()),
27142714
e);
27152715
}

src/main/starlark/tests/builtins_bzl/cc_builtin_tests.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,9 @@ msys*)
5151
;;
5252
esac
5353

54+
# TODO: cc_shared_library doesn't work well with Bzlmod.
55+
disable_bzlmod
56+
5457
function test_starlark_cc() {
5558
setup_tests src/main/starlark/tests/builtins_bzl/cc
5659
mkdir -p "src/conditions"

src/test/shell/BUILD

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
load("//:distdir_deps.bzl", "gen_workspace_stanza")
21
load("@rules_python//python:defs.bzl", "py_test")
2+
load("//:distdir_deps.bzl", "gen_workspace_stanza")
33

44
package(default_visibility = ["//visibility:private"])
55

@@ -47,6 +47,7 @@ sh_library(
4747
],
4848
data = [
4949
":testenv.sh",
50+
"//src/test/tools/bzlmod:MODULE.bazel.lock",
5051
"@bazel_tools//tools/bash/runfiles",
5152
],
5253
visibility = ["//visibility:public"],

src/test/shell/bazel/bazel_coverage_hermetic_py_test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ CURRENT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
2121
source "${CURRENT_DIR}/../integration_test_setup.sh" \
2222
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }
2323

24+
disable_bzlmod
25+
2426
# Fetch hermetic python and register toolchain.
2527
function set_up() {
2628
cat >>WORKSPACE <<EOF

src/test/shell/bazel/bazel_coverage_java_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,7 @@ import java.nio.channels.*;
403403
import java.net.InetAddress;
404404
public class CovTest extends TestCase {
405405
private static Process startSubprocess(String arg) throws Exception {
406-
String path = System.getenv("TEST_SRCDIR") + "/main/java/cov/Cov_deploy.jar";
406+
String path = System.getenv("TEST_SRCDIR") + "/_main/java/cov/Cov_deploy.jar";
407407
String[] command = {
408408
// Run the deploy jar by invoking JVM because the integration tests
409409
// cannot use the java launcher (b/29388516).
@@ -580,7 +580,7 @@ import java.nio.channels.*;
580580
import java.net.InetAddress;
581581
public class CovTest extends TestCase {
582582
private static Process startSubprocess(String arg) throws Exception {
583-
String path = System.getenv("TEST_SRCDIR") + "/main/java/cov/Cov_deploy.jar";
583+
String path = System.getenv("TEST_SRCDIR") + "/_main/java/cov/Cov_deploy.jar";
584584
String[] command = {
585585
// Run the deploy jar by invoking JVM because the integration tests
586586
// cannot use the java launcher (b/29388516).

src/test/shell/bazel/bazel_hermetic_sandboxing_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ function test_absolute_path() {
309309
function test_symbolic_link() {
310310
bazel build examples/hermetic:symbolic_link &> $TEST_log \
311311
&& fail "Fail due to non hermetic sandbox: examples/hermetic:symbolic_link" || true
312-
expect_log "cat: \/execroot\/main\/examples\/hermetic\/unknown_file.txt: No such file or directory"
312+
expect_log "cat: \/execroot\/_main\/examples\/hermetic\/unknown_file.txt: No such file or directory"
313313
}
314314

315315
# Test that the sandbox discover if the bazel python rule miss dependencies.

src/test/shell/bazel/bazel_java17_test.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ fi
7272
JAVA_TOOLS_ZIP_FILE_URL=${JAVA_TOOLS_ZIP_FILE_URL:-}
7373
JAVA_TOOLS_PREBUILT_ZIP_FILE_URL=${JAVA_TOOLS_PREBUILT_ZIP_FILE_URL:-}
7474

75+
disable_bzlmod
7576

7677
function set_up() {
7778
cat >>WORKSPACE <<EOF

src/test/shell/bazel/bazel_rules_cc_test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ filegroup(name = 'yolo')
7878
EOF
7979

8080
cd rules_cc_can_be_overridden || fail "couldn't cd into workspace"
81-
bazel build @rules_cc//:yolo &> $TEST_log || \
81+
bazel build --noenable_bzlmod @rules_cc//:yolo &> $TEST_log || \
8282
fail "Bazel failed to build @rules_cc"
8383
}
8484

0 commit comments

Comments
 (0)