Skip to content

Commit ea71c0e

Browse files
committed
1 parent 8137056 commit ea71c0e

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

src/bootstrap/bootstrap_test.py

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -256,27 +256,23 @@ class TestRustBuild(unittest.TestCase):
256256
@patch("os.path.exists")
257257
@patch("bootstrap.RustBuild.get_toml_static")
258258
def test_profile_none_with_non_git_source(self, mock_get_toml_static, mock_exists):
259-
# Mock the behavior for a non-git source
260259
mock_exists.return_value = False
261260
mock_get_toml_static.return_value = None
262261

263262
rust_root = "/mock/rust_root"
264263
config_toml = ""
265264

266-
# Simulate the execution of the logic
267265
profile = bootstrap.RustBuild.get_toml_static(config_toml, "profile")
268266

269267
is_non_git_source = not os.path.exists(os.path.join(rust_root, ".git"))
270268
if profile is None and is_non_git_source:
271269
profile = "dist"
272270

273-
# Assert that profile is set to "dist"
274271
self.assertEqual(profile, "dist")
275272

276273
@patch("os.path.exists")
277274
@patch("bootstrap.RustBuild.get_toml_static")
278275
def test_include_path_exists(self, mock_get_toml_static, mock_exists):
279-
# Mock the behavior for a git source
280276
mock_exists.return_value = True
281277
mock_get_toml_static.return_value = "dist"
282278

@@ -285,7 +281,6 @@ def test_include_path_exists(self, mock_get_toml_static, mock_exists):
285281

286282
profile = bootstrap.RustBuild.get_toml_static(config_toml, "profile")
287283

288-
# Profile alias check
289284
profile_aliases = {"user": "dist"}
290285
include_file = f"config.{profile_aliases.get(profile) or profile}.toml"
291286
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):
300295
@patch("bootstrap.RustBuild.get_toml_static")
301296
@patch("builtins.open", new_callable=mock_open)
302297
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
304298
mock_exists.side_effect = (
305299
lambda path: path
306300
== "/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
313307

314308
profile = bootstrap.RustBuild.get_toml_static(config_toml, "profile")
315309

316-
# Profile alias check
317310
profile_aliases = {"user": "dist"}
318311
include_file = f"config.{profile_aliases.get(profile) or profile}.toml"
319312
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
322315
with open(include_path) as included_toml:
323316
config_toml += os.linesep + included_toml.read()
324317

325-
# Assert that the content of included_toml is appended correctly
326318
self.assertIn("initial_config\nincluded_toml_content", config_toml)
327319

328320
@patch("os.path.exists")
329321
@patch("bootstrap.RustBuild.get_toml_static")
330322
def test_invalid_profile_for_non_git_source(
331323
self, mock_get_toml_static, mock_exists
332324
):
333-
# Mock a non-git source
334325
mock_exists.return_value = False
335326

336-
# Mock config to simulate presence of options
337327
def mock_get_toml_static_side_effect(config_toml, option):
338328
if option in ["download-ci-llvm", "download-rustc"]:
339-
return "true" # Simulate the option being set in the config
329+
return "true"
340330
return None
341331

342332
mock_get_toml_static.side_effect = mock_get_toml_static_side_effect
343333

344334
rust_root = "/mock/rust_root"
345335
config_toml = ""
346336

347-
# Simulate the execution of the logic
348337
profile = bootstrap.RustBuild.get_toml_static(config_toml, "profile")
349338
is_non_git_source = not os.path.exists(os.path.join(rust_root, ".git"))
350339
if profile is None and is_non_git_source:
351340
profile = "dist"
352341

353-
# Assert that non-git sources cannot use these options
354342
for option in ["download-ci-llvm", "download-rustc"]:
355343
if bootstrap.RustBuild.get_toml_static(config_toml, option):
356-
# Now, raise the exception in the test code
357344
with self.assertRaises(Exception) as context:
358345
raise Exception(
359346
f"Option '{option}' cannot be used with non-git sources."

0 commit comments

Comments
 (0)