about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjyn <github@jyn.dev>2023-06-25 10:01:04 -0500
committerjyn <github@jyn.dev>2023-06-25 10:01:04 -0500
commit1e7f03718b3e1c19e59afff518d80d3717b785b9 (patch)
treea105ba6a2782c2d7831456ef759595fd9a3cd820
parent24e67d51a0fbf20910e19045e038fe646e5b0910 (diff)
downloadrust-1e7f03718b3e1c19e59afff518d80d3717b785b9.tar.gz
rust-1e7f03718b3e1c19e59afff518d80d3717b785b9.zip
fix some bugs
- fix tests when `--build` is set
- don't leak `config.example.toml` fd
- don't crash if `config.toml` doesn't exist yet
-rw-r--r--src/bootstrap/bootstrap.py2
-rw-r--r--src/bootstrap/bootstrap_test.py1
-rwxr-xr-xsrc/bootstrap/configure.py4
-rw-r--r--src/bootstrap/test.rs1
4 files changed, 7 insertions, 1 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index 3dae37ca350..53a762cd0a8 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -1046,6 +1046,8 @@ def bootstrap(args):
     if not using_default_path or os.path.exists(toml_path):
         with open(toml_path) as config:
             config_toml = config.read()
+    else:
+        config_toml = ''
 
     profile = RustBuild.get_toml_static(config_toml, 'profile')
     if profile is not None:
diff --git a/src/bootstrap/bootstrap_test.py b/src/bootstrap/bootstrap_test.py
index 167b11d421e..815b32eb991 100644
--- a/src/bootstrap/bootstrap_test.py
+++ b/src/bootstrap/bootstrap_test.py
@@ -132,6 +132,7 @@ class BuildBootstrap(unittest.TestCase):
         parsed = bootstrap.parse_args(args)
         build = serialize_and_parse(configure_args, parsed)
         build.build_dir = os.environ["BUILD_DIR"]
+        build.build = os.environ["BUILD_PLATFORM"]
         return build.build_bootstrap_cmd(env), env
 
     def test_cargoflags(self):
diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
index 76a153b60a3..a5a1385dc0d 100755
--- a/src/bootstrap/configure.py
+++ b/src/bootstrap/configure.py
@@ -400,7 +400,9 @@ def parse_example_config(known_args, config):
     targets = {}
     top_level_keys = []
 
-    for line in open(rust_dir + '/config.example.toml').read().split("\n"):
+    with open(rust_dir + '/config.example.toml') as example_config:
+        example_lines = example_config.read().split("\n")
+    for line in example_lines:
         if cur_section is None:
             if line.count('=') == 1:
                 top_level_key = line.split('=')[0]
diff --git a/src/bootstrap/test.rs b/src/bootstrap/test.rs
index 9f0f24e0f7b..bdc6b4de6cd 100644
--- a/src/bootstrap/test.rs
+++ b/src/bootstrap/test.rs
@@ -2667,6 +2667,7 @@ impl Step for Bootstrap {
         check_bootstrap
             .args(["-m", "unittest", "bootstrap_test.py"])
             .env("BUILD_DIR", &builder.out)
+            .env("BUILD_PLATFORM", &builder.build.build.triple)
             .current_dir(builder.src.join("src/bootstrap/"))
             .args(builder.config.test_args());
         try_run(builder, &mut check_bootstrap).unwrap();