Skip to content

Don't pass --test-args to python -m unitest #113234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions src/bootstrap/bootstrap_test.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Bootstrap tests

Run these with `x test bootstrap`, or `python -m unittest bootstrap_test.py`."""
Run these with `x test bootstrap`, or `python -m unittest src/bootstrap/bootstrap_test.py`."""

from __future__ import absolute_import, division, print_function
import os
Expand All @@ -12,6 +12,10 @@

from shutil import rmtree

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

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

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"]
# Make these optional so that `python -m unittest` works when run manually.
build_dir = os.environ.get("BUILD_DIR")
if build_dir is not None:
build.build_dir = build_dir
build_platform = os.environ.get("BUILD_PLATFORM")
if build_platform is not None:
build.build = build_platform
return build.build_bootstrap_cmd(env), env

def test_cargoflags(self):
Expand Down
5 changes: 3 additions & 2 deletions src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2682,8 +2682,9 @@ impl Step for 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());
.current_dir(builder.src.join("src/bootstrap/"));
// NOTE: we intentionally don't pass test_args here because the args for unittest and cargo test are mutually incompatible.
// Use `python -m unittest` manually if you want to pass arguments.
try_run(builder, &mut check_bootstrap).unwrap();

let host = builder.config.build;
Expand Down