Skip to content

Commit 172cd92

Browse files
committed
Merge bitcoin#28862: lint: Report all lint errors instead of early exit
fa01f88 ci: Add missing COPY for ./test/lint/test_runner (MarcoFalke) faff3e3 lint: Report all lint errors instead of early exit (MarcoFalke) Pull request description: `all-lint.py` currently collects all failures. However, the `06_script.sh` does not, since July this year (bitcoin#28103 (comment)). Fix this by printing all failures before exiting. Can be tested by modifying (for example) two subtrees in the same commit and then running the linters. ACKs for top commit: kevkevinpal: ACK [fa01f88](bitcoin@fa01f88) TheCharlatan: lgtm ACK fa01f88 Tree-SHA512: c0f3110f2907d87e29c755e3b77a67dfae1f8a25833fe6ef8f2f2c58cfecf1aa46f1a20881576b62252b04930140a9e416c78b4edba0780d3c4fa7aaebabba81
2 parents a238356 + fa01f88 commit 172cd92

File tree

3 files changed

+59
-12
lines changed

3 files changed

+59
-12
lines changed

ci/lint/06_script.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,7 @@ else
2323
fi
2424
export COMMIT_RANGE
2525

26-
# This only checks that the trees are pure subtrees, it is not doing a full
27-
# check with -r to not have to fetch all the remotes.
28-
test/lint/git-subtree-check.sh src/crypto/ctaes
29-
test/lint/git-subtree-check.sh src/secp256k1
30-
test/lint/git-subtree-check.sh src/minisketch
31-
test/lint/git-subtree-check.sh src/leveldb
32-
test/lint/git-subtree-check.sh src/crc32c
3326
RUST_BACKTRACE=1 "${LINT_RUNNER_PATH}/test_runner"
34-
test/lint/check-doc.py
35-
test/lint/all-lint.py
3627

3728
if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ "$CIRRUS_PR" = "" ] ; then
3829
# Sanity check only the last few commits to get notified of missing sigs,

ci/lint_imagefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ ENV LC_ALL=C.UTF-8
1212
COPY ./.python-version /.python-version
1313
COPY ./ci/lint/container-entrypoint.sh /entrypoint.sh
1414
COPY ./ci/lint/04_install.sh /install.sh
15+
COPY ./test/lint/test_runner /test/lint/test_runner
1516

1617
RUN /install.sh && \
1718
echo 'alias lint="./ci/lint/06_script.sh"' >> ~/.bashrc && \

test/lint/test_runner/src/main.rs

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ use std::path::PathBuf;
77
use std::process::Command;
88
use std::process::ExitCode;
99

10-
use String as LintError;
10+
type LintError = String;
11+
type LintResult = Result<(), LintError>;
12+
type LintFn = fn() -> LintResult;
1113

1214
/// Return the git command
1315
fn git() -> Command {
@@ -31,7 +33,31 @@ fn get_git_root() -> String {
3133
check_output(git().args(["rev-parse", "--show-toplevel"])).unwrap()
3234
}
3335

34-
fn lint_std_filesystem() -> Result<(), LintError> {
36+
fn lint_subtree() -> LintResult {
37+
// This only checks that the trees are pure subtrees, it is not doing a full
38+
// check with -r to not have to fetch all the remotes.
39+
let mut good = true;
40+
for subtree in [
41+
"src/crypto/ctaes",
42+
"src/secp256k1",
43+
"src/minisketch",
44+
"src/leveldb",
45+
"src/crc32c",
46+
] {
47+
good &= Command::new("test/lint/git-subtree-check.sh")
48+
.arg(subtree)
49+
.status()
50+
.expect("command_error")
51+
.success();
52+
}
53+
if good {
54+
Ok(())
55+
} else {
56+
Err("".to_string())
57+
}
58+
}
59+
60+
fn lint_std_filesystem() -> LintResult {
3561
let found = git()
3662
.args([
3763
"grep",
@@ -55,8 +81,37 @@ fs:: namespace, which has unsafe filesystem functions marked as deleted.
5581
}
5682
}
5783

84+
fn lint_doc() -> LintResult {
85+
if Command::new("test/lint/check-doc.py")
86+
.status()
87+
.expect("command error")
88+
.success()
89+
{
90+
Ok(())
91+
} else {
92+
Err("".to_string())
93+
}
94+
}
95+
96+
fn lint_all() -> LintResult {
97+
if Command::new("test/lint/all-lint.py")
98+
.status()
99+
.expect("command error")
100+
.success()
101+
{
102+
Ok(())
103+
} else {
104+
Err("".to_string())
105+
}
106+
}
107+
58108
fn main() -> ExitCode {
59-
let test_list = [("std::filesystem check", lint_std_filesystem)];
109+
let test_list: Vec<(&str, LintFn)> = vec![
110+
("subtree check", lint_subtree),
111+
("std::filesystem check", lint_std_filesystem),
112+
("-help=1 documentation check", lint_doc),
113+
("all-lint.py script", lint_all),
114+
];
60115

61116
let git_root = PathBuf::from(get_git_root());
62117

0 commit comments

Comments
 (0)