aboutsummaryrefslogtreecommitdiff
path: root/test/lint
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-11-22 16:53:51 +0000
committerfanquake <fanquake@gmail.com>2023-11-22 17:00:45 +0000
commit172cd92620167cc437f6d208a20f2698f15835a9 (patch)
tree2d3bb295cfe57a89c31b84204bc0e0a7163a7165 /test/lint
parenta238356823bd261c4bbada9d9b8f9c850b6ba79e (diff)
parentfa01f884d3ac128f09bfa57ac2648a19a19d854e (diff)
Merge bitcoin/bitcoin#28862: lint: Report all lint errors instead of early exit
fa01f884d3ac128f09bfa57ac2648a19a19d854e ci: Add missing COPY for ./test/lint/test_runner (MarcoFalke) faff3e3b4604519375e122c103b156ec13eef80f 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 (https://github.com/bitcoin/bitcoin/pull/28103#discussion_r1268115806). 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](https://github.com/bitcoin/bitcoin/pull/28862/commits/fa01f884d3ac128f09bfa57ac2648a19a19d854e) TheCharlatan: lgtm ACK fa01f884d3ac128f09bfa57ac2648a19a19d854e Tree-SHA512: c0f3110f2907d87e29c755e3b77a67dfae1f8a25833fe6ef8f2f2c58cfecf1aa46f1a20881576b62252b04930140a9e416c78b4edba0780d3c4fa7aaebabba81
Diffstat (limited to 'test/lint')
-rw-r--r--test/lint/test_runner/src/main.rs61
1 files changed, 58 insertions, 3 deletions
diff --git a/test/lint/test_runner/src/main.rs b/test/lint/test_runner/src/main.rs
index b7ec9ee3b2..ce94c3b628 100644
--- a/test/lint/test_runner/src/main.rs
+++ b/test/lint/test_runner/src/main.rs
@@ -7,7 +7,9 @@ use std::path::PathBuf;
use std::process::Command;
use std::process::ExitCode;
-use String as LintError;
+type LintError = String;
+type LintResult = Result<(), LintError>;
+type LintFn = fn() -> LintResult;
/// Return the git command
fn git() -> Command {
@@ -31,7 +33,31 @@ fn get_git_root() -> String {
check_output(git().args(["rev-parse", "--show-toplevel"])).unwrap()
}
-fn lint_std_filesystem() -> Result<(), LintError> {
+fn lint_subtree() -> LintResult {
+ // This only checks that the trees are pure subtrees, it is not doing a full
+ // check with -r to not have to fetch all the remotes.
+ let mut good = true;
+ for subtree in [
+ "src/crypto/ctaes",
+ "src/secp256k1",
+ "src/minisketch",
+ "src/leveldb",
+ "src/crc32c",
+ ] {
+ good &= Command::new("test/lint/git-subtree-check.sh")
+ .arg(subtree)
+ .status()
+ .expect("command_error")
+ .success();
+ }
+ if good {
+ Ok(())
+ } else {
+ Err("".to_string())
+ }
+}
+
+fn lint_std_filesystem() -> LintResult {
let found = git()
.args([
"grep",
@@ -55,8 +81,37 @@ fs:: namespace, which has unsafe filesystem functions marked as deleted.
}
}
+fn lint_doc() -> LintResult {
+ if Command::new("test/lint/check-doc.py")
+ .status()
+ .expect("command error")
+ .success()
+ {
+ Ok(())
+ } else {
+ Err("".to_string())
+ }
+}
+
+fn lint_all() -> LintResult {
+ if Command::new("test/lint/all-lint.py")
+ .status()
+ .expect("command error")
+ .success()
+ {
+ Ok(())
+ } else {
+ Err("".to_string())
+ }
+}
+
fn main() -> ExitCode {
- let test_list = [("std::filesystem check", lint_std_filesystem)];
+ let test_list: Vec<(&str, LintFn)> = vec![
+ ("subtree check", lint_subtree),
+ ("std::filesystem check", lint_std_filesystem),
+ ("-help=1 documentation check", lint_doc),
+ ("all-lint.py script", lint_all),
+ ];
let git_root = PathBuf::from(get_git_root());