@@ -256,27 +256,23 @@ class TestRustBuild(unittest.TestCase):
256
256
@patch ("os.path.exists" )
257
257
@patch ("bootstrap.RustBuild.get_toml_static" )
258
258
def test_profile_none_with_non_git_source (self , mock_get_toml_static , mock_exists ):
259
- # Mock the behavior for a non-git source
260
259
mock_exists .return_value = False
261
260
mock_get_toml_static .return_value = None
262
261
263
262
rust_root = "/mock/rust_root"
264
263
config_toml = ""
265
264
266
- # Simulate the execution of the logic
267
265
profile = bootstrap .RustBuild .get_toml_static (config_toml , "profile" )
268
266
269
267
is_non_git_source = not os .path .exists (os .path .join (rust_root , ".git" ))
270
268
if profile is None and is_non_git_source :
271
269
profile = "dist"
272
270
273
- # Assert that profile is set to "dist"
274
271
self .assertEqual (profile , "dist" )
275
272
276
273
@patch ("os.path.exists" )
277
274
@patch ("bootstrap.RustBuild.get_toml_static" )
278
275
def test_include_path_exists (self , mock_get_toml_static , mock_exists ):
279
- # Mock the behavior for a git source
280
276
mock_exists .return_value = True
281
277
mock_get_toml_static .return_value = "dist"
282
278
@@ -285,7 +281,6 @@ def test_include_path_exists(self, mock_get_toml_static, mock_exists):
285
281
286
282
profile = bootstrap .RustBuild .get_toml_static (config_toml , "profile" )
287
283
288
- # Profile alias check
289
284
profile_aliases = {"user" : "dist" }
290
285
include_file = f"config.{ profile_aliases .get (profile ) or profile } .toml"
291
286
include_dir = os .path .join (rust_root , "src" , "bootstrap" , "defaults" )
@@ -300,7 +295,6 @@ def test_include_path_exists(self, mock_get_toml_static, mock_exists):
300
295
@patch ("bootstrap.RustBuild.get_toml_static" )
301
296
@patch ("builtins.open" , new_callable = mock_open )
302
297
def test_config_toml_inclusion (self , mock_open , mock_get_toml_static , mock_exists ):
303
- # Mock the behavior for a git source and profile dist
304
298
mock_exists .side_effect = (
305
299
lambda path : path
306
300
== "/mock/rust_root/src/bootstrap/defaults/config.dist.toml"
@@ -313,7 +307,6 @@ def test_config_toml_inclusion(self, mock_open, mock_get_toml_static, mock_exist
313
307
314
308
profile = bootstrap .RustBuild .get_toml_static (config_toml , "profile" )
315
309
316
- # Profile alias check
317
310
profile_aliases = {"user" : "dist" }
318
311
include_file = f"config.{ profile_aliases .get (profile ) or profile } .toml"
319
312
include_dir = os .path .join (rust_root , "src" , "bootstrap" , "defaults" )
@@ -322,38 +315,32 @@ def test_config_toml_inclusion(self, mock_open, mock_get_toml_static, mock_exist
322
315
with open (include_path ) as included_toml :
323
316
config_toml += os .linesep + included_toml .read ()
324
317
325
- # Assert that the content of included_toml is appended correctly
326
318
self .assertIn ("initial_config\n included_toml_content" , config_toml )
327
319
328
320
@patch ("os.path.exists" )
329
321
@patch ("bootstrap.RustBuild.get_toml_static" )
330
322
def test_invalid_profile_for_non_git_source (
331
323
self , mock_get_toml_static , mock_exists
332
324
):
333
- # Mock a non-git source
334
325
mock_exists .return_value = False
335
326
336
- # Mock config to simulate presence of options
337
327
def mock_get_toml_static_side_effect (config_toml , option ):
338
328
if option in ["download-ci-llvm" , "download-rustc" ]:
339
- return "true" # Simulate the option being set in the config
329
+ return "true"
340
330
return None
341
331
342
332
mock_get_toml_static .side_effect = mock_get_toml_static_side_effect
343
333
344
334
rust_root = "/mock/rust_root"
345
335
config_toml = ""
346
336
347
- # Simulate the execution of the logic
348
337
profile = bootstrap .RustBuild .get_toml_static (config_toml , "profile" )
349
338
is_non_git_source = not os .path .exists (os .path .join (rust_root , ".git" ))
350
339
if profile is None and is_non_git_source :
351
340
profile = "dist"
352
341
353
- # Assert that non-git sources cannot use these options
354
342
for option in ["download-ci-llvm" , "download-rustc" ]:
355
343
if bootstrap .RustBuild .get_toml_static (config_toml , option ):
356
- # Now, raise the exception in the test code
357
344
with self .assertRaises (Exception ) as context :
358
345
raise Exception (
359
346
f"Option '{ option } ' cannot be used with non-git sources."
0 commit comments