Skip to content

Commit a353cb0

Browse files
authored
Rollup merge of #113234 - jyn514:revert-python-test-args, r=clubby789
Don't pass --test-args to `python -m unitest` The args for unittest and cargo test are mutually incompatible. Suggest that people use `python -m unittest ...` manually instead. This also changes `bootstrap_test.py` to be easier to run standalone; see the commit for details. r? `@clubby789` cc #112281 (comment)
2 parents fda22ef + 8537200 commit a353cb0

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

src/bootstrap/bootstrap_test.py

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Bootstrap tests
22
3-
Run these with `x test bootstrap`, or `python -m unittest bootstrap_test.py`."""
3+
Run these with `x test bootstrap`, or `python -m unittest src/bootstrap/bootstrap_test.py`."""
44

55
from __future__ import absolute_import, division, print_function
66
import os
@@ -12,6 +12,10 @@
1212

1313
from shutil import rmtree
1414

15+
# Allow running this from the top-level directory.
16+
bootstrap_dir = os.path.dirname(os.path.abspath(__file__))
17+
# For the import below, have Python search in src/bootstrap first.
18+
sys.path.insert(0, bootstrap_dir)
1519
import bootstrap
1620
import configure
1721

@@ -131,8 +135,13 @@ def build_args(self, configure_args=[], args=[], env={}):
131135

132136
parsed = bootstrap.parse_args(args)
133137
build = serialize_and_parse(configure_args, parsed)
134-
build.build_dir = os.environ["BUILD_DIR"]
135-
build.build = os.environ["BUILD_PLATFORM"]
138+
# Make these optional so that `python -m unittest` works when run manually.
139+
build_dir = os.environ.get("BUILD_DIR")
140+
if build_dir is not None:
141+
build.build_dir = build_dir
142+
build_platform = os.environ.get("BUILD_PLATFORM")
143+
if build_platform is not None:
144+
build.build = build_platform
136145
return build.build_bootstrap_cmd(env), env
137146

138147
def test_cargoflags(self):

src/bootstrap/test.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -2682,8 +2682,9 @@ impl Step for Bootstrap {
26822682
.args(["-m", "unittest", "bootstrap_test.py"])
26832683
.env("BUILD_DIR", &builder.out)
26842684
.env("BUILD_PLATFORM", &builder.build.build.triple)
2685-
.current_dir(builder.src.join("src/bootstrap/"))
2686-
.args(builder.config.test_args());
2685+
.current_dir(builder.src.join("src/bootstrap/"));
2686+
// NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
2687+
// Use `python -m unittest` manually if you want to pass arguments.
26872688
try_run(builder, &mut check_bootstrap).unwrap();
26882689

26892690
let host = builder.config.build;

0 commit comments

Comments
 (0)