crosvm/tools/clippy
Anton Romanov 24a226169d Run some win64 tests with wine as part of presubmit
docker container size increases to ~4.7-8 Gb

TEST=./dev_container --hermetic ./tools/presubmit
BUG=none

Change-Id: I49dc03182f6ac5c29e0174618cc3864e073a2eb8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3499264
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
2022-04-06 19:45:49 +00:00

62 lines
1.7 KiB
Python
Executable file

#!/usr/bin/env python3
# Copyright 2019 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# To check for violations:
# $ ./tools/clippy
#
# To fix violations where possible:
# $ ./tools/clippy --fix
import os
import sys
sys.path.append(os.path.join(sys.path[0], "impl"))
from impl.common import CROSVM_ROOT, cwd, run_main, cmd, chdir
from impl.test_runner import get_workspace_excludes
clippy = cmd("cargo clippy")
if os.name == "posix":
EXCLUDED_CRATES: list[str] = []
EXCLUDED_CRATES_ARGS: list[str] = []
FEATURES: str = "--features=all-linux"
elif os.name == "nt":
EXCLUDED_CRATES: list[str] = list(get_workspace_excludes("win64"))
EXCLUDED_CRATES_ARGS: list[str] = [f"--exclude={crate}" for crate in EXCLUDED_CRATES]
FEATURES: str = ""
else:
raise Exception(f"Unsupported build target: {os.name}")
def is_crate_excluded(crate: str) -> bool:
return crate in EXCLUDED_CRATES
def main(fix: bool = False):
chdir(CROSVM_ROOT)
# Note: Clippy checks are configured in .cargo/config.toml
common_args = [
"--fix" if fix else None,
"--all-targets",
"--",
"-Dwarnings",
]
print("Clippy crosvm workspace")
clippy("--workspace", FEATURES, *EXCLUDED_CRATES_ARGS, *common_args).fg()
for crate in CROSVM_ROOT.glob("common/*/Cargo.toml"):
if not is_crate_excluded(crate.parent.name):
print("Clippy", crate.parent.relative_to(CROSVM_ROOT))
with cwd(crate.parent):
clippy("--all-features", *common_args).fg()
else:
print("Skipping crate", crate.parent.relative_to(CROSVM_ROOT))
run_main(main)