mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-28 01:16:50 +00:00
health-check: Add check for newline at ends of files
Fixes a couple of files that were missing them. BUG=b:242605601 TEST=./tools/health-check --fix Change-Id: I620d6a939cb824e014002152584aacfc5dfdf7e8 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3835648 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Dennis Kempin <denniskempin@google.com> Commit-Queue: Dennis Kempin <denniskempin@google.com>
This commit is contained in:
parent
38b9268cb8
commit
7a4d4d6b2a
14 changed files with 42 additions and 22 deletions
|
@ -52,4 +52,4 @@ runner = "wine64"
|
||||||
[env]
|
[env]
|
||||||
PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf = "/usr/arm-linux-gnueabihf"
|
PKG_CONFIG_SYSROOT_DIR_armv7-unknown-linux-gnueabihf = "/usr/arm-linux-gnueabihf"
|
||||||
PKG_CONFIG_SYSROOT_DIR_aarch64-unknown-linux-gnu = "/usr/aarch64_linux_gnu"
|
PKG_CONFIG_SYSROOT_DIR_aarch64-unknown-linux-gnu = "/usr/aarch64_linux_gnu"
|
||||||
PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-gnu = "/usr/x86_64-w64-mingw32"
|
PKG_CONFIG_SYSROOT_DIR_x86_64-pc-windows-gnu = "/usr/x86_64-w64-mingw32"
|
||||||
|
|
|
@ -72,4 +72,4 @@
|
||||||
</request>
|
</request>
|
||||||
</interface>
|
</interface>
|
||||||
|
|
||||||
</protocol>
|
</protocol>
|
||||||
|
|
|
@ -5,4 +5,4 @@
|
||||||
#include <X11/Xlib.h>
|
#include <X11/Xlib.h>
|
||||||
#include <X11/Xutil.h>
|
#include <X11/Xutil.h>
|
||||||
#include <X11/extensions/XShm.h>
|
#include <X11/extensions/XShm.h>
|
||||||
#include <X11/keysymdef.h>
|
#include <X11/keysymdef.h>
|
||||||
|
|
|
@ -24,4 +24,4 @@ wmi = { version = "^0.9" }
|
||||||
|
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
protoc-rust = "2.24"
|
protoc-rust = "2.24"
|
||||||
|
|
|
@ -100,4 +100,4 @@ message EmulatorChildProcessExitDetails {
|
||||||
|
|
||||||
message EmulatorDllDetails {
|
message EmulatorDllDetails {
|
||||||
optional string dll_base_name = 1;
|
optional string dll_base_name = 1;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,4 +58,4 @@ utimensat: 1
|
||||||
prctl: arg0 == PR_SET_NAME || arg0 == PR_SET_SECUREBITS || arg0 == PR_GET_SECUREBITS
|
prctl: arg0 == PR_SET_NAME || arg0 == PR_SET_SECUREBITS || arg0 == PR_GET_SECUREBITS
|
||||||
capget: 1
|
capget: 1
|
||||||
capset: 1
|
capset: 1
|
||||||
unshare: 1
|
unshare: 1
|
||||||
|
|
|
@ -10,4 +10,4 @@
|
||||||
@include /usr/share/policy/crosvm/serial.policy
|
@include /usr/share/policy/crosvm/serial.policy
|
||||||
|
|
||||||
# From vhost_user.policy.
|
# From vhost_user.policy.
|
||||||
lseek: arg2 == SEEK_END
|
lseek: arg2 == SEEK_END
|
||||||
|
|
|
@ -11,4 +11,4 @@
|
||||||
|
|
||||||
# From vvu.policy
|
# From vvu.policy
|
||||||
pread64: 1
|
pread64: 1
|
||||||
pwrite64: 1
|
pwrite64: 1
|
||||||
|
|
|
@ -11,4 +11,4 @@ getdents64: 1
|
||||||
ioctl: arg1 == SIOCGIFFLAGS || arg1 == SIOCSIFFLAGS || arg1 == TCGETS
|
ioctl: arg1 == SIOCGIFFLAGS || arg1 == SIOCSIFFLAGS || arg1 == TCGETS
|
||||||
prctl: arg0 == PR_SET_NAME
|
prctl: arg0 == PR_SET_NAME
|
||||||
socket: arg0 == AF_UNIX
|
socket: arg0 == AF_UNIX
|
||||||
socketpair: 1
|
socketpair: 1
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
# Use of this source code is governed by a BSD-style license that can be
|
# Use of this source code is governed by a BSD-style license that can be
|
||||||
# found in the LICENSE file.
|
# found in the LICENSE file.
|
||||||
|
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
@ -10,15 +11,7 @@ from pathlib import Path
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
from impl.check_code_hygiene import has_crlf_line_endings
|
from impl.check_code_hygiene import has_crlf_line_endings
|
||||||
from impl.common import (
|
from impl.common import CROSVM_ROOT, argh, chdir, cmd, cwd_context, parallel, run_main
|
||||||
CROSVM_ROOT,
|
|
||||||
argh,
|
|
||||||
chdir,
|
|
||||||
cmd,
|
|
||||||
cwd_context,
|
|
||||||
parallel,
|
|
||||||
run_main,
|
|
||||||
)
|
|
||||||
from impl.health_check import Check, CheckContext, run_checks
|
from impl.health_check import Check, CheckContext, run_checks
|
||||||
|
|
||||||
|
|
||||||
|
@ -146,6 +139,24 @@ def check_infra_tests(context: CheckContext):
|
||||||
recipes("test run --py3-only").fg(quiet=True)
|
recipes("test run --py3-only").fg(quiet=True)
|
||||||
|
|
||||||
|
|
||||||
|
def check_file_ends_with_newline(context: CheckContext):
|
||||||
|
"Checks if files end with a newline."
|
||||||
|
for file_path in context.modified_files:
|
||||||
|
with file_path.open("rb") as file:
|
||||||
|
# Skip empty files
|
||||||
|
file.seek(0, os.SEEK_END)
|
||||||
|
if file.tell() == 0:
|
||||||
|
continue
|
||||||
|
# Check last byte of the file
|
||||||
|
file.seek(-1, os.SEEK_END)
|
||||||
|
file_end = file.read(1)
|
||||||
|
if file_end.decode("utf-8") != "\n":
|
||||||
|
if context.fix:
|
||||||
|
file_path.write_text(file_path.read_text() + "\n")
|
||||||
|
else:
|
||||||
|
raise Exception(f"File does not end with a newline {file_path}")
|
||||||
|
|
||||||
|
|
||||||
# List of all checks and on which files they should run.
|
# List of all checks and on which files they should run.
|
||||||
CHECKS: List[Check] = [
|
CHECKS: List[Check] = [
|
||||||
Check(
|
Check(
|
||||||
|
@ -202,6 +213,10 @@ CHECKS: List[Check] = [
|
||||||
],
|
],
|
||||||
can_fix=True,
|
can_fix=True,
|
||||||
),
|
),
|
||||||
|
Check(
|
||||||
|
check_file_ends_with_newline,
|
||||||
|
exclude=["**.h264", "**.vp8", "**.bin", "**.png", "**.min.js", "infra/**.json"],
|
||||||
|
),
|
||||||
Check(check_crlf_line_endings),
|
Check(check_crlf_line_endings),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -573,7 +573,10 @@ def add_verbose_args(parser: argparse.ArgumentParser):
|
||||||
|
|
||||||
|
|
||||||
def all_tracked_files():
|
def all_tracked_files():
|
||||||
return (Path(f) for f in cmd("git ls-files").lines())
|
for line in cmd("git ls-files").lines():
|
||||||
|
file = Path(line)
|
||||||
|
if file.is_file():
|
||||||
|
yield file
|
||||||
|
|
||||||
|
|
||||||
def find_source_files(extension: str, ignore: List[str] = []):
|
def find_source_files(extension: str, ignore: List[str] = []):
|
||||||
|
|
|
@ -69,7 +69,9 @@ def list_file_diff():
|
||||||
if upstream:
|
if upstream:
|
||||||
for line in git("diff --name-status", upstream).lines():
|
for line in git("diff --name-status", upstream).lines():
|
||||||
parts = line.split("\t", 1)
|
parts = line.split("\t", 1)
|
||||||
yield (parts[0].strip(), Path(parts[1].strip()))
|
file = Path(parts[1].strip())
|
||||||
|
if file.is_file():
|
||||||
|
yield (parts[0].strip(), file)
|
||||||
else:
|
else:
|
||||||
print("WARNING: Not tracking a branch. Checking all files.")
|
print("WARNING: Not tracking a branch. Checking all files.")
|
||||||
for file in all_tracked_files():
|
for file in all_tracked_files():
|
||||||
|
|
|
@ -6,4 +6,4 @@ edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
|
@ -14,4 +14,4 @@ wio = "*"
|
||||||
sync = { path = "../common/sync" }
|
sync = { path = "../common/sync" }
|
||||||
thiserror = "*"
|
thiserror = "*"
|
||||||
metrics = { path = "../metrics"}
|
metrics = { path = "../metrics"}
|
||||||
once_cell = "1.7.2"
|
once_cell = "1.7.2"
|
||||||
|
|
Loading…
Reference in a new issue