Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c0c98a2

Browse files
comiuscopybara-github
authored andcommittedApr 15, 2025
Add loads to integration tests
These are needed to flip --incompatible_disable_autoloads_in_main_repository PiperOrigin-RevId: 747798337 Change-Id: Ia600652523c5b41f436db0f612607e7f403a4157
1 parent 0d44148 commit c0c98a2

26 files changed

+576
-207
lines changed
 

‎examples/py/BUILD

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
load("@rules_python//python:py_binary.bzl", "py_binary")
2+
load("@rules_python//python:py_library.bzl", "py_library")
3+
14
py_library(
25
name = "lib",
36
srcs = ["lib.py"],

‎examples/py_native/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
load("@rules_python//python:py_binary.bzl", "py_binary")
2+
load("@rules_python//python:py_library.bzl", "py_library")
3+
load("@rules_python//python:py_test.bzl", "py_test")
4+
15
filegroup(
26
name = "srcs",
37
srcs = glob(["*.py"]) + [

‎examples/py_native/fibonacci/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
load("@rules_python//python:py_library.bzl", "py_library")
2+
13
filegroup(
24
name = "srcs",
35
srcs = glob(["*.py"]) + [

‎examples/shell/BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
2+
load("@rules_shell//shell:sh_library.bzl", "sh_library")
3+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
4+
15
package(default_visibility = ["//visibility:public"])
26

37
sh_binary(

‎src/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ load("@bazel_pip_dev_deps//:requirements.bzl", "requirement")
44
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
55
load("@rules_java//java:java_binary.bzl", "java_binary")
66
load("@rules_python//python:defs.bzl", "py_binary", "py_library")
7+
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
78
load("//src:build_defs.bzl", "transition_java_language_8_archive")
89
load("//src:release_archive.bzl", "release_archive")
910
load(":embedded_tools.bzl", "srcsfile")

‎src/main/java/com/google/devtools/build/skyframe/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
load("@com_google_protobuf//bazel:java_proto_library.bzl", "java_proto_library")
12
load("@com_google_protobuf//bazel:proto_library.bzl", "proto_library")
23
load("@rules_java//java:defs.bzl", "java_library")
34
load("//tools/build_rules:utilities.bzl", "java_library_srcs")

‎src/main/starlark/tests/builtins_bzl/builtin_test_setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ function setup_tests() {
2323
add_bazel_skylib "MODULE.bazel"
2424
add_rules_python "MODULE.bazel"
2525
add_platforms "MODULE.bazel"
26+
add_rules_shell "MODULE.bazel"
2627
src=$(get_runfiles_dir $1)
2728
dest="${2:-$1}"
2829
if [ ! -e "$src" ]; then

‎src/main/starlark/tests/builtins_bzl/cc/cc_shared_library/test/BUILD.builtin_test

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ load(
1515
"runfiles_test",
1616
"wrapped_cc_lib",
1717
)
18+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
19+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
20+
load("@rules_cc//cc:cc_import.bzl", "cc_import")
21+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
1822

1923
LINKABLE_MORE_THAN_ONCE = "LINKABLE_MORE_THAN_ONCE"
2024

‎src/main/starlark/tests/builtins_bzl/cc/cc_static_library/test/BUILD.builtin_test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
load(":starlark_tests.bzl", "analysis_test_suite")
2+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
3+
load("@rules_cc//cc:cc_import.bzl", "cc_import")
4+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
25

36
cc_static_library(
47
name = "static",

‎src/test/java/com/google/devtools/build/lib/blackbox/tests/PythonBlackBoxTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ protected ImmutableList<ToolsSetup> getAdditionalTools() {
3838

3939
@Test
4040
public void testCompileAndRunHelloWorldStub() throws Exception {
41+
context().write(MODULE_DOT_BAZEL, "bazel_dep(name = 'rules_python', version = '0.40.0')");
42+
4143
writeHelloWorldFiles();
4244

4345
BuilderRunner bazel = context().bazel();
@@ -51,7 +53,11 @@ public void testCompileAndRunHelloWorldStub() throws Exception {
5153
}
5254

5355
private void writeHelloWorldFiles() throws IOException {
54-
context().write("python/hello/BUILD", "py_binary(name = 'hello', srcs = ['hello.py'])");
56+
context()
57+
.write(
58+
"python/hello/BUILD",
59+
"load('@rules_python//python:py_binary.bzl', 'py_binary')",
60+
"py_binary(name = 'hello', srcs = ['hello.py'])");
5561
context().write("python/hello/hello.py", String.format("print ('%s')", HELLO));
5662
}
5763
}

‎src/test/py/bazel/bazel_external_repository_test.py

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,20 @@ def tearDown(self):
6666
def testNewHttpArchive(self):
6767
ip, port = self._http_server.server_address
6868
rule_definition = [
69-
(
70-
'http_archive ='
71-
' use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl",'
72-
' "http_archive")'
73-
),
69+
'bazel_dep(name = "rules_python", version = "0.40.0")',
70+
'http_archive = use_repo_rule(',
71+
' "@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")',
7472
'http_archive(',
7573
' name = "hello_archive",',
7674
' urls = ["http://%s:%s/hello-1.0.0.tar.gz"],' % (ip, port),
77-
(
78-
' sha256 = '
79-
'"154740b327bcfee5669ef2ce0a04bf0904227a3bfe0fee08a5aaca96ea5a601a",'
80-
),
75+
' sha256 = ',
76+
' "154740b327bcfee5669ef2ce0a04bf0904227a3bfe0fee08a5aaca96ea5a601a",',
8177
' strip_prefix = "hello-1.0.0",',
8278
' build_file = "@//third_party:hello.BUILD",',
8379
')',
8480
]
8581
build_file = [
82+
'load("@rules_python//python:py_library.bzl", "py_library")',
8683
'py_library(',
8784
' name = "hello",',
8885
' srcs = ["hello.py"],',
@@ -189,20 +186,16 @@ def testNewHttpTarWithSparseFile(self):
189186

190187
ip, port = self._http_server.server_address
191188
rule_definition = [
192-
(
193-
'http_archive ='
194-
' use_repo_rule("@bazel_tools//tools/build_defs/repo:http.bzl",'
195-
' "http_archive")'
196-
),
189+
'bazel_dep(name = "rules_python", version = "0.40.0")',
190+
'http_archive = use_repo_rule(',
191+
' "@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")',
197192
'http_archive(',
198193
' name = "sparse_archive",',
199194
' urls = ["http://%s:%s/sparse_archive.tar"],' % (ip, port),
200195
' build_file = "@//:sparse_archive.BUILD",',
201196
' sha256 = ',
202-
(
203-
' "a1a2b2ce4acd51a8cc1ab80adce6f134ac73e885219911a960a42000e312bb65",'
204-
')'
205-
),
197+
' "a1a2b2ce4acd51a8cc1ab80adce6f134ac73e885219911a960a42000e312bb65",',
198+
')',
206199
]
207200
self.ScratchFile('MODULE.bazel', rule_definition)
208201
self.ScratchFile(
@@ -224,13 +217,12 @@ def testNewHttpTarWithSparseFile(self):
224217
self.ScratchFile(
225218
'BUILD',
226219
[
220+
'load("@rules_python//python:py_test.bzl", "py_test")',
227221
'py_test(',
228222
' name = "test",',
229223
' srcs = ["test.py"],',
230-
(
231-
' args = ["$(rlocationpath @sparse_archive//:sparse_file)"],'
232-
' data = ['
233-
),
224+
' args = ["$(rlocationpath @sparse_archive//:sparse_file)"],',
225+
' data = [',
234226
' "@sparse_archive//:sparse_file",',
235227
' "@bazel_tools//tools/python/runfiles",',
236228
' ],)',
@@ -260,10 +252,11 @@ def _CreatePyWritingStarlarkRule(self, print_string):
260252
def testNewLocalRepositoryNoticesFileChangeInRepoRoot(self):
261253
"""Regression test for https://github.com/bazelbuild/bazel/issues/7063."""
262254
rule_definition = [
255+
'bazel_dep(name = "rules_python", version = "0.40.0")',
256+
'new_local_repository = use_repo_rule(',
263257
(
264-
'new_local_repository ='
265-
' use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl",'
266-
' "new_local_repository")'
258+
' "@bazel_tools//tools/build_defs/repo:local.bzl",'
259+
' "new_local_repository")'
267260
),
268261
'new_local_repository(',
269262
' name = "r",',
@@ -273,11 +266,15 @@ def testNewLocalRepositoryNoticesFileChangeInRepoRoot(self):
273266
]
274267
self.ScratchFile('MODULE.bazel', rule_definition)
275268
self._CreatePyWritingStarlarkRule('hello!')
276-
self.ScratchFile('BUILD', [
277-
'load("@r//:foo.bzl", "gen_py")',
278-
'gen_py(name = "gen")',
279-
'py_binary(name = "bin", srcs = [":gen"], main = "gen.py")',
280-
])
269+
self.ScratchFile(
270+
'BUILD',
271+
[
272+
'load("@r//:foo.bzl", "gen_py")',
273+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
274+
'gen_py(name = "gen")',
275+
'py_binary(name = "bin", srcs = [":gen"], main = "gen.py")',
276+
],
277+
)
281278

282279
_, stdout, _ = self.RunBazel(['run', '//:bin'])
283280
self.assertIn('hello!', os.linesep.join(stdout))
@@ -294,11 +291,9 @@ def setUpOtherRepoMyRepo(self):
294291
self.ScratchFile(
295292
'my_repo/MODULE.bazel',
296293
[
297-
(
298-
'local_repository ='
299-
' use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl",'
300-
' "local_repository")'
301-
),
294+
'local_repository = use_repo_rule(',
295+
' "@bazel_tools//tools/build_defs/repo:local.bzl",',
296+
' "local_repository")',
302297
'local_repository(name = "other_repo", path="../other_repo")',
303298
],
304299
)

‎src/test/py/bazel/launcher_test.py

Lines changed: 156 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,21 @@ def _buildAndCheckArgumentPassing(self, package, target_name):
237237
self.assertEqual(stdout, arguments)
238238

239239
def testJavaBinaryLauncher(self):
240-
self.ScratchFile('foo/BUILD', [
241-
'java_binary(',
242-
' name = "foo",',
243-
' srcs = ["Main.java"],',
244-
' main_class = "Main",',
245-
' data = ["//bar:bar.txt"],',
246-
')',
247-
])
240+
self.ScratchFile(
241+
'MODULE.bazel', ['bazel_dep(name = "rules_java", version = "8.11.0")']
242+
)
243+
self.ScratchFile(
244+
'foo/BUILD',
245+
[
246+
'load("@rules_java//java:java_binary.bzl", "java_binary")',
247+
'java_binary(',
248+
' name = "foo",',
249+
' srcs = ["Main.java"],',
250+
' main_class = "Main",',
251+
' data = ["//bar:bar.txt"],',
252+
')',
253+
],
254+
)
248255
self.ScratchFile('foo/Main.java', [
249256
'public class Main {',
250257
' public static void main(String[] args) {'
@@ -266,13 +273,20 @@ def testJavaBinaryLauncher(self):
266273
self._buildJavaTargets(bazel_bin, '.exe' if self.IsWindows() else '')
267274

268275
def testJavaBinaryArgumentPassing(self):
269-
self.ScratchFile('foo/BUILD', [
270-
'java_binary(',
271-
' name = "bin",',
272-
' srcs = ["Main.java"],',
273-
' main_class = "Main",',
274-
')',
275-
])
276+
self.ScratchFile(
277+
'MODULE.bazel', ['bazel_dep(name = "rules_java", version = "8.11.0")']
278+
)
279+
self.ScratchFile(
280+
'foo/BUILD',
281+
[
282+
'load("@rules_java//java:java_binary.bzl", "java_binary")',
283+
'java_binary(',
284+
' name = "bin",',
285+
' srcs = ["Main.java"],',
286+
' main_class = "Main",',
287+
')',
288+
],
289+
)
276290
self.ScratchFile('foo/Main.java', [
277291
'public class Main {',
278292
' public static void main(String[] args) {'
@@ -286,6 +300,9 @@ def testJavaBinaryArgumentPassing(self):
286300
self._buildAndCheckArgumentPassing('foo', 'bin')
287301

288302
def testShBinaryLauncher(self):
303+
self.ScratchFile(
304+
'MODULE.bazel', ['bazel_dep(name = "rules_shell", version = "0.3.0")']
305+
)
289306
self.ScratchFile(
290307
'foo/BUILD',
291308
[
@@ -295,6 +312,7 @@ def testShBinaryLauncher(self):
295312
# On Windows, if the srcs's extension is one of ".exe", ".cmd", or
296313
# ".bat", then Bazel requires the rule's name has the same
297314
# extension, and the output file will be a copy of the source file.
315+
'load("@rules_shell//shell:sh_binary.bzl", "sh_binary")',
298316
'sh_binary(',
299317
' name = "bin1.sh",',
300318
' srcs = ["foo.sh"],',
@@ -310,7 +328,8 @@ def testShBinaryLauncher(self):
310328
' srcs = ["foo.cmd"],',
311329
' data = ["//bar:bar.txt"],',
312330
')',
313-
])
331+
],
332+
)
314333
foo_sh = self.ScratchFile('foo/foo.sh', [
315334
'#!/bin/bash',
316335
'echo hello shell',
@@ -328,12 +347,19 @@ def testShBinaryLauncher(self):
328347
self._buildShBinaryTargets(bazel_bin, '.exe' if self.IsWindows() else '')
329348

330349
def testShBinaryArgumentPassing(self):
331-
self.ScratchFile('foo/BUILD', [
332-
'sh_binary(',
333-
' name = "bin",',
334-
' srcs = ["bin.sh"],',
335-
')',
336-
])
350+
self.ScratchFile(
351+
'MODULE.bazel', ['bazel_dep(name = "rules_shell", version = "0.3.0")']
352+
)
353+
self.ScratchFile(
354+
'foo/BUILD',
355+
[
356+
'load("@rules_shell//shell:sh_binary.bzl", "sh_binary")',
357+
'sh_binary(',
358+
' name = "bin",',
359+
' srcs = ["bin.sh"],',
360+
')',
361+
],
362+
)
337363
foo_sh = self.ScratchFile('foo/bin.sh', [
338364
'#!/bin/bash',
339365
'# Store arguments in a array',
@@ -350,6 +376,9 @@ def testShBinaryArgumentPassing(self):
350376
self._buildAndCheckArgumentPassing('foo', 'bin')
351377

352378
def testPyBinaryLauncher(self):
379+
self.ScratchFile(
380+
'MODULE.bazel', ['bazel_dep(name = "rules_python", version = "0.40.0")']
381+
)
353382
self.ScratchFile(
354383
'foo/foo.bzl',
355384
[
@@ -372,12 +401,30 @@ def testPyBinaryLauncher(self):
372401
')',
373402
],
374403
)
375-
self.ScratchFile('foo/BUILD', [
376-
'load(":foo.bzl", "helloworld")', '', 'py_binary(', ' name = "foo",',
377-
' srcs = ["foo.py"],', ' data = ["//bar:bar.txt"],', ')', '',
378-
'py_test(', ' name = "test",', ' srcs = ["test.py"],', ')', '',
379-
'helloworld(', ' name = "hello",', ' out = "hello.txt",', ')'
380-
])
404+
self.ScratchFile(
405+
'foo/BUILD',
406+
[
407+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
408+
'load("@rules_python//python:py_test.bzl", "py_test")',
409+
'load(":foo.bzl", "helloworld")',
410+
'',
411+
'py_binary(',
412+
' name = "foo",',
413+
' srcs = ["foo.py"],',
414+
' data = ["//bar:bar.txt"],',
415+
')',
416+
'',
417+
'py_test(',
418+
' name = "test",',
419+
' srcs = ["test.py"],',
420+
')',
421+
'',
422+
'helloworld(',
423+
' name = "hello",',
424+
' out = "hello.txt",',
425+
')',
426+
],
427+
)
381428
foo_py = self.ScratchFile('foo/foo.py', [
382429
'#!/usr/bin/env python3',
383430
'import sys',
@@ -406,12 +453,19 @@ def testPyBinaryLauncher(self):
406453
self._buildPyTargets(bazel_bin, '.exe' if self.IsWindows() else '')
407454

408455
def testPyBinaryArgumentPassing(self):
409-
self.ScratchFile('foo/BUILD', [
410-
'py_binary(',
411-
' name = "bin",',
412-
' srcs = ["bin.py"],',
413-
')',
414-
])
456+
self.ScratchFile(
457+
'MODULE.bazel', ['bazel_dep(name = "rules_python", version = "0.40.0")']
458+
)
459+
self.ScratchFile(
460+
'foo/BUILD',
461+
[
462+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
463+
'py_binary(',
464+
' name = "bin",',
465+
' srcs = ["bin.py"],',
466+
')',
467+
],
468+
)
415469
self.ScratchFile('foo/bin.py', [
416470
'import sys',
417471
'for arg in sys.argv[1:]:',
@@ -422,12 +476,19 @@ def testPyBinaryArgumentPassing(self):
422476

423477
def testPyBinaryLauncherWithDifferentArgv0(self):
424478
"""Test for https://github.com/bazelbuild/bazel/issues/14343."""
425-
self.ScratchFile('foo/BUILD', [
426-
'py_binary(',
427-
' name = "bin",',
428-
' srcs = ["bin.py"],',
429-
')',
430-
])
479+
self.ScratchFile(
480+
'MODULE.bazel', ['bazel_dep(name = "rules_python", version = "0.40.0")']
481+
)
482+
self.ScratchFile(
483+
'foo/BUILD',
484+
[
485+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
486+
'py_binary(',
487+
' name = "bin",',
488+
' srcs = ["bin.py"],',
489+
')',
490+
],
491+
)
431492
self.ScratchFile('foo/bin.py', ['print("Hello world")'])
432493

433494
_, stdout, _ = self.RunBazel(['info', 'bazel-bin'])
@@ -447,15 +508,22 @@ def testWindowsJavaExeLauncher(self):
447508
# Skip this test on non-Windows platforms
448509
if not self.IsWindows():
449510
return
450-
self.ScratchFile('foo/BUILD', [
451-
'java_binary(',
452-
' name = "foo",',
453-
' srcs = ["Main.java"],',
454-
' main_class = "Main",',
455-
' jvm_flags = ["--flag1", "--flag2"],',
456-
' data = ["advice-1.jar", "advice-2.jar"],',
457-
')',
458-
])
511+
self.ScratchFile(
512+
'MODULE.bazel', ['bazel_dep(name = "rules_java", version = "8.11.0")']
513+
)
514+
self.ScratchFile(
515+
'foo/BUILD',
516+
[
517+
'load("@rules_java//java:java_binary.bzl", "java_binary")',
518+
'java_binary(',
519+
' name = "foo",',
520+
' srcs = ["Main.java"],',
521+
' main_class = "Main",',
522+
' jvm_flags = ["--flag1", "--flag2"],',
523+
' data = ["advice-1.jar", "advice-2.jar"],',
524+
')',
525+
],
526+
)
459527
self.ScratchFile('foo/advice-1.jar')
460528
self.ScratchFile('foo/advice-2.jar')
461529
self.ScratchFile('foo/Main.java', [
@@ -569,17 +637,27 @@ def testWindowsJavaExeLauncher(self):
569637
def testWindowsNativeLauncherInNonEnglishPath(self):
570638
if not self.IsWindows():
571639
return
572-
self.ScratchFile('bin/BUILD', [
573-
'java_binary(',
574-
' name = "bin_java",',
575-
' srcs = ["Main.java"],',
576-
' main_class = "Main",',
577-
')',
578-
'sh_binary(',
579-
' name = "bin_sh",',
580-
' srcs = ["main.sh"],',
581-
')',
582-
])
640+
self.ScratchFile(
641+
'MODULE.bazel', ['bazel_dep(name = "rules_java", version = "8.11.0")',
642+
'bazel_dep(name = "rules_python", version = "0.40.0")',
643+
'bazel_dep(name = "rules_shell", version = "0.3.0")']
644+
)
645+
self.ScratchFile(
646+
'bin/BUILD',
647+
[
648+
'load("@rules_java//java:java_binary.bzl", "java_binary")',
649+
'load("@rules_shell//shell:sh_binary.bzl", "sh_binary")',
650+
'java_binary(',
651+
' name = "bin_java",',
652+
' srcs = ["Main.java"],',
653+
' main_class = "Main",',
654+
')',
655+
'sh_binary(',
656+
' name = "bin_sh",',
657+
' srcs = ["main.sh"],',
658+
')',
659+
],
660+
)
583661
self.ScratchFile('bin/Main.java', [
584662
'public class Main {',
585663
' public static void main(String[] args) {'
@@ -617,9 +695,17 @@ def testWindowsNativeLauncherInNonEnglishPath(self):
617695
def testWindowsNativeLauncherInLongPath(self):
618696
if not self.IsWindows():
619697
return
698+
self.ScratchFile(
699+
'MODULE.bazel', ['bazel_dep(name = "rules_java", version = "8.11.0")',
700+
'bazel_dep(name = "rules_python", version = "0.40.0")',
701+
'bazel_dep(name = "rules_shell", version = "0.3.0")']
702+
)
620703
self.ScratchFile(
621704
'bin/BUILD',
622705
[
706+
'load("@rules_java//java:java_binary.bzl", "java_binary")',
707+
'load("@rules_shell//shell:sh_binary.bzl", "sh_binary")',
708+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
623709
'java_binary(',
624710
' name = "not_short_bin_java",',
625711
' srcs = ["Main.java"],',
@@ -713,9 +799,17 @@ def testWindowsNativeLauncherInLongPath(self):
713799
def testWindowsNativeLauncherInvalidArgv0(self):
714800
if not self.IsWindows():
715801
return
802+
self.ScratchFile(
803+
'MODULE.bazel', ['bazel_dep(name = "rules_java", version = "8.11.0")',
804+
'bazel_dep(name = "rules_python", version = "0.40.0")',
805+
'bazel_dep(name = "rules_shell", version = "0.3.0")']
806+
)
716807
self.ScratchFile(
717808
'bin/BUILD',
718809
[
810+
'load("@rules_java//java:java_binary.bzl", "java_binary")',
811+
'load("@rules_shell//shell:sh_binary.bzl", "sh_binary")',
812+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
719813
'java_binary(',
720814
' name = "bin_java",',
721815
' srcs = ["Main.java"],',
@@ -787,11 +881,8 @@ def testBuildLaunchersWithClangClOnWindows(self):
787881
[
788882
'bazel_dep(name = "platforms", version = "0.0.9")',
789883
'bazel_dep(name = "rules_cc", version = "0.0.12")',
790-
(
791-
'cc_configure ='
792-
' use_extension("@rules_cc//cc:extensions.bzl",'
793-
' "cc_configure_extension")'
794-
),
884+
'cc_configure = use_extension(',
885+
' "@rules_cc//cc:extensions.bzl", "cc_configure_extension")',
795886
'use_repo(cc_configure, "local_config_cc")',
796887
# Register all cc toolchains for Windows
797888
'register_toolchains("@local_config_cc//:all")',

‎src/test/py/bazel/py_test.py

Lines changed: 103 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ def createSimpleFiles(self):
2626
self.ScratchFile(
2727
'a/BUILD',
2828
[
29+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
30+
'load("@rules_python//python:py_library.bzl", "py_library")',
2931
'py_binary(name="a", srcs=["a.py"], deps=[":b"])',
3032
'py_library(name="b", srcs=["b.py"], imports=["."])',
3133
],
@@ -45,6 +47,12 @@ def createSimpleFiles(self):
4547
' print("Hello, World")',
4648
])
4749

50+
def setUp(self):
51+
test_base.TestBase.setUp(self)
52+
self.ScratchFile(
53+
'MODULE.bazel', ['bazel_dep(name = "rules_python", version = "0.40.0")']
54+
)
55+
4856
def testSmoke(self):
4957
self.createSimpleFiles()
5058
_, stdout, _ = self.RunBazel(['run', '//a:a'])
@@ -68,13 +76,24 @@ def testRunfilesSymlinks(self):
6876

6977
class TestInitPyFiles(test_base.TestBase):
7078

79+
def setUp(self):
80+
test_base.TestBase.setUp(self)
81+
self.ScratchFile(
82+
'MODULE.bazel', ['bazel_dep(name = "rules_python", version = "0.40.0")']
83+
)
84+
7185
def createSimpleFiles(self, create_init=True):
7286

73-
self.ScratchFile('src/a/BUILD', [
74-
'py_binary(name="a", srcs=["a.py"], deps=[":b"], legacy_create_init=%s)'
75-
% create_init,
76-
'py_library(name="b", srcs=["b.py"])',
77-
])
87+
self.ScratchFile(
88+
'src/a/BUILD',
89+
[
90+
'load("@rules_python//python:py_library.bzl", "py_library")',
91+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
92+
'py_binary(name="a", srcs=["a.py"], deps=[":b"],'
93+
' legacy_create_init=%s)' % create_init,
94+
'py_library(name="b", srcs=["b.py"])',
95+
],
96+
)
7897

7998
self.ScratchFile('src/a/a.py', [
8099
'from src.a import b',
@@ -116,13 +135,18 @@ def testInitPyFilesNotCreatedWhenLegacyCreateInitIsSet(self):
116135

117136
# Regression test for https://github.com/bazelbuild/bazel/pull/10119
118137
def testBuildingZipFileWithTargetNameWithDot(self):
119-
self.ScratchFile('BUILD', [
120-
'py_binary(',
121-
' name = "bin.v1", # .v1 should not be treated as extension and removed accidentally',
122-
' srcs = ["bin.py"],',
123-
' main = "bin.py",',
124-
')',
125-
])
138+
self.ScratchFile(
139+
'BUILD',
140+
[
141+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
142+
"# .v1 shouldn't be treated as extension and removed accidentally",
143+
'py_binary(',
144+
' name = "bin.v1",',
145+
' srcs = ["bin.py"],',
146+
' main = "bin.py",',
147+
')',
148+
],
149+
)
126150
self.ScratchFile('bin.py', ['print("Hello, world")'])
127151
self.RunBazel(['build', '--build_python_zip', '//:bin.v1'])
128152
self.assertTrue(os.path.exists('bazel-bin/bin.v1.temp'))
@@ -151,19 +175,26 @@ def _RunRemoteBazel(self, args):
151175

152176
def setUp(self):
153177
test_base.TestBase.setUp(self)
178+
self.ScratchFile(
179+
'MODULE.bazel', ['bazel_dep(name = "rules_python", version = "0.40.0")']
180+
)
154181
self._worker_port = self.StartRemoteWorker()
155182

156183
def tearDown(self):
157184
self.StopRemoteWorker()
158185
test_base.TestBase.tearDown(self)
159186

160187
def testPyTestRunsRemotely(self):
161-
self.ScratchFile('foo/BUILD', [
162-
'py_test(',
163-
' name = "foo_test",',
164-
' srcs = ["foo_test.py"],',
165-
')',
166-
])
188+
self.ScratchFile(
189+
'foo/BUILD',
190+
[
191+
'load("@rules_python//python:py_test.bzl", "py_test")',
192+
'py_test(',
193+
' name = "foo_test",',
194+
' srcs = ["foo_test.py"],',
195+
')',
196+
],
197+
)
167198
self.ScratchFile('foo/foo_test.py', [
168199
'print("Test ran")',
169200
])
@@ -176,17 +207,22 @@ def testPyTestRunsRemotely(self):
176207

177208
# Regression test for https://github.com/bazelbuild/bazel/issues/9239
178209
def testPyTestWithStdlibCollisionRunsRemotely(self):
179-
self.ScratchFile('foo/BUILD', [
180-
'py_library(',
181-
' name = "io",',
182-
' srcs = ["io.py"],',
183-
')',
184-
'py_test(',
185-
' name = "io_test",',
186-
' srcs = ["io_test.py"],',
187-
' deps = [":io"],',
188-
')',
189-
])
210+
self.ScratchFile(
211+
'foo/BUILD',
212+
[
213+
'load("@rules_python//python:py_library.bzl", "py_library")',
214+
'load("@rules_python//python:py_test.bzl", "py_test")',
215+
'py_library(',
216+
' name = "io",',
217+
' srcs = ["io.py"],',
218+
')',
219+
'py_test(',
220+
' name = "io_test",',
221+
' srcs = ["io_test.py"],',
222+
' deps = [":io"],',
223+
')',
224+
],
225+
)
190226
self.ScratchFile('foo/io.py', [
191227
'def my_func():',
192228
' print("Test ran")',
@@ -209,41 +245,46 @@ def testPyRunfilesLibraryCurrentRepository(self):
209245
self.ScratchFile(
210246
'MODULE.bazel',
211247
[
212-
(
213-
'local_repository ='
214-
' use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl",'
215-
' "local_repository")'
216-
),
248+
'bazel_dep(name = "rules_python", version = "0.40.0")',
249+
'local_repository = use_repo_rule(',
250+
' "@bazel_tools//tools/build_defs/repo:local.bzl",',
251+
' "local_repository")',
217252
'local_repository(name = "other_repo", path = "other_repo_path")',
218253
],
219254
)
220255

221-
self.ScratchFile('pkg/BUILD.bazel', [
222-
'py_library(',
223-
' name = "library",',
224-
' srcs = ["library.py"],',
225-
' visibility = ["//visibility:public"],',
226-
' deps = ["@bazel_tools//tools/python/runfiles"],',
227-
')',
228-
'',
229-
'py_binary(',
230-
' name = "binary",',
231-
' srcs = ["binary.py"],',
232-
' deps = [',
233-
' ":library",',
234-
' "@bazel_tools//tools/python/runfiles",',
235-
' ],',
236-
')',
237-
'',
238-
'py_test(',
239-
' name = "test",',
240-
' srcs = ["test.py"],',
241-
' deps = [',
242-
' ":library",',
243-
' "@bazel_tools//tools/python/runfiles",',
244-
' ],',
245-
')',
246-
])
256+
self.ScratchFile(
257+
'pkg/BUILD.bazel',
258+
[
259+
'load("@rules_python//python:py_library.bzl", "py_library")',
260+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
261+
'load("@rules_python//python:py_test.bzl", "py_test")',
262+
'py_library(',
263+
' name = "library",',
264+
' srcs = ["library.py"],',
265+
' visibility = ["//visibility:public"],',
266+
' deps = ["@bazel_tools//tools/python/runfiles"],',
267+
')',
268+
'',
269+
'py_binary(',
270+
' name = "binary",',
271+
' srcs = ["binary.py"],',
272+
' deps = [',
273+
' ":library",',
274+
' "@bazel_tools//tools/python/runfiles",',
275+
' ],',
276+
')',
277+
'',
278+
'py_test(',
279+
' name = "test",',
280+
' srcs = ["test.py"],',
281+
' deps = [',
282+
' ":library",',
283+
' "@bazel_tools//tools/python/runfiles",',
284+
' ],',
285+
')',
286+
],
287+
)
247288
self.ScratchFile('pkg/library.py', [
248289
'from bazel_tools.tools.python.runfiles import runfiles',
249290
'def print_repo_name():',
@@ -266,6 +307,8 @@ def testPyRunfilesLibraryCurrentRepository(self):
266307
self.ScratchFile(
267308
'other_repo_path/other_pkg/BUILD.bazel',
268309
[
310+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
311+
'load("@rules_python//python:py_test.bzl", "py_test")',
269312
'py_binary(',
270313
' name = "binary",',
271314
' srcs = ["binary.py"],',

‎src/test/py/bazel/query_test.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,16 @@ def testSimpleQuery(self):
4343
def testQueryWithDifferentOutputBaseAfterBuilding(self):
4444
output_base = tempfile.mkdtemp(dir=os.getenv('TEST_TMPDIR'))
4545

46-
self.ScratchFile('MODULE.bazel')
46+
self.ScratchFile(
47+
'MODULE.bazel',
48+
[
49+
'bazel_dep(name = "rules_python", version = "0.40.0")',
50+
],
51+
)
4752
self.ScratchFile(
4853
'BUILD',
4954
[
55+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
5056
'py_binary(name="a", srcs=["a.py"])',
5157
],
5258
)

‎src/test/py/bazel/runfiles_test.py

Lines changed: 56 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -262,25 +262,35 @@ def testRunfilesLibrariesFindRlocationpathExpansion(self):
262262
self.ScratchFile("A/REPO.bazel")
263263
self.ScratchFile("A/p/BUILD", ["exports_files(['foo.txt'])"])
264264
self.ScratchFile("A/p/foo.txt", ["Hello, World!"])
265-
self.ScratchFile("MODULE.bazel", [
266-
'local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "local_repository")', # pylint: disable=line-too-long
267-
'local_repository(name = "A", path = "A")',
268-
])
269-
self.ScratchFile("pkg/BUILD", [
270-
"py_binary(",
271-
" name = 'bin',",
272-
" srcs = ['bin.py'],",
273-
" args = [",
274-
" '$(rlocationpath bar.txt)',",
275-
" '$(rlocationpath @A//p:foo.txt)',",
276-
" ],",
277-
" data = [",
278-
" 'bar.txt',",
279-
" '@A//p:foo.txt'",
280-
" ],",
281-
" deps = ['@bazel_tools//tools/python/runfiles'],",
282-
")",
283-
])
265+
self.ScratchFile(
266+
"MODULE.bazel",
267+
[
268+
'bazel_dep(name = "rules_python", version = "0.40.0")',
269+
"local_repository = use_repo_rule(",
270+
' "@bazel_tools//tools/build_defs/repo:local.bzl",',
271+
' "local_repository")',
272+
'local_repository(name = "A", path = "A")',
273+
],
274+
)
275+
self.ScratchFile(
276+
"pkg/BUILD",
277+
[
278+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
279+
"py_binary(",
280+
" name = 'bin',",
281+
" srcs = ['bin.py'],",
282+
" args = [",
283+
" '$(rlocationpath bar.txt)',",
284+
" '$(rlocationpath @A//p:foo.txt)',",
285+
" ],",
286+
" data = [",
287+
" 'bar.txt',",
288+
" '@A//p:foo.txt'",
289+
" ],",
290+
" deps = ['@bazel_tools//tools/python/runfiles'],",
291+
")",
292+
],
293+
)
284294
self.ScratchFile("pkg/bar.txt", ["Hello, Bazel!"])
285295
self.ScratchFile("pkg/bin.py", [
286296
"import sys",
@@ -296,10 +306,13 @@ def testRunfilesLibrariesFindRlocationpathExpansion(self):
296306
self.assertEqual(stdout[1], "Hello, World!")
297307

298308
def setUpRunfilesDirectoryIncrementalityTest(self):
299-
self.ScratchFile("MODULE.bazel")
309+
self.ScratchFile(
310+
"MODULE.bazel", ['bazel_dep(name = "rules_shell", version = "0.3.0")']
311+
)
300312
self.ScratchFile(
301313
"BUILD",
302314
[
315+
'load("@rules_shell//shell:sh_test.bzl", "sh_test")',
303316
"sh_test(",
304317
" name = 'test',",
305318
" srcs = ['test.sh'],",
@@ -418,10 +431,13 @@ def testRunfilesDirectoryIncrementalityNoBuildRunfileLinksEnableRunfilesFlippedO
418431
self.assertNotEqual(exit_code, 0)
419432

420433
def testTestsRunWithNoBuildRunfileLinksAndNoEnableRunfiles(self):
421-
self.ScratchFile("MODULE.bazel")
434+
self.ScratchFile(
435+
"MODULE.bazel", ['bazel_dep(name = "rules_shell", version = "0.3.0")']
436+
)
422437
self.ScratchFile(
423438
"BUILD",
424439
[
440+
'load("@rules_shell//shell:sh_test.bzl", "sh_test")',
425441
"sh_test(",
426442
" name = 'test',",
427443
" srcs = ['test.sh'],",
@@ -436,10 +452,13 @@ def testTestsRunWithNoBuildRunfileLinksAndNoEnableRunfiles(self):
436452

437453
def testWrappedShBinary(self):
438454
self.writeWrapperRule()
439-
self.ScratchFile("MODULE.bazel")
455+
self.ScratchFile(
456+
"MODULE.bazel", ['bazel_dep(name = "rules_shell", version = "0.3.0")']
457+
)
440458
self.ScratchFile(
441459
"BUILD",
442460
[
461+
'load("@rules_shell//shell:sh_binary.bzl", "sh_binary")',
443462
"sh_binary(",
444463
" name = 'binary',",
445464
" srcs = ['binary.sh'],",
@@ -466,6 +485,7 @@ def disabledWrappedPyBinary(self):
466485
self.ScratchFile(
467486
"BUILD",
468487
[
488+
'load("@rules_python//python:py_binary.bzl", "py_binary")',
469489
"py_binary(",
470490
" name = 'binary',",
471491
" srcs = ['binary.py'],",
@@ -485,10 +505,13 @@ def disabledWrappedPyBinary(self):
485505

486506
def testWrappedJavaBinary(self):
487507
self.writeWrapperRule()
488-
self.ScratchFile("MODULE.bazel")
508+
self.ScratchFile(
509+
"MODULE.bazel", ['bazel_dep(name = "rules_java", version = "8.11.0")']
510+
)
489511
self.ScratchFile(
490512
"BUILD",
491513
[
514+
'load("@rules_java//java:java_binary.bzl", "java_binary")',
492515
"java_binary(",
493516
" name = 'binary',",
494517
" srcs = ['Binary.java'],",
@@ -518,26 +541,16 @@ def writeWrapperRule(self):
518541
[
519542
"def _wrapper_impl(ctx):",
520543
" target = ctx.attr.target",
521-
(
522-
" original_executable ="
523-
" target[DefaultInfo].files_to_run.executable"
524-
),
525-
(
526-
" executable ="
527-
" ctx.actions.declare_file(original_executable.basename)"
528-
),
529-
(
530-
" ctx.actions.symlink(output = executable, target_file ="
531-
" original_executable)"
532-
),
533-
(
534-
" data_runfiles ="
535-
" ctx.runfiles([executable]).merge(target[DefaultInfo].data_runfiles)"
536-
),
537-
(
538-
" default_runfiles ="
539-
" ctx.runfiles([executable]).merge(target[DefaultInfo].default_runfiles)"
540-
),
544+
" original_executable = (",
545+
" target[DefaultInfo].files_to_run.executable)",
546+
" executable = ctx.actions.declare_file(",
547+
" original_executable.basename)",
548+
" ctx.actions.symlink(output = executable,",
549+
" target_file = original_executable)",
550+
" data_runfiles = ctx.runfiles([executable]).merge(",
551+
" target[DefaultInfo].data_runfiles)",
552+
" default_runfiles = ctx.runfiles([executable]).merge(",
553+
" target[DefaultInfo].default_runfiles)",
541554
" return [",
542555
" DefaultInfo(",
543556
" executable = executable,",

‎src/test/shell/bazel/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
load("@bazel_skylib//rules:write_file.bzl", "write_file")
2+
load("@rules_shell//shell:sh_library.bzl", "sh_library")
3+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
24
load("//:workspace_deps.bzl", "gen_workspace_stanza")
35
load("//src/tools/bzlmod:utils.bzl", "get_canonical_repo_name")
46

‎src/test/shell/bazel/bazel_build_event_stream_test.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,10 @@ EOF
185185
}
186186

187187
function test_residue_in_run_bep(){
188+
add_rules_shell "MODULE.bazel"
188189
mkdir -p a
189190
cat > a/BUILD <<'EOF'
191+
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
190192
sh_binary(
191193
name = 'arg',
192194
srcs = ['arg.sh'],
@@ -221,8 +223,10 @@ EOF
221223
}
222224

223225
function test_no_residue_in_run_bep(){
226+
add_rules_shell "MODULE.bazel"
224227
mkdir -p a
225228
cat > a/BUILD <<'EOF'
229+
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
226230
sh_binary(
227231
name = 'arg',
228232
srcs = ['arg.sh'],
@@ -261,8 +265,10 @@ EOF
261265

262266

263267
function test_residue_in_run_test_bep(){
268+
add_rules_shell "MODULE.bazel"
264269
mkdir -p a
265270
cat > a/BUILD <<'EOF'
271+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
266272
sh_test(
267273
name = 'arg',
268274
srcs = ['arg_test.sh'],
@@ -297,8 +303,10 @@ EOF
297303
}
298304

299305
function test_no_residue_in_run_test_bep(){
306+
add_rules_shell "MODULE.bazel"
300307
mkdir -p a
301308
cat > a/BUILD <<'EOF'
309+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
302310
sh_test(
303311
name = 'arg',
304312
srcs = ['arg_test.sh'],

‎src/test/shell/bazel/bazel_coverage_cc_test_gcc.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,17 @@ if [[ "${COVERAGE_GENERATOR_DIR}" != "released" ]]; then
2929
add_to_bazelrc "build --override_repository=remote_coverage_tools=${COVERAGE_GENERATOR_DIR}"
3030
fi
3131

32+
function set_up() {
33+
add_rules_cc "MODULE.bazel"
34+
}
35+
3236
# Writes the C++ source files and a corresponding BUILD file for which to
3337
# collect code coverage. The sources are a.cc, a.h and t.cc.
3438
function setup_a_cc_lib_and_t_cc_test() {
3539
cat << EOF > BUILD
40+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
41+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
42+
3643
cc_library(
3744
name = "a",
3845
srcs = ["a.cc"],
@@ -137,6 +144,9 @@ function test_cc_test_coverage_gcov_virtual_includes() {
137144
########### Setup source files and BUILD file ###########
138145
mkdir -p examples/cpp
139146
cat << EOF > examples/cpp/BUILD
147+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
148+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
149+
140150
cc_library(
141151
name = "a_header",
142152
hdrs = ["foo/bar/baz/a_header.h"],
@@ -279,6 +289,9 @@ function test_cc_test_gcov_multiple_headers() {
279289
############## Setting up the test sources and BUILD file ##############
280290
mkdir -p "coverage_srcs/"
281291
cat << EOF > BUILD
292+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
293+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
294+
282295
cc_library(
283296
name = "a",
284297
srcs = ["coverage_srcs/a.cc"],
@@ -383,6 +396,9 @@ function test_cc_test_gcov_multiple_headers_instrument_test_target() {
383396
############## Setting up the test sources and BUILD file ##############
384397
mkdir -p "coverage_srcs/"
385398
cat << EOF > BUILD
399+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
400+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
401+
386402
cc_library(
387403
name = "a",
388404
srcs = ["coverage_srcs/a.cc"],
@@ -492,6 +508,9 @@ function test_cc_test_gcov_same_header_different_libs() {
492508
############## Setting up the test sources and BUILD file ##############
493509
mkdir -p "coverage_srcs/"
494510
cat << EOF > BUILD
511+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
512+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
513+
495514
cc_library(
496515
name = "a",
497516
srcs = ["coverage_srcs/a.cc"],
@@ -654,6 +673,9 @@ function test_cc_test_gcov_same_header_different_libs_multiple_exec() {
654673
############## Setting up the test sources and BUILD file ##############
655674
mkdir -p "coverage_srcs/"
656675
cat << EOF > BUILD
676+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
677+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
678+
657679
cc_library(
658680
name = "a",
659681
srcs = ["coverage_srcs/a.cc"],
@@ -845,6 +867,9 @@ function test_failed_coverage() {
845867
fi
846868

847869
cat << EOF > BUILD
870+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
871+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
872+
848873
cc_library(
849874
name = "a",
850875
srcs = ["a.cc"],
@@ -924,6 +949,8 @@ function test_coverage_doesnt_fail_on_empty_output() {
924949
}
925950
EOF
926951
cat << EOF > empty_cov/BUILD
952+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
953+
927954
cc_test(
928955
name = "empty-cov-test",
929956
srcs = ["t.cc"]
@@ -943,8 +970,11 @@ local_repository(
943970
path = "other_repo",
944971
)
945972
EOF
973+
add_rules_cc "MODULE.bazel"
946974

947975
cat > BUILD <<'EOF'
976+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
977+
948978
cc_library(
949979
name = "b",
950980
srcs = ["b.cc"],
@@ -971,6 +1001,9 @@ EOF
9711001
touch other_repo/REPO.bazel
9721002

9731003
cat > other_repo/BUILD <<'EOF'
1004+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
1005+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
1006+
9741007
cc_library(
9751008
name = "a",
9761009
srcs = ["a.cc"],

‎src/test/shell/bazel/bazel_coverage_cc_test_llvm.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ if [[ "${COVERAGE_GENERATOR_DIR}" != "released" ]]; then
2929
add_to_bazelrc "build --override_repository=remote_coverage_tools=${COVERAGE_GENERATOR_DIR}"
3030
fi
3131

32+
function set_up() {
33+
add_rules_cc "MODULE.bazel"
34+
}
35+
3236
# Configures Bazel to emit coverage using LLVM tools, returning a non-zero exit
3337
# code if the tools are not available.
3438
function setup_llvm_coverage_tools_for_lcov() {
@@ -67,6 +71,9 @@ function setup_llvm_coverage_tools_for_lcov() {
6771
# collect code coverage. The sources are a.cc, a.h and t.cc.
6872
function setup_a_cc_lib_and_t_cc_test() {
6973
cat << EOF > BUILD
74+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
75+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
76+
7077
cc_library(
7178
name = "a",
7279
srcs = ["a.cc"],
@@ -201,8 +208,13 @@ end_of_record"
201208

202209
function test_cc_test_with_runtime_objects_not_in_runfiles() {
203210
setup_llvm_coverage_tools_for_lcov || return 0
211+
add_rules_java "MODULE.bazel"
204212

205213
cat << EOF > BUILD
214+
load("@rules_java//java:java_binary.bzl", "java_binary")
215+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
216+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
217+
206218
cc_test(
207219
name = "main",
208220
srcs = ["main.cpp"],
@@ -265,8 +277,11 @@ local_repository(
265277
path = "other_repo",
266278
)
267279
EOF
280+
add_rules_cc "MODULE.bazel"
268281

269282
cat > BUILD <<'EOF'
283+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
284+
270285
cc_library(
271286
name = "b",
272287
srcs = ["b.cc"],
@@ -424,6 +439,9 @@ function test_coverage_with_tmp_in_path() {
424439

425440
mkdir -p foo/tmp
426441
cat > foo/tmp/BUILD <<'EOF'
442+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
443+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
444+
427445
cc_library(
428446
name = "a",
429447
srcs = ["a.cc"],
@@ -494,6 +512,9 @@ function test_coverage_for_header() {
494512
setup_llvm_coverage_tools_for_lcov || return 0
495513

496514
cat << EOF > BUILD
515+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
516+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
517+
497518
cc_library(
498519
name = "foo",
499520
srcs = ["foo.cc"],

‎src/test/shell/bazel/bazel_coverage_java_test.sh

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,15 @@ if [[ $# -gt 0 ]]; then
4242
add_to_bazelrc "build --tool_java_runtime_version=${JAVA_RUNTIME_VERSION}"
4343
fi
4444

45+
function set_up() {
46+
add_rules_java "MODULE.bazel"
47+
}
48+
4549
function test_java_test_coverage() {
4650
cat <<EOF > BUILD
4751
load("@bazel_tools//tools/jdk:default_java_toolchain.bzl", "default_java_toolchain")
52+
load("@rules_java//java:java_test.bzl", "java_test")
53+
load("@rules_java//java:java_library.bzl", "java_library")
4854
4955
java_test(
5056
name = "test",
@@ -139,6 +145,9 @@ end_of_record"
139145
function test_java_test_coverage_combined_report() {
140146

141147
cat <<EOF > BUILD
148+
load("@rules_java//java:java_library.bzl", "java_library")
149+
load("@rules_java//java:java_test.bzl", "java_test")
150+
142151
java_test(
143152
name = "test",
144153
srcs = glob(["src/test/**/*.java"]),
@@ -228,6 +237,10 @@ end_of_record"
228237
function test_java_test_java_import_coverage() {
229238

230239
cat <<EOF > BUILD
240+
load("@rules_java//java:java_test.bzl", "java_test")
241+
load("@rules_java//java:java_import.bzl", "java_import")
242+
load("@rules_java//java:java_library.bzl", "java_library")
243+
231244
java_test(
232245
name = "test",
233246
srcs = glob(["src/test/**/*.java"]),
@@ -319,6 +332,8 @@ function test_run_jar_in_subprocess_empty_env() {
319332
mkdir -p java/cov
320333
mkdir -p javatests/cov
321334
cat >java/cov/BUILD <<EOF
335+
load("@rules_java//java:java_binary.bzl", "java_binary")
336+
322337
package(default_visibility=['//visibility:public'])
323338
java_binary(name = 'Cov',
324339
main_class = 'cov.Cov',
@@ -341,6 +356,7 @@ public class Cov {
341356
EOF
342357

343358
cat >javatests/cov/BUILD <<EOF
359+
load("@rules_java//java:java_test.bzl", "java_test")
344360
java_test(name = 'CovTest',
345361
srcs = ['CovTest.java'],
346362
data = ['//java/cov:Cov_deploy.jar'],
@@ -409,6 +425,9 @@ function test_runtime_deploy_jar() {
409425
mkdir -p java/cov
410426
mkdir -p javatests/cov
411427
cat >java/cov/BUILD <<EOF
428+
load("@rules_java//java:java_binary.bzl", "java_binary")
429+
load("@rules_java//java:java_library.bzl", "java_library")
430+
412431
package(default_visibility=['//visibility:public'])
413432
java_binary(
414433
name = 'RandomBinary',
@@ -447,6 +466,8 @@ public class Cov {
447466
EOF
448467

449468
cat >javatests/cov/BUILD <<EOF
469+
load("@rules_java//java:java_test.bzl", "java_test")
470+
450471
java_test(name = 'CovTest',
451472
srcs = ['CovTest.java'],
452473
deps = ['//java/cov:Cov'],
@@ -478,6 +499,8 @@ function test_runtime_and_data_deploy_jars() {
478499
mkdir -p java/cov
479500
mkdir -p javatests/cov
480501
cat >java/cov/BUILD <<EOF
502+
load("@rules_java//java:java_binary.bzl", "java_binary")
503+
481504
package(default_visibility=['//visibility:public'])
482505
java_binary(
483506
name = 'RandomBinary',
@@ -517,6 +540,8 @@ public class Cov {
517540
EOF
518541

519542
cat >javatests/cov/BUILD <<EOF
543+
load("@rules_java//java:java_test.bzl", "java_test")
544+
520545
java_test(name = 'CovTest',
521546
srcs = ['CovTest.java'],
522547
data = ['//java/cov:Cov_deploy.jar'],
@@ -622,6 +647,9 @@ function test_java_coverage_with_classpath_jar() {
622647
# Verifies the logic in JacocoCoverageRunner can unpack the classpath jar
623648
# created when the classpath is too long.
624649
cat <<EOF > BUILD
650+
load("@rules_java//java:java_library.bzl", "java_library")
651+
load("@rules_java//java:java_test.bzl", "java_test")
652+
625653
java_library(
626654
name = "lib",
627655
srcs = ["src/main/java/lib/Lib.java"],
@@ -686,6 +714,10 @@ LF:2"
686714

687715
function test_java_coverage_with_classpath_and_data_jar() {
688716
cat <<EOF > BUILD
717+
load("@rules_java//java:java_binary.bzl", "java_binary")
718+
load("@rules_java//java:java_test.bzl", "java_test")
719+
load("@rules_java//java:java_library.bzl", "java_library")
720+
689721
java_binary(
690722
name = "foo",
691723
srcs = ["src/main/java/foo/Foo.java"],
@@ -784,6 +816,9 @@ function test_java_string_switch_coverage() {
784816
# (because a switch on String::hashCode is made first) - these branches should
785817
# be filtered.
786818
cat <<EOF > BUILD
819+
load("@rules_java//java:java_test.bzl", "java_test")
820+
load("@rules_java//java:java_library.bzl", "java_library")
821+
787822
java_test(
788823
name = "test",
789824
srcs = glob(["src/test/**/*.java"]),
@@ -876,6 +911,9 @@ function test_finally_block_branch_coverage() {
876911
# may enter them (e.g. via an exception handler or when no exception is
877912
# thrown).
878913
cat <<EOF > BUILD
914+
load("@rules_java//java:java_test.bzl", "java_test")
915+
load("@rules_java//java:java_library.bzl", "java_library")
916+
879917
java_test(
880918
name = "test",
881919
srcs = glob(["src/test/**/*.java"]),
@@ -1081,7 +1119,10 @@ function test_java_test_coverage_cc_binary() {
10811119
fi
10821120

10831121
########### Setup source files and BUILD file ###########
1122+
add_rules_cc "MODULE.bazel"
10841123
cat <<EOF > BUILD
1124+
load("@rules_java//java:java_test.bzl", "java_test")
1125+
10851126
java_test(
10861127
name = "NumJava",
10871128
srcs = ["NumJava.java"],
@@ -1103,6 +1144,9 @@ EOF
11031144
mkdir -p examples/cpp
11041145

11051146
cat <<EOF > examples/cpp/BUILD
1147+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
1148+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
1149+
11061150
package(default_visibility = ["//visibility:public"])
11071151
11081152
cc_binary(
@@ -1227,6 +1271,8 @@ local_repository(
12271271
EOF
12281272

12291273
cat > BUILD <<'EOF'
1274+
load("@rules_java//java:java_library.bzl", "java_library")
1275+
12301276
java_library(
12311277
name = "math",
12321278
srcs = ["src/main/com/example/Math.java"],
@@ -1250,6 +1296,9 @@ EOF
12501296
touch other_repo/REPO.bazel
12511297

12521298
cat > other_repo/BUILD <<'EOF'
1299+
load("@rules_java//java:java_library.bzl", "java_library")
1300+
load("@rules_java//java:java_test.bzl", "java_test")
1301+
12531302
java_library(
12541303
name = "collatz",
12551304
srcs = ["src/main/com/example/Collatz.java"],

‎src/test/shell/bazel/bazel_example_test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ function set_up() {
5555
module(name="io_bazel")
5656
EOF
5757
add_rules_java "MODULE.bazel"
58+
add_rules_python "MODULE.bazel"
59+
add_rules_shell "MODULE.bazel"
5860
}
5961

6062
#

‎src/test/shell/bazel/bazel_hermetic_sandboxing_test.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function set_up {
6363

6464
sed -i.bak '/sandbox_tmpfs_path/d' $TEST_TMPDIR/bazelrc
6565

66+
add_rules_python "MODULE.bazel"
6667
mkdir -p examples/hermetic
6768

6869
cat << 'EOF' > examples/hermetic/unknown_file.txt
@@ -95,7 +96,7 @@ import import_module
9596
EOF
9697

9798
cat << 'EOF' > examples/hermetic/BUILD
98-
99+
load("@rules_python//python:py_test.bzl", "py_test")
99100
load(
100101
"test.bzl",
101102
"overwrite_via_symlink",

‎src/test/shell/bazel/bazel_windows_example_test.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ function test_java_test() {
292292
}
293293

294294
function test_native_python() {
295+
add_rules_python "MODULE.bazel"
295296
# On windows, we build a python executable zip as the python binary
296297
assert_build //examples/py_native:bin
297298
# run the python package directly, clearing out runfiles variables to
@@ -314,6 +315,7 @@ function test_native_python() {
314315
# default on your system. See this pull request for an example:
315316
# https://github.com/bazelbuild/continuous-integration/pull/1216
316317
function test_native_python_with_runfiles() {
318+
add_rules_python "MODULE.bazel"
317319
BUILD_FLAGS="--enable_runfiles --build_python_zip=0"
318320
bazel build -s --verbose_failures $BUILD_FLAGS //examples/py_native:bin \
319321
|| fail "Failed to build //examples/py_native:bin with runfiles support"

‎src/test/shell/bazel/remote/remote_build_event_uploader_test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,8 +425,10 @@ EOF
425425
}
426426

427427
function test_upload_minimal_upload_testlogs() {
428+
add_rules_shell "MODULE.bazel"
428429
mkdir -p a
429430
cat > a/BUILD <<EOF
431+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
430432
sh_test(
431433
name = 'test',
432434
srcs = ['test.sh'],
@@ -451,8 +453,10 @@ EOF
451453
}
452454

453455
function test_upload_all_upload_testlogs() {
456+
add_rules_shell "MODULE.bazel"
454457
mkdir -p a
455458
cat > a/BUILD <<EOF
459+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
456460
sh_test(
457461
name = 'test',
458462
srcs = ['test.sh'],

‎src/test/shell/bazel/remote/remote_execution_http_test.sh

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,10 @@ EOF
7373
}
7474

7575
function test_cc_binary_http_cache() {
76+
add_rules_cc "MODULE.bazel"
7677
mkdir -p a
7778
cat > a/BUILD <<EOF
79+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
7880
package(default_visibility = ["//visibility:public"])
7981
cc_binary(
8082
name = 'test',
@@ -106,8 +108,11 @@ EOF
106108
}
107109

108110
function test_cc_binary_http_cache_bad_server() {
111+
add_rules_cc "MODULE.bazel"
109112
mkdir -p a
110113
cat > a/BUILD <<EOF
114+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
115+
111116
package(default_visibility = ["//visibility:public"])
112117
cc_binary(
113118
name = 'test',
@@ -139,6 +144,7 @@ EOF
139144
}
140145

141146
function set_directory_artifact_starlark_testfixtures() {
147+
add_rules_shell "MODULE.bazel"
142148
mkdir -p a
143149
cat > a/rule.bzl <<'EOF'
144150
def _gen_output_dir_impl(ctx):
@@ -169,6 +175,7 @@ gen_output_dir = rule(
169175
)
170176
EOF
171177
cat > a/BUILD <<'EOF'
178+
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
172179
package(default_visibility = ["//visibility:public"])
173180
load("//a:rule.bzl", "gen_output_dir")
174181

‎src/test/shell/bazel/remote/remote_execution_test.sh

Lines changed: 64 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,8 +307,10 @@ EOF
307307
}
308308

309309
function test_cc_binary() {
310+
add_rules_cc "MODULE.bazel"
310311
mkdir -p a
311312
cat > a/BUILD <<EOF
313+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
312314
package(default_visibility = ["//visibility:public"])
313315
cc_binary(
314316
name = 'test',
@@ -334,8 +336,10 @@ EOF
334336
}
335337

336338
function test_cc_test() {
339+
add_rules_cc "MODULE.bazel"
337340
mkdir -p a
338341
cat > a/BUILD <<EOF
342+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
339343
package(default_visibility = ["//visibility:public"])
340344
cc_test(
341345
name = 'test',
@@ -356,8 +360,10 @@ EOF
356360
}
357361

358362
function test_cc_test_split_xml() {
363+
add_rules_cc "MODULE.bazel"
359364
mkdir -p a
360365
cat > a/BUILD <<EOF
366+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
361367
package(default_visibility = ["//visibility:public"])
362368
cc_test(
363369
name = 'test',
@@ -378,8 +384,10 @@ EOF
378384
}
379385

380386
function test_cc_binary_grpc_cache() {
387+
add_rules_cc "MODULE.bazel"
381388
mkdir -p a
382389
cat > a/BUILD <<EOF
390+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
383391
package(default_visibility = ["//visibility:public"])
384392
cc_binary(
385393
name = 'test',
@@ -404,8 +412,10 @@ EOF
404412
}
405413

406414
function test_cc_binary_grpc_cache_statsline() {
415+
add_rules_cc "MODULE.bazel"
407416
mkdir -p a
408417
cat > a/BUILD <<EOF
418+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
409419
package(default_visibility = ["//visibility:public"])
410420
cc_binary(
411421
name = 'test',
@@ -428,8 +438,10 @@ EOF
428438
}
429439

430440
function test_failing_cc_test() {
441+
add_rules_cc "MODULE.bazel"
431442
mkdir -p a
432443
cat > a/BUILD <<EOF
444+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
433445
package(default_visibility = ["//visibility:public"])
434446
cc_test(
435447
name = 'test',
@@ -616,8 +628,10 @@ function is_file_uploaded() {
616628
function test_failed_test_outputs_not_uploaded() {
617629
# Test that outputs of a failed test/action are not uploaded to the remote
618630
# cache. This is a regression test for https://github.com/bazelbuild/bazel/issues/7232
631+
add_rules_cc "MODULE.bazel"
619632
mkdir -p a
620633
cat > a/BUILD <<EOF
634+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
621635
package(default_visibility = ["//visibility:public"])
622636
cc_test(
623637
name = 'test',
@@ -671,8 +685,10 @@ EOF
671685
}
672686

673687
function test_py_test() {
688+
add_rules_python "MODULE.bazel"
674689
mkdir -p a
675690
cat > a/BUILD <<EOF
691+
load("@rules_python//python:py_test.bzl", "py_test")
676692
package(default_visibility = ["//visibility:public"])
677693
py_test(
678694
name = 'test',
@@ -693,8 +709,10 @@ EOF
693709
}
694710

695711
function test_py_test_with_xml_output() {
712+
add_rules_python "MODULE.bazel"
696713
mkdir -p a
697714
cat > a/BUILD <<EOF
715+
load("@rules_python//python:py_test.bzl", "py_test")
698716
package(default_visibility = ["//visibility:public"])
699717
py_test(
700718
name = 'test',
@@ -731,8 +749,10 @@ EOF
731749
}
732750

733751
function test_failing_py_test_with_xml_output() {
752+
add_rules_python "MODULE.bazel"
734753
mkdir -p a
735754
cat > a/BUILD <<EOF
755+
load("@rules_python//python:py_test.bzl", "py_test")
736756
package(default_visibility = ["//visibility:public"])
737757
py_test(
738758
name = 'test',
@@ -795,8 +815,10 @@ EOF
795815
}
796816

797817
function test_timeout() {
818+
add_rules_shell "MODULE.bazel"
798819
mkdir -p a
799820
cat > a/BUILD <<'EOF'
821+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
800822
sh_test(
801823
name = "sleep",
802824
timeout = "short",
@@ -828,8 +850,10 @@ EOF
828850
}
829851

830852
function test_passed_env_user() {
853+
add_rules_shell "MODULE.bazel"
831854
mkdir -p a
832855
cat > a/BUILD <<'EOF'
856+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
833857
sh_test(
834858
name = "user_test",
835859
timeout = "short",
@@ -885,8 +909,10 @@ EOF
885909
# For example, if the network connection to the remote executor fails it shouldn't be displayed as
886910
# a test error.
887911
function test_display_non_testerrors() {
912+
add_rules_shell "MODULE.bazel"
888913
mkdir -p a
889914
cat > a/BUILD <<'EOF'
915+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
890916
sh_test(
891917
name = "test",
892918
timeout = "short",
@@ -1221,7 +1247,7 @@ EOF
12211247

12221248
function test_nobuild_runfile_links() {
12231249
mkdir data && echo "hello" > data/hello && echo "world" > data/world
1224-
1250+
add_rules_shell "MODULE.bazel"
12251251
cat > test.sh <<'EOF'
12261252
#!/bin/bash
12271253
set -e
@@ -1231,6 +1257,8 @@ exit 0
12311257
EOF
12321258
chmod 755 test.sh
12331259
cat > BUILD <<'EOF'
1260+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
1261+
12341262
filegroup(
12351263
name = "runfiles",
12361264
srcs = ["data/hello", "data/world"],
@@ -2043,13 +2071,15 @@ EOF
20432071
}
20442072

20452073
function setup_exclusive_test_case() {
2074+
add_rules_shell "MODULE.bazel"
20462075
mkdir -p a
20472076
cat > a/success.sh <<'EOF'
20482077
#!/bin/sh
20492078
exit 0
20502079
EOF
20512080
chmod 755 a/success.sh
20522081
cat > a/BUILD <<'EOF'
2082+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
20532083
sh_test(
20542084
name = "success_test",
20552085
srcs = ["success.sh"],
@@ -2125,6 +2155,7 @@ function test_exclusive_test_wont_remote_exec() {
21252155
# runfiles. The error we would see here without the flag would be "Cannot find
21262156
# runfiles". See #4685.
21272157
function test_java_rbe_coverage_produces_report() {
2158+
add_rules_java "MODULE.bazel"
21282159
mkdir -p java/factorial
21292160

21302161
JAVA_TOOLS_ZIP="released"
@@ -2133,6 +2164,9 @@ function test_java_rbe_coverage_produces_report() {
21332164
cd java/factorial
21342165

21352166
cat > BUILD <<'EOF'
2167+
load("@rules_java//java:java_library.bzl", "java_library")
2168+
load("@rules_java//java:java_test.bzl", "java_test")
2169+
21362170
java_library(
21372171
name = "fact",
21382172
srcs = ["Factorial.java"],
@@ -2412,10 +2446,14 @@ function test_cc_rbe_coverage_produces_report() {
24122446
# Check to see if intermediate files are supported, otherwise skip.
24132447
gcov --help | grep "\-i," || return 0
24142448

2449+
add_rules_cc "MODULE.bazel"
24152450
local test_dir="a/cc/coverage_test"
24162451
mkdir -p $test_dir
24172452

24182453
cat > "$test_dir"/BUILD <<'EOF'
2454+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
2455+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
2456+
24192457
package(default_visibility = ["//visibility:public"])
24202458
24212459
cc_library(
@@ -2547,10 +2585,15 @@ function test_cc_rbe_coverage_produces_report_with_llvm() {
25472585
return 0
25482586
fi
25492587

2588+
add_rules_cc "MODULE.bazel"
25502589
local test_dir="a/cc/coverage_test"
25512590
mkdir -p $test_dir
25522591

25532592
cat > "$test_dir"/BUILD <<'EOF'
2593+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
2594+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
2595+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
2596+
25542597
package(default_visibility = ["//visibility:public"])
25552598
25562599
cc_library(
@@ -2681,8 +2724,11 @@ EOF
26812724
}
26822725

26832726
function test_async_upload_works_for_flaky_tests() {
2727+
add_rules_shell "MODULE.bazel"
26842728
mkdir -p a
26852729
cat > a/BUILD <<EOF
2730+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
2731+
26862732
sh_test(
26872733
name = "test",
26882734
srcs = ["test.sh"],
@@ -2763,8 +2809,10 @@ function test_local_test_execution_with_disk_cache() {
27632809
# considered stale on a cache hit.
27642810
# Regression test for https://github.com/bazelbuild/bazel/issues/14426.
27652811

2812+
add_rules_shell "MODULE.bazel"
27662813
mkdir -p a
27672814
cat > a/BUILD <<EOF
2815+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
27682816
sh_test(
27692817
name = 'test',
27702818
srcs = ['test.sh'],
@@ -3021,12 +3069,14 @@ local_repository(
30213069
path = "other_repo",
30223070
)
30233071
EOF
3072+
add_rules_cc "MODULE.bazel"
30243073

30253074
mkdir -p other_repo
30263075
touch other_repo/REPO.bazel
30273076

30283077
mkdir -p other_repo/lib
30293078
cat > other_repo/lib/BUILD <<'EOF'
3079+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
30303080
cc_library(
30313081
name = "lib",
30323082
srcs = ["lib.cpp"],
@@ -3046,6 +3096,7 @@ EOF
30463096

30473097
mkdir -p other_repo/test
30483098
cat > other_repo/test/BUILD <<'EOF'
3099+
load("@rules_cc//cc:cc_test.bzl", "cc_test")
30493100
cc_test(
30503101
name = "test",
30513102
srcs = ["test.cpp"],
@@ -3185,6 +3236,7 @@ local_repository(
31853236
path = "other_repo",
31863237
)
31873238
EOF
3239+
add_rules_cc "MODULE.bazel"
31883240

31893241
mkdir -p $repo
31903242
touch $repo/REPO.bazel
@@ -3193,6 +3245,9 @@ EOF
31933245
# Use a comma in the target name as that is known to be problematic whith -Wl,
31943246
# which is commonly used to pass rpaths to the linker.
31953247
cat > $repo/lib/BUILD <<'EOF'
3248+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
3249+
load("@rules_cc//cc:cc_import.bzl", "cc_import")
3250+
31963251
cc_binary(
31973252
name = "l,ib",
31983253
srcs = ["lib.cpp"],
@@ -3219,6 +3274,8 @@ EOF
32193274

32203275
mkdir -p $repo/pkg
32213276
cat > $repo/pkg/BUILD <<'EOF'
3277+
load("@rules_cc//cc:cc_binary.bzl", "cc_binary")
3278+
32223279
cc_binary(
32233280
name = "tool",
32243281
srcs = ["tool.cpp"],
@@ -3275,7 +3332,9 @@ function test_external_cc_binary_tool_with_dynamic_deps_sibling_repository_layou
32753332
}
32763333

32773334
function test_shard_status_file_checked_remote_download_minimal() {
3335+
add_rules_shell "MODULE.bazel"
32783336
cat <<'EOF' > BUILD
3337+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
32793338
sh_test(
32803339
name = 'x',
32813340
srcs = ['x.sh'],
@@ -3301,7 +3360,9 @@ EOF
33013360
}
33023361

33033362
function test_premature_exit_file_checked_remote_download_minimal() {
3363+
add_rules_shell "MODULE.bazel"
33043364
cat <<'EOF' > BUILD
3365+
load("@rules_shell//shell:sh_test.bzl", "sh_test")
33053366
sh_test(
33063367
name = 'x',
33073368
srcs = ['x.sh'],
@@ -3555,6 +3616,7 @@ EOF
35553616
}
35563617

35573618
function setup_inlined_outputs() {
3619+
add_rules_shell "MODULE.bazel"
35583620
mkdir -p a
35593621
cat > a/input.txt <<'EOF'
35603622
input
@@ -3595,6 +3657,7 @@ my_rule = rule(
35953657
EOF
35963658
cat > a/BUILD <<'EOF'
35973659
load("//a:defs.bzl", "my_rule")
3660+
load("@rules_shell//shell:sh_binary.bzl", "sh_binary")
35983661
35993662
my_rule(
36003663
name = "my_rule",

0 commit comments

Comments
 (0)
Please sign in to comment.