Skip to content

Commit d6daa76

Browse files
committed
Explicitly enable/disable Bzlmod
1 parent 2342eac commit d6daa76

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

go/tools/bazel_testing/bazel_testing.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -364,11 +364,16 @@ func setupWorkspace(args Args, files []string) (dir string, cleanup func() error
364364
// The test can override this with its own .bazelrc or with flags in commands.
365365
bazelrcPath := filepath.Join(mainDir, ".bazelrc")
366366
bazelrcBuf := &bytes.Buffer{}
367+
if args.ModuleFileSuffix == "" {
368+
fmt.Fprintf(bazelrcBuf, "common --noenable_bzlmod\n")
369+
} else {
370+
fmt.Fprintf(bazelrcBuf, "common --enable_bzlmod\n")
371+
}
367372
if outputUserRoot != "" {
368373
fmt.Fprintf(bazelrcBuf, "startup --output_user_root=%s\n", outputUserRoot)
369374
}
370375
if flags := os.Getenv("GO_BAZEL_TEST_BAZELFLAGS"); flags != "" {
371-
fmt.Fprintf(bazelrcBuf, "build %s\n", flags)
376+
fmt.Fprintf(bazelrcBuf, "common %s\n", flags)
372377
}
373378
if err := os.WriteFile(bazelrcPath, bazelrcBuf.Bytes(), 0666); err != nil {
374379
return "", cleanup, err

0 commit comments

Comments
 (0)