@@ -249,102 +249,3 @@ def test_warnings(self):
249249
250250 _ , env = self .build_args (configure_args , args = ["--warnings=deny" ])
251251 self .assertTrue ("-Dwarnings" in env ["RUSTFLAGS" ])
252-
253-
254- class TestProfileOverride (unittest .TestCase ):
255- @patch ("os.path.exists" )
256- @patch ("bootstrap.RustBuild.get_toml_static" )
257- def test_profile_none_with_non_git_source (self , mock_get_toml_static , mock_exists ):
258- mock_exists .return_value = False
259- mock_get_toml_static .return_value = None
260-
261- rust_root = "/mock/rust_root"
262- config_toml = ""
263-
264- profile = bootstrap .RustBuild .get_toml_static (config_toml , "profile" )
265-
266- is_non_git_source = not os .path .exists (os .path .join (rust_root , ".git" ))
267- if profile is None and is_non_git_source :
268- profile = "dist"
269-
270- self .assertEqual (profile , "dist" )
271-
272- @patch ("os.path.exists" )
273- @patch ("bootstrap.RustBuild.get_toml_static" )
274- def test_include_path_exists (self , mock_get_toml_static , mock_exists ):
275- mock_exists .return_value = True
276- mock_get_toml_static .return_value = "dist"
277-
278- rust_root = "/mock/rust_root"
279- config_toml = "mock_config"
280-
281- profile = bootstrap .RustBuild .get_toml_static (config_toml , "profile" )
282-
283- profile_aliases = {"user" : "dist" }
284- include_file = f"config.{ profile_aliases .get (profile ) or profile } .toml"
285- include_dir = os .path .join (rust_root , "src" , "bootstrap" , "defaults" )
286- include_path = os .path .join (include_dir , include_file )
287-
288- # Assert the include_path is correctly formed
289- self .assertEqual (
290- include_path , "/mock/rust_root/src/bootstrap/defaults/config.dist.toml"
291- )
292-
293- @patch ("os.path.exists" )
294- @patch ("bootstrap.RustBuild.get_toml_static" )
295- @patch ("builtins.open" , new_callable = mock_open )
296- def test_config_toml_inclusion (self , mock_open , mock_get_toml_static , mock_exists ):
297- mock_exists .side_effect = (
298- lambda path : path
299- == "/mock/rust_root/src/bootstrap/defaults/config.dist.toml"
300- )
301- mock_get_toml_static .return_value = "dist"
302- mock_open .return_value .read .return_value = "included_toml_content"
303-
304- rust_root = "/mock/rust_root"
305- config_toml = "initial_config"
306-
307- profile = bootstrap .RustBuild .get_toml_static (config_toml , "profile" )
308-
309- profile_aliases = {"user" : "dist" }
310- include_file = f"config.{ profile_aliases .get (profile ) or profile } .toml"
311- include_dir = os .path .join (rust_root , "src" , "bootstrap" , "defaults" )
312- include_path = os .path .join (include_dir , include_file )
313-
314- with open (include_path ) as included_toml :
315- config_toml += os .linesep + included_toml .read ()
316-
317- self .assertIn ("initial_config\n included_toml_content" , config_toml )
318-
319- @patch ("os.path.exists" )
320- @patch ("bootstrap.RustBuild.get_toml_static" )
321- def test_invalid_profile_for_non_git_source (
322- self , mock_get_toml_static , mock_exists
323- ):
324- mock_exists .return_value = False
325-
326- def mock_get_toml_static_side_effect (config_toml , option ):
327- if option in ["download-ci-llvm" , "download-rustc" ]:
328- return "true"
329- return None
330-
331- mock_get_toml_static .side_effect = mock_get_toml_static_side_effect
332-
333- rust_root = "/mock/rust_root"
334- config_toml = ""
335-
336- profile = bootstrap .RustBuild .get_toml_static (config_toml , "profile" )
337- is_non_git_source = not os .path .exists (os .path .join (rust_root , ".git" ))
338- if profile is None and is_non_git_source :
339- profile = "dist"
340-
341- for option in ["download-ci-llvm" , "download-rustc" ]:
342- if bootstrap .RustBuild .get_toml_static (config_toml , option ):
343- with self .assertRaises (Exception ) as context :
344- raise Exception (
345- f"Option '{ option } ' cannot be used with non-git sources."
346- )
347- self .assertTrue (
348- f"Option '{ option } ' cannot be used with non-git sources."
349- in str (context .exception )
350- )
0 commit comments