Skip to content

Commit 055e25b

Browse files
Wyveraldcopybara-github
authored andcommitted
In update_default_lock_file.sh, create a MODULE.bazel instead of a REPO.bazel
... to avoid the "--enable_bzlmod but no MODULE.bazel found" warning message. PiperOrigin-RevId: 592608824 Change-Id: I140005467977b4fd724eb919ce66f68d83f8ecc2
1 parent d9169ab commit 055e25b

18 files changed

+47
-42
lines changed

MODULE.bazel.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/java/com/google/devtools/build/lib/blackbox/bazel/BlackBoxTestEnvironmentImpl.java

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ public BlackBoxTestContext prepareEnvironment(
4242
testName, "bazel", binaryPath, Collections.emptyMap(), executorService);
4343
// Any Bazel command requires that workspace is already set up.
4444
testContext.write("WORKSPACE", "workspace(name = 'main')", getWorkspaceWithDefaultRepos());
45+
testContext.write("MODULE.bazel");
4546
Path defaultLockfile = RunfilesUtil.find("io_bazel/src/test/tools/bzlmod/MODULE.bazel.lock");
4647
Files.copy(defaultLockfile, testContext.getWorkDir().resolve("MODULE.bazel.lock"));
4748

src/test/py/bazel/BUILD

+4
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ py_test(
164164
timeout = "long",
165165
srcs = ["runfiles_test.py"],
166166
data = glob(["testdata/runfiles_test/**"]),
167+
tags = [
168+
"requires-network",
169+
],
167170
deps = [
168171
":test_base",
169172
],
@@ -177,6 +180,7 @@ py_test(
177180
tags = [
178181
# Windows does not support sandboxing yet.
179182
"no_windows",
183+
"requires-network",
180184
],
181185
deps = [":test_base"],
182186
)

src/test/py/bazel/action_temp_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def _CreateWorkspace(self, build_flags=None):
156156
'fi',
157157
]
158158

