Skip to content

Commit 1e7f037

Browse files
committed
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
1 parent 24e67d5 commit 1e7f037

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

src/bootstrap/bootstrap.py

+2
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,8 @@ def bootstrap(args):
10461046
if not using_default_path or os.path.exists(toml_path):
10471047
with open(toml_path) as config:
10481048
config_toml = config.read()
1049+
else:
1050+
config_toml = ''
10491051

10501052
profile = RustBuild.get_toml_static(config_toml, 'profile')
10511053
if profile is not None:

src/bootstrap/bootstrap_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def build_args(self, configure_args=[], args=[], env={}):
132132
parsed = bootstrap.parse_args(args)
133133
build = serialize_and_parse(configure_args, parsed)
134134
build.build_dir = os.environ["BUILD_DIR"]
135+
build.build = os.environ["BUILD_PLATFORM"]
135136
return build.build_bootstrap_cmd(env), env
136137

137138
def test_cargoflags(self):

src/bootstrap/configure.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,9 @@ def parse_example_config(known_args, config):
400400
targets = {}
401401
top_level_keys = []
402402

403-
for line in open(rust_dir + '/config.example.toml').read().split("\n"):
403+
with open(rust_dir + '/config.example.toml') as example_config:
404+
example_lines = example_config.read().split("\n")
405+
for line in example_lines:
404406
if cur_section is None:
405407
if line.count('=') == 1:
406408
top_level_key = line.split('=')[0]

src/bootstrap/test.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2667,6 +2667,7 @@ impl Step for Bootstrap {
26672667
check_bootstrap
26682668
.args(["-m", "unittest", "bootstrap_test.py"])
26692669
.env("BUILD_DIR", &builder.out)
2670+
.env("BUILD_PLATFORM", &builder.build.build.triple)
26702671
.current_dir(builder.src.join("src/bootstrap/"))
26712672
.args(builder.config.test_args());
26722673
try_run(builder, &mut check_bootstrap).unwrap();

0 commit comments

Comments
 (0)