test_runner: Parallelize building of common/ crates

Each of these is a separate workspace and can be built in
parallel.

BUG=b:195126527
TEST=./tools/run_tests

Change-Id: I9ad61b5d5d83903fda36c948ba470bba8f608d46
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248128
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
This commit is contained in:
Dennis Kempin 2021-10-27 10:53:16 -07:00 committed by Commit Bot
parent 85d5655160
commit df7d744fec

View file

@ -203,6 +203,17 @@ def cargo_build_executables(
yield from cargo("test", cwd, ["--no-run", *flags], env) yield from cargo("test", cwd, ["--no-run", *flags], env)
def build_common_crate(build_env: dict[str, str], crate_name: str):
print(f"Building tests for: common/{crate_name}")
return list(
cargo_build_executables(
[],
env=build_env,
cwd=COMMON_ROOT / crate_name,
)
)
def build_all_binaries(target: TestTarget, target_arch: Arch): def build_all_binaries(target: TestTarget, target_arch: Arch):
"""Discover all crates and build them.""" """Discover all crates and build them."""
build_env = os.environ.copy() build_env = os.environ.copy()
@ -219,15 +230,17 @@ def build_all_binaries(target: TestTarget, target_arch: Arch):
main_crates, env=build_env, features=set(["all-linux"]) main_crates, env=build_env, features=set(["all-linux"])
) )
for crate in list_common_crates(): common_crates = [
if not should_build_crate(crate, target_arch): crate
continue for crate in list_common_crates()
print(f"Building tests for: common/{crate}") if should_build_crate(crate, target_arch)
yield from cargo_build_executables( ]
[],
env=build_env, with Pool(PARALLELISM) as pool:
cwd=COMMON_ROOT / crate, for executables in pool.imap(
) functools.partial(build_common_crate, build_env), common_crates
):
yield from executables
def execute_test(target: TestTarget, executable: Executable): def execute_test(target: TestTarget, executable: Executable):