@@ -66,23 +66,20 @@ def tearDown(self):
66
66
def testNewHttpArchive (self ):
67
67
ip , port = self ._http_server .server_address
68
68
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")' ,
74
72
'http_archive(' ,
75
73
' name = "hello_archive",' ,
76
74
' urls = ["http://%s:%s/hello-1.0.0.tar.gz"],' % (ip , port ),
77
- (
78
- ' sha256 = '
79
- '"154740b327bcfee5669ef2ce0a04bf0904227a3bfe0fee08a5aaca96ea5a601a",'
80
- ),
75
+ ' sha256 = ' ,
76
+ ' "154740b327bcfee5669ef2ce0a04bf0904227a3bfe0fee08a5aaca96ea5a601a",' ,
81
77
' strip_prefix = "hello-1.0.0",' ,
82
78
' build_file = "@//third_party:hello.BUILD",' ,
83
79
')' ,
84
80
]
85
81
build_file = [
82
+ 'load("@rules_python//python:py_library.bzl", "py_library")' ,
86
83
'py_library(' ,
87
84
' name = "hello",' ,
88
85
' srcs = ["hello.py"],' ,
@@ -189,20 +186,16 @@ def testNewHttpTarWithSparseFile(self):
189
186
190
187
ip , port = self ._http_server .server_address
191
188
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")' ,
197
192
'http_archive(' ,
198
193
' name = "sparse_archive",' ,
199
194
' urls = ["http://%s:%s/sparse_archive.tar"],' % (ip , port ),
200
195
' build_file = "@//:sparse_archive.BUILD",' ,
201
196
' sha256 = ' ,
202
- (
203
- ' "a1a2b2ce4acd51a8cc1ab80adce6f134ac73e885219911a960a42000e312bb65",'
204
- ')'
205
- ),
197
+ ' "a1a2b2ce4acd51a8cc1ab80adce6f134ac73e885219911a960a42000e312bb65",' ,
198
+ ')' ,
206
199
]
207
200
self .ScratchFile ('MODULE.bazel' , rule_definition )
208
201
self .ScratchFile (
@@ -224,13 +217,12 @@ def testNewHttpTarWithSparseFile(self):
224
217
self .ScratchFile (
225
218
'BUILD' ,
226
219
[
220
+ 'load("@rules_python//python:py_test.bzl", "py_test")' ,
227
221
'py_test(' ,
228
222
' name = "test",' ,
229
223
' srcs = ["test.py"],' ,
230
- (
231
- ' args = ["$(rlocationpath @sparse_archive//:sparse_file)"],'
232
- ' data = ['
233
- ),
224
+ ' args = ["$(rlocationpath @sparse_archive//:sparse_file)"],' ,
225
+ ' data = [' ,
234
226
' "@sparse_archive//:sparse_file",' ,
235
227
' "@bazel_tools//tools/python/runfiles",' ,
236
228
' ],)' ,
@@ -260,10 +252,11 @@ def _CreatePyWritingStarlarkRule(self, print_string):
260
252
def testNewLocalRepositoryNoticesFileChangeInRepoRoot (self ):
261
253
"""Regression test for https://github.com/bazelbuild/bazel/issues/7063."""
262
254
rule_definition = [
255
+ 'bazel_dep(name = "rules_python", version = "0.40.0")' ,
256
+ 'new_local_repository = use_repo_rule(' ,
263
257
(
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")'
267
260
),
268
261
'new_local_repository(' ,
269
262
' name = "r",' ,
@@ -273,11 +266,15 @@ def testNewLocalRepositoryNoticesFileChangeInRepoRoot(self):
273
266
]
274
267
self .ScratchFile ('MODULE.bazel' , rule_definition )
275
268
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
+ )
281
278
282
279
_ , stdout , _ = self .RunBazel (['run' , '//:bin' ])
283
280
self .assertIn ('hello!' , os .linesep .join (stdout ))
@@ -294,11 +291,9 @@ def setUpOtherRepoMyRepo(self):
294
291
self .ScratchFile (
295
292
'my_repo/MODULE.bazel' ,
296
293
[
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")' ,
302
297
'local_repository(name = "other_repo", path="../other_repo")' ,
303
298
],
304
299
)
0 commit comments