159-
self.ScratchFile('WORKSPACE')
159+
self.ScratchFile('MODULE.bazel')
160160
self.ScratchFile('foo/' + toolname, toolsrc, executable=True)
161161
self.ScratchFile(
162162
'foo/foo.bzl',

src/test/py/bazel/bazel_clean_test.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
class BazelCleanTest(test_base.TestBase):
2323

2424
def testBazelClean(self):
25-
self.ScratchFile('WORKSPACE')
25+
self.ScratchFile('MODULE.bazel')
2626
self.ScratchFile('foo/BUILD', [
2727
'genrule(',
2828
' name = "x",',
@@ -60,7 +60,7 @@ def testBazelClean(self):
6060
@absltest.skipIf(not test_base.TestBase.IsLinux(),
6161
'Async clean only supported on Linux')
6262
def testBazelAsyncClean(self):
63-
self.ScratchFile('WORKSPACE')
63+
self.ScratchFile('MODULE.bazel')
6464
_, _, stderr = self.RunBazel(['clean', '--async'])
6565
matcher = self._findMatch(' moved to (.*) for deletion', stderr)
6666
self.assertTrue(matcher, stderr)
@@ -79,7 +79,7 @@ def testBazelAsyncClean(self):
7979
@absltest.skipIf(not test_base.TestBase.IsLinux(),
8080
'Async clean only supported on Linux')
8181
def testBazelAsyncCleanWithReadonlyDirectories(self):
82-
self.ScratchFile('WORKSPACE')
82+
self.ScratchFile('MODULE.bazel')
8383
self.RunBazel(['build'])
8484
_, stdout, _ = self.RunBazel(['info', 'execution_root'])
8585
execroot = stdout[0]

src/test/py/bazel/genrule_test.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class GenRuleTest(test_base.TestBase):
2121

2222
def testCopyWithBashAndBatch(self):
23-
self.ScratchFile('WORKSPACE')
23+
self.ScratchFile('MODULE.bazel')
2424
self.ScratchFile('foo/BUILD', [
2525
'genrule(',
2626
' name = "x",',
@@ -42,7 +42,7 @@ def testCopyWithBashAndBatch(self):
4242
self.AssertFileContentContains(copied, 'hello world')
4343

4444
def testCopyWithBashAndPowershell(self):
45-
self.ScratchFile('WORKSPACE')
45+
self.ScratchFile('MODULE.bazel')
4646
self.ScratchFile('foo/BUILD', [
4747
'genrule(',
4848
' name = "x",',
@@ -64,7 +64,7 @@ def testCopyWithBashAndPowershell(self):
6464
self.AssertFileContentContains(copied, 'hello world')
6565

6666
def testShOptionOverridesDefault(self):
67-
self.ScratchFile('WORKSPACE')
67+
self.ScratchFile('MODULE.bazel')
6868
self.ScratchFile('foo/BUILD', [
6969
'genrule(',
7070
' name = "x",',
@@ -85,7 +85,7 @@ def testShOptionOverridesDefault(self):
8585
def testScriptFileIsUsedWithBatch(self):
8686
if not self.IsWindows():
8787
return
88-
self.ScratchFile('WORKSPACE')
88+
self.ScratchFile('MODULE.bazel')
8989
self.ScratchFile('foo/BUILD', [
9090
'genrule(',
9191
' name = "x",',
@@ -110,7 +110,7 @@ def testScriptFileIsUsedWithBatch(self):
110110
def testScriptFileIsUsedWithPowershell(self):
111111
if not self.IsWindows():
112112
return
113-
self.ScratchFile('WORKSPACE')
113+
self.ScratchFile('MODULE.bazel')
114114
self.ScratchFile('foo/BUILD', [
115115
'genrule(',
116116
' name = "x",',
@@ -135,7 +135,7 @@ def testScriptFileIsUsedWithPowershell(self):
135135
def testCommandFailsEagerlyInPowershell(self):
136136
if not self.IsWindows():
137137
return
138-
self.ScratchFile('WORKSPACE')
138+
self.ScratchFile('MODULE.bazel')
139139
self.ScratchFile('foo/BUILD', [
140140
'genrule(',
141141
' name = "x",',
@@ -155,7 +155,7 @@ def testCommandFailsEagerlyInPowershell(self):
155155
def testCopyWithSpacesWithBatch(self):
156156
if not self.IsWindows():
157157
return
158-
self.ScratchFile('WORKSPACE')
158+
self.ScratchFile('MODULE.bazel')
159159
self.ScratchFile('foo/BUILD', [
160160
'genrule(',
161161
' name = "x",',
@@ -178,7 +178,7 @@ def testCopyWithSpacesWithBatch(self):
178178
def testCopyWithSpacesWithPowershell(self):
179179
if not self.IsWindows():
180180
return
181-
self.ScratchFile('WORKSPACE')
181+
self.ScratchFile('MODULE.bazel')
182182
self.ScratchFile('foo/BUILD', [
183183
'genrule(',
184184
' name = "x",',

src/test/py/bazel/options_test.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class OptionsTest(test_base.TestBase):
2020

2121
def testCanOverrideStarlarkFlagInBazelrcConfigStanza(self):
22-
self.ScratchFile("WORKSPACE.bazel")
22+
self.ScratchFile("MODULE.bazel")
2323
self.ScratchFile(
2424
"bazelrc",
2525
[
@@ -84,7 +84,7 @@ def testCanOverrideStarlarkFlagInBazelrcConfigStanza(self):
8484
)
8585

8686
def testCommonPseudoCommand(self):
87-
self.ScratchFile("WORKSPACE.bazel")
87+
self.ScratchFile("MODULE.bazel")
8888
self.ScratchFile(
8989
".bazelrc",
9090
[
@@ -183,7 +183,7 @@ def testCommonPseudoCommand(self):
183183
)
184184

185185
def testCommonPseudoCommand_singleLineParsesUnambiguously(self):
186-
self.ScratchFile("WORKSPACE.bazel")
186+
self.ScratchFile("MODULE.bazel")
187187
self.ScratchFile(
188188
".bazelrc",
189189
[
@@ -225,7 +225,7 @@ def testCommonPseudoCommand_singleLineParsesUnambiguously(self):
225225
)
226226

227227
def testCommonPseudoCommand_unsupportedOptionValue(self):
228-
self.ScratchFile("WORKSPACE.bazel")
228+
self.ScratchFile("MODULE.bazel")
229229
self.ScratchFile(
230230
".bazelrc",
231231
[
@@ -271,7 +271,7 @@ def testCommonPseudoCommand_unsupportedOptionValue(self):
271271
def testCommonPseudoCommand_allowResidueFalseCommandIgnoresStarlarkOptions(
272272
self,
273273
):
274-
self.ScratchFile("WORKSPACE.bazel")
274+
self.ScratchFile("MODULE.bazel")
275275
self.ScratchFile(
276276
".bazelrc",
277277
[

src/test/py/bazel/query_test.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class QueryTest(test_base.TestBase):
2121

2222
def testSimpleQuery(self):
23-
self.ScratchFile('WORKSPACE')
23+
self.ScratchFile('MODULE.bazel')
2424
self.ScratchFile('foo/BUILD', [
2525
'exports_files(["exported.txt"])',
2626
'filegroup(name = "top-rule", srcs = [":dep-rule"])',
@@ -39,13 +39,14 @@ def testSimpleQuery(self):
3939
'//foo:dep-rule')
4040

4141
def testQueryFilesUsedByRepositoryRules(self):
42-
self.ScratchFile('WORKSPACE')
42+
self.ScratchFile('MODULE.bazel')
4343
self._AssertQueryOutputContains(
4444
"kind('source file', deps(//external:*))",
4545
'@bazel_tools//tools/genrule:genrule-setup.sh',
4646
)
4747

4848
def testBuildFilesForExternalRepos_Simple(self):
49+
self.ScratchFile('MODULE.bazel')
4950
self.ScratchFile('WORKSPACE', [
5051
'load("//:deps.bzl", "repos")',
5152
'repos()',
@@ -64,6 +65,7 @@ def testBuildFilesForExternalRepos_Simple(self):
6465
'//:BUILD.bazel')
6566

6667
def testBuildFilesForExternalRepos_IndirectLoads(self):
68+
self.ScratchFile('MODULE.bazel')
6769
self.ScratchFile('WORKSPACE', [
6870
'load("//:deps.bzl", "repos")',
6971
'repos()',
@@ -94,6 +96,7 @@ def testBuildFilesForExternalRepos_IndirectLoads(self):
9496
'//:deps.bzl', '//:private_deps.bzl', '//:BUILD.bazel')
9597

9698
def testBuildFilesForExternalRepos_NoDuplicates(self):
99+
self.ScratchFile('MODULE.bazel')
97100
self.ScratchFile('WORKSPACE', [
98101
'load("//:deps.bzl", "repos")',
99102
'repos()',

src/test/py/bazel/runfiles_sandboxed_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def _FailWithContents(self, msg, contents):
2525

2626
def testRunfilesLibrariesFindRunfilesWithoutEnvvars(self):
2727
for s, t, exe in [
28-
("WORKSPACE.mock", "WORKSPACE", False),
28+
("MODULE.bazel.mock", "MODULE.bazel", False),
2929
("bar/BUILD.mock", "bar/BUILD", False),
3030
("bar/bar.py", "bar/bar.py", True),
3131
("bar/bar-py-data.txt", "bar/bar-py-data.txt", False),

src/test/py/bazel/runfiles_test.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
class RunfilesTest(test_base.TestBase):
2222

2323
def _AssertRunfilesLibraryInBazelToolsRepo(self, family, lang_name):
24-
for s, t, exe in [("WORKSPACE.mock", "WORKSPACE",
24+
for s, t, exe in [("MODULE.bazel.mock", "MODULE.bazel",
2525
False), ("foo/BUILD.mock", "foo/BUILD",
2626
False), ("foo/foo.py", "foo/foo.py", True),
2727
("foo/Foo.java", "foo/Foo.java",
@@ -101,7 +101,7 @@ def testCppRunfilesLibraryInBazelToolsRepo(self):
101101

102102
def testRunfilesLibrariesFindRunfilesWithoutEnvvars(self):
103103
for s, t, exe in [
104-
("WORKSPACE.mock", "WORKSPACE", False),
104+
("MODULE.bazel.mock", "MODULE.bazel", False),
105105
("bar/BUILD.mock", "bar/BUILD", False),
106106
("bar/bar.py", "bar/bar.py", True),
107107
("bar/bar-py-data.txt", "bar/bar-py-data.txt", False),
@@ -161,7 +161,7 @@ def testRunfilesLibrariesFindRunfilesWithoutEnvvars(self):
161161

162162
def testRunfilesLibrariesFindRunfilesWithRunfilesManifestEnvvar(self):
163163
for s, t, exe in [
164-
("WORKSPACE.mock", "WORKSPACE", False),
164+
("MODULE.bazel.mock", "MODULE.bazel", False),
165165
("bar/BUILD.mock", "bar/BUILD", False),
166166
# Note: do not test Python here, because py_binary always needs a
167167
# runfiles tree, even on Windows, because it needs __init__.py files in
@@ -305,9 +305,10 @@ def testLegacyExternalRunfilesOption(self):
305305

306306
def testRunfilesLibrariesFindRlocationpathExpansion(self):
307307
self.ScratchDir("A")
308-
self.ScratchFile("A/WORKSPACE")
308+
self.ScratchFile("A/REPO.bazel")
309309
self.ScratchFile("A/p/BUILD", ["exports_files(['foo.txt'])"])
310310
self.ScratchFile("A/p/foo.txt", ["Hello, World!"])
311+
self.ScratchFile("MODULE.bazel")
311312
self.ScratchFile("WORKSPACE", ["local_repository(name = 'A', path='A')"])
312313
self.ScratchFile("pkg/BUILD", [
313314
"py_binary(",

src/test/py/bazel/test_base.py

+5
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ def CreateWorkspaceWithDefaultRepos(self, path, lines=None):
225225
')',
226226
])
227227
self.ScratchFile(path, rule_definition)
228+
self.ScratchFile(
229+
path.replace('WORKSPACE.bazel', 'MODULE.bazel').replace(
230+
'WORKSPACE', 'MODULE.bazel'
231+
)
232+
)
228233

229234
def GetDefaultRepoRules(self):
230235
with open(
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bazel_dep(name = "rules_cc", version = "0.0.9")

src/test/py/bazel/testdata/runfiles_test/WORKSPACE.mock

-12
This file was deleted.

src/test/shell/integration/configured_query_test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ function test_external_repo_scope() {
13821382
local -r dir=$FUNCNAME
13831383

13841384
mkdir -p $dir/repo
1385-
touch $dir/repo/WORKSPACE
1385+
touch $dir/repo/REPO.bazel
13861386
cat > $dir/repo/BUILD <<EOF
13871387
sh_library(name='maple', deps=[':japanese'])
13881388
sh_library(name='japanese')

src/test/shell/testenv.sh.tmpl

+3-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,9 @@ EOF
668668

669669
# Set up a lockfile to avoid accessing BCR for tests with a clean workspace.
670670
function write_default_lockfile() {
671-
cp -f $(rlocation io_bazel/src/test/tools/bzlmod/MODULE.bazel.lock) ${1:-MODULE.bazel.lock}
671+
module_lockfile=${1:-MODULE.bazel.lock}
672+
touch "$(dirname ${module_lockfile})/MODULE.bazel"
673+
cp -f $(rlocation io_bazel/src/test/tools/bzlmod/MODULE.bazel.lock) ${module_lockfile}
672674
}
673675

674676
workspaces=()

src/test/tools/bzlmod/MODULE.bazel.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/test/tools/bzlmod/update_default_lock_file.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function generate_lock_file() {
3535
trap 'cleanup $tmpdir' EXIT
3636

3737
cd "${tmpdir}"
38-
touch REPO.bazel
38+
touch MODULE.bazel
3939
bazel=$(rlocation io_bazel/src/bazel)
4040

4141
echo "Running: $bazel mod deps"

src/test/tools/bzlmod/verify_default_lock_file.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ source "$(rlocation "io_bazel/src/test/shell/integration_test_setup.sh")" \
3030
|| { echo "integration_test_setup.sh not found!" >&2; exit 1; }
3131

3232
function test_verify_lock_file() {
33-
touch REPO.bazel
3433
rm -f MODULE.bazel
34+
touch MODULE.bazel
3535
cp $(rlocation io_bazel/src/test/tools/bzlmod/MODULE.bazel.lock) MODULE.bazel.lock
3636
echo "Running: bazel mod deps --lockfile_mode=error" >& "$TEST_log"
3737
bazel mod deps --lockfile_mode=error >& "$TEST_log" || fail "Default lockfile for empty workspace is no longer in sync with MODULE.tools. Please run \"bazel run //src/test/tools/bzlmod:update_default_lock_file\""

0 commit comments

Comments
 (0)