Test color/verbose/warnings properly
These weren't being passed in to bootstrap consistently before; in particular `serialize_and_parse` forgot to pass them in.
This commit is contained in:
parent
c5820b50c5
commit
c7af6fb5b8
@ -466,6 +466,8 @@ class FakeArgs:
|
|||||||
self.clean = False
|
self.clean = False
|
||||||
self.verbose = False
|
self.verbose = False
|
||||||
self.json_output = False
|
self.json_output = False
|
||||||
|
self.color = 'auto'
|
||||||
|
self.warnings = 'default'
|
||||||
|
|
||||||
class RustBuild(object):
|
class RustBuild(object):
|
||||||
"""Provide all the methods required to build Rust"""
|
"""Provide all the methods required to build Rust"""
|
||||||
@ -477,9 +479,11 @@ class RustBuild(object):
|
|||||||
|
|
||||||
self.config_toml = config_toml
|
self.config_toml = config_toml
|
||||||
|
|
||||||
self.verbose = args.verbose != 0
|
|
||||||
self.clean = args.clean
|
self.clean = args.clean
|
||||||
self.json_output = args.json_output
|
self.json_output = args.json_output
|
||||||
|
self.verbose = args.verbose
|
||||||
|
self.color = args.color
|
||||||
|
self.warnings = args.warnings
|
||||||
|
|
||||||
profile = self.get_toml('profile')
|
profile = self.get_toml('profile')
|
||||||
if profile is not None:
|
if profile is not None:
|
||||||
@ -491,6 +495,10 @@ class RustBuild(object):
|
|||||||
with open(include_path) as included_toml:
|
with open(include_path) as included_toml:
|
||||||
self.config_toml += os.linesep + included_toml.read()
|
self.config_toml += os.linesep + included_toml.read()
|
||||||
|
|
||||||
|
config_verbose_count = self.get_toml('verbose', 'build')
|
||||||
|
if config_verbose_count is not None:
|
||||||
|
self.verbose = max(self.verbose, int(config_verbose_count))
|
||||||
|
|
||||||
self.use_vendored_sources = self.get_toml('vendor', 'build') == 'true'
|
self.use_vendored_sources = self.get_toml('vendor', 'build') == 'true'
|
||||||
self.use_locked_deps = self.get_toml('locked-deps', 'build') == 'true'
|
self.use_locked_deps = self.get_toml('locked-deps', 'build') == 'true'
|
||||||
|
|
||||||
@ -505,6 +513,7 @@ class RustBuild(object):
|
|||||||
|
|
||||||
self.build = args.build or self.build_triple()
|
self.build = args.build or self.build_triple()
|
||||||
|
|
||||||
|
|
||||||
def download_toolchain(self):
|
def download_toolchain(self):
|
||||||
"""Fetch the build system for Rust, written in Rust
|
"""Fetch the build system for Rust, written in Rust
|
||||||
|
|
||||||
@ -859,7 +868,7 @@ class RustBuild(object):
|
|||||||
"""
|
"""
|
||||||
return os.path.join(self.build_dir, "bootstrap", "debug", "bootstrap")
|
return os.path.join(self.build_dir, "bootstrap", "debug", "bootstrap")
|
||||||
|
|
||||||
def build_bootstrap(self, color, warnings, verbose_count):
|
def build_bootstrap(self):
|
||||||
"""Build bootstrap"""
|
"""Build bootstrap"""
|
||||||
env = os.environ.copy()
|
env = os.environ.copy()
|
||||||
if "GITHUB_ACTIONS" in env:
|
if "GITHUB_ACTIONS" in env:
|
||||||
@ -867,14 +876,14 @@ class RustBuild(object):
|
|||||||
else:
|
else:
|
||||||
print("Building bootstrap", file=sys.stderr)
|
print("Building bootstrap", file=sys.stderr)
|
||||||
|
|
||||||
args = self.build_bootstrap_cmd(env, color, warnings, verbose_count)
|
args = self.build_bootstrap_cmd(env)
|
||||||
# Run this from the source directory so cargo finds .cargo/config
|
# Run this from the source directory so cargo finds .cargo/config
|
||||||
run(args, env=env, verbose=self.verbose, cwd=self.rust_root)
|
run(args, env=env, verbose=self.verbose, cwd=self.rust_root)
|
||||||
|
|
||||||
if "GITHUB_ACTIONS" in env:
|
if "GITHUB_ACTIONS" in env:
|
||||||
print("::endgroup::")
|
print("::endgroup::")
|
||||||
|
|
||||||
def build_bootstrap_cmd(self, env, color, warnings, verbose_count):
|
def build_bootstrap_cmd(self, env):
|
||||||
"""For tests."""
|
"""For tests."""
|
||||||
build_dir = os.path.join(self.build_dir, "bootstrap")
|
build_dir = os.path.join(self.build_dir, "bootstrap")
|
||||||
if self.clean and os.path.exists(build_dir):
|
if self.clean and os.path.exists(build_dir):
|
||||||
@ -928,10 +937,10 @@ class RustBuild(object):
|
|||||||
if target_linker is not None:
|
if target_linker is not None:
|
||||||
env["RUSTFLAGS"] += " -C linker=" + target_linker
|
env["RUSTFLAGS"] += " -C linker=" + target_linker
|
||||||
env["RUSTFLAGS"] += " -Wrust_2018_idioms -Wunused_lifetimes"
|
env["RUSTFLAGS"] += " -Wrust_2018_idioms -Wunused_lifetimes"
|
||||||
if warnings == "default":
|
if self.warnings == "default":
|
||||||
deny_warnings = self.get_toml("deny-warnings", "rust") != "false"
|
deny_warnings = self.get_toml("deny-warnings", "rust") != "false"
|
||||||
else:
|
else:
|
||||||
deny_warnings = warnings == "deny"
|
deny_warnings = self.warnings == "deny"
|
||||||
if deny_warnings:
|
if deny_warnings:
|
||||||
env["RUSTFLAGS"] += " -Dwarnings"
|
env["RUSTFLAGS"] += " -Dwarnings"
|
||||||
|
|
||||||
@ -942,7 +951,7 @@ class RustBuild(object):
|
|||||||
self.cargo()))
|
self.cargo()))
|
||||||
args = [self.cargo(), "build", "--manifest-path",
|
args = [self.cargo(), "build", "--manifest-path",
|
||||||
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
|
os.path.join(self.rust_root, "src/bootstrap/Cargo.toml")]
|
||||||
args.extend("--verbose" for _ in range(verbose_count))
|
args.extend("--verbose" for _ in range(self.verbose))
|
||||||
if self.use_locked_deps:
|
if self.use_locked_deps:
|
||||||
args.append("--locked")
|
args.append("--locked")
|
||||||
if self.use_vendored_sources:
|
if self.use_vendored_sources:
|
||||||
@ -952,9 +961,9 @@ class RustBuild(object):
|
|||||||
args.append("build-metrics")
|
args.append("build-metrics")
|
||||||
if self.json_output:
|
if self.json_output:
|
||||||
args.append("--message-format=json")
|
args.append("--message-format=json")
|
||||||
if color == "always":
|
if self.color == "always":
|
||||||
args.append("--color=always")
|
args.append("--color=always")
|
||||||
elif color == "never":
|
elif self.color == "never":
|
||||||
args.append("--color=never")
|
args.append("--color=never")
|
||||||
try:
|
try:
|
||||||
args += env["CARGOFLAGS"].split()
|
args += env["CARGOFLAGS"].split()
|
||||||
@ -1049,18 +1058,13 @@ def bootstrap(args):
|
|||||||
build = RustBuild(config_toml, args)
|
build = RustBuild(config_toml, args)
|
||||||
build.check_vendored_status()
|
build.check_vendored_status()
|
||||||
|
|
||||||
verbose_count = args.verbose
|
|
||||||
config_verbose_count = build.get_toml('verbose', 'build')
|
|
||||||
if config_verbose_count is not None:
|
|
||||||
verbose_count = max(args.verbose, int(config_verbose_count))
|
|
||||||
|
|
||||||
if not os.path.exists(build.build_dir):
|
if not os.path.exists(build.build_dir):
|
||||||
os.makedirs(build.build_dir)
|
os.makedirs(build.build_dir)
|
||||||
|
|
||||||
# Fetch/build the bootstrap
|
# Fetch/build the bootstrap
|
||||||
build.download_toolchain()
|
build.download_toolchain()
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
build.build_bootstrap(args.color, args.warnings, verbose_count)
|
build.build_bootstrap()
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
|
|
||||||
# Run the bootstrap
|
# Run the bootstrap
|
||||||
|
@ -15,14 +15,13 @@ from shutil import rmtree
|
|||||||
import bootstrap
|
import bootstrap
|
||||||
import configure
|
import configure
|
||||||
|
|
||||||
def serialize_and_parse(args):
|
def serialize_and_parse(configure_args, bootstrap_args=bootstrap.FakeArgs()):
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
|
|
||||||
section_order, sections, targets = configure.parse_args(args)
|
section_order, sections, targets = configure.parse_args(configure_args)
|
||||||
buffer = StringIO()
|
buffer = StringIO()
|
||||||
configure.write_config_toml(buffer, section_order, targets, sections)
|
configure.write_config_toml(buffer, section_order, targets, sections)
|
||||||
build = bootstrap.RustBuild()
|
build = bootstrap.RustBuild(config_toml=buffer.getvalue(), args=bootstrap_args)
|
||||||
build.config_toml = buffer.getvalue()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import tomllib
|
import tomllib
|
||||||
@ -130,10 +129,10 @@ class BuildBootstrap(unittest.TestCase):
|
|||||||
env = env.copy()
|
env = env.copy()
|
||||||
env["PATH"] = os.environ["PATH"]
|
env["PATH"] = os.environ["PATH"]
|
||||||
|
|
||||||
build = serialize_and_parse(configure_args)
|
|
||||||
build.build_dir = os.environ["BUILD_DIR"]
|
|
||||||
parsed = bootstrap.parse_args(args)
|
parsed = bootstrap.parse_args(args)
|
||||||
return build.build_bootstrap_cmd(env, parsed.color, parsed.warnings, parsed.verbose), env
|
build = serialize_and_parse(configure_args, parsed)
|
||||||
|
build.build_dir = os.environ["BUILD_DIR"]
|
||||||
|
return build.build_bootstrap_cmd(env), env
|
||||||
|
|
||||||
def test_cargoflags(self):
|
def test_cargoflags(self):
|
||||||
args, _ = self.build_args(env={"CARGOFLAGS": "--timings"})
|
args, _ = self.build_args(env={"CARGOFLAGS": "--timings"})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user