crosvm/tools/fmt
Dennis Kempin a5b5e4b9a6 Enable rustfmt nightly in container and CI
This enables nightly rustfmt features in CI so we can keep a consistent
imports style.

The resulting formatting changes are in the follow-up CL and will
need to submit together.

This change also uncovered a bug from a previous commit that caused only
the first command in a series to be waited for. Formatting issues would
not be reported by the tool. The bug is fixed as part of this CL.

BUG=b:302055317
TEST=dev_container presubmit format --no-delta

Change-Id: I5d50609cc89d7e78bce66db120737a302f5c57e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4950268
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-11-29 18:41:29 +00:00

39 lines
777 B
Python
Executable file

#!/usr/bin/env python3
# Copyright 2022 The ChromiumOS Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Run `rustfmt` on all Rust code contained in the crosvm workspace, including
# all commmon/* crates as well.
#
# Usage:
#
# $ tools/fmt
#
# To print a diff and exit 1 if code is not formatted, but without changing any
# files, use:
#
# $ tools/fmt --check
#
from pathlib import Path
import sys
from impl.common import (
CROSVM_ROOT,
run_main,
cmd,
chdir,
)
def main(check: bool = False):
chdir(CROSVM_ROOT)
cmd(
Path(sys.executable),
"./tools/presubmit format",
"--fix" if not check else None,
).fg()
if __name__ == "__main__":
run_main(main)