Skip to content

Commit faff3e3

Browse files
author
MarcoFalke
committed
lint: Report all lint errors instead of early exit
1 parent d232e36 commit faff3e3

File tree

2 files changed

+58
-12
lines changed

2 files changed

+58
-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,

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)