Skip to content

Commit ac3901e

Browse files
committed
Merge bitcoin#29228: test: Remove all-lint.py script
fa2b95c test: Remove all-lint.py script (MarcoFalke) fadb06c doc: move-only lint docs to one place (MarcoFalke) Pull request description: Seems confusing to have a test runner that calls another runner (`all-lint.py`), which calls a subset of the lint tests. Fix that by just calling this subset of lint tests in the test runner directly, and remove the now unused `all-lint.py`. To run all lint checks locally, refer to the documentation: https://github.com/bitcoin/bitcoin/blob/master/test/lint/README.md#running-locally ACKs for top commit: kevkevinpal: ACK [fa2b95c](bitcoin@fa2b95c) achow101: ACK fa2b95c TheCharlatan: ACK fa2b95c pablomartin4btc: tACK fa2b95c brunoerg: utACK fa2b95c Tree-SHA512: 43fac9acb4e9a6744d695dd49c7202e19ab4bf480f4cccff768647d0157a065f40e6ad70b9f6a65ba42048cc5fa9834365aa8e7aa0ed64c09e0cd4eb8dccb831
2 parents 03c5b00 + fa2b95c commit ac3901e

File tree

4 files changed

+49
-66
lines changed

4 files changed

+49
-66
lines changed

test/README.md

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -326,35 +326,7 @@ Use the `-v` option for verbose output.
326326

327327
### Lint tests
328328

329-
#### Dependencies
330-
331-
| Lint test | Dependency |
332-
|-----------|:----------:|
333-
| [`lint-python.py`](lint/lint-python.py) | [flake8](https://gitlab.com/pycqa/flake8)
334-
| [`lint-python.py`](lint/lint-python.py) | [lief](https://github.com/lief-project/LIEF)
335-
| [`lint-python.py`](lint/lint-python.py) | [mypy](https://github.com/python/mypy)
336-
| [`lint-python.py`](lint/lint-python.py) | [pyzmq](https://github.com/zeromq/pyzmq)
337-
| [`lint-python-dead-code.py`](lint/lint-python-dead-code.py) | [vulture](https://github.com/jendrikseipp/vulture)
338-
| [`lint-shell.py`](lint/lint-shell.py) | [ShellCheck](https://github.com/koalaman/shellcheck)
339-
| [`lint-spelling.py`](lint/lint-spelling.py) | [codespell](https://github.com/codespell-project/codespell)
340-
341-
In use versions and install instructions are available in the [CI setup](../ci/lint/04_install.sh).
342-
343-
Please be aware that on Linux distributions all dependencies are usually available as packages, but could be outdated.
344-
345-
#### Running the tests
346-
347-
Individual tests can be run by directly calling the test script, e.g.:
348-
349-
```
350-
test/lint/lint-files.py
351-
```
352-
353-
You can run all the shell-based lint tests by running:
354-
355-
```
356-
test/lint/all-lint.py
357-
```
329+
See the README in [test/lint](/test/lint).
358330

359331
# Writing functional tests
360332

test/lint/README.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,36 @@ result is cached and it prevents issues when the image changes.
1616
test runner
1717
===========
1818

19-
To run the checks in the test runner outside the docker, use:
19+
To run all the lint checks in the test runner outside the docker, use:
2020

2121
```sh
2222
( cd ./test/lint/test_runner/ && cargo fmt && cargo clippy && cargo run )
2323
```
2424

25+
#### Dependencies
26+
27+
| Lint test | Dependency |
28+
|-----------|:----------:|
29+
| [`lint-python.py`](lint/lint-python.py) | [flake8](https://gitlab.com/pycqa/flake8)
30+
| [`lint-python.py`](lint/lint-python.py) | [lief](https://github.com/lief-project/LIEF)
31+
| [`lint-python.py`](lint/lint-python.py) | [mypy](https://github.com/python/mypy)
32+
| [`lint-python.py`](lint/lint-python.py) | [pyzmq](https://github.com/zeromq/pyzmq)
33+
| [`lint-python-dead-code.py`](lint/lint-python-dead-code.py) | [vulture](https://github.com/jendrikseipp/vulture)
34+
| [`lint-shell.py`](lint/lint-shell.py) | [ShellCheck](https://github.com/koalaman/shellcheck)
35+
| [`lint-spelling.py`](lint/lint-spelling.py) | [codespell](https://github.com/codespell-project/codespell)
36+
37+
In use versions and install instructions are available in the [CI setup](../ci/lint/04_install.sh).
38+
39+
Please be aware that on Linux distributions all dependencies are usually available as packages, but could be outdated.
40+
41+
#### Running the tests
42+
43+
Individual tests can be run by directly calling the test script, e.g.:
44+
45+
```
46+
test/lint/lint-files.py
47+
```
48+
2549
check-doc.py
2650
============
2751
Check for missing documentation of command line options.
@@ -59,7 +83,3 @@ To do so, add the upstream repository as remote:
5983
```
6084
git remote add --fetch secp256k1 https://github.com/bitcoin-core/secp256k1.git
6185
```
62-
63-
all-lint.py
64-
===========
65-
Calls other scripts with the `lint-` prefix.

test/lint/all-lint.py

Lines changed: 0 additions & 23 deletions
This file was deleted.

test/lint/test_runner/src/main.rs

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// file COPYING or https://opensource.org/license/mit/.
44

55
use std::env;
6+
use std::fs;
67
use std::path::PathBuf;
78
use std::process::Command;
89
use std::process::ExitCode;
@@ -29,8 +30,8 @@ fn check_output(cmd: &mut std::process::Command) -> Result<String, LintError> {
2930
}
3031

3132
/// Return the git root as utf8, or panic
32-
fn get_git_root() -> String {
33-
check_output(git().args(["rev-parse", "--show-toplevel"])).unwrap()
33+
fn get_git_root() -> PathBuf {
34+
PathBuf::from(check_output(git().args(["rev-parse", "--show-toplevel"])).unwrap())
3435
}
3536

3637
fn lint_subtree() -> LintResult {
@@ -94,11 +95,24 @@ fn lint_doc() -> LintResult {
9495
}
9596

9697
fn lint_all() -> LintResult {
97-
if Command::new("test/lint/all-lint.py")
98-
.status()
99-
.expect("command error")
100-
.success()
101-
{
98+
let mut good = true;
99+
let lint_dir = get_git_root().join("test/lint");
100+
for entry in fs::read_dir(lint_dir).unwrap() {
101+
let entry = entry.unwrap();
102+
let entry_fn = entry.file_name().into_string().unwrap();
103+
if entry_fn.starts_with("lint-")
104+
&& entry_fn.ends_with(".py")
105+
&& !Command::new("python3")
106+
.arg(entry.path())
107+
.status()
108+
.expect("command error")
109+
.success()
110+
{
111+
good = false;
112+
println!("^---- failure generated from {}", entry_fn);
113+
}
114+
}
115+
if good {
102116
Ok(())
103117
} else {
104118
Err("".to_string())
@@ -110,10 +124,10 @@ fn main() -> ExitCode {
110124
("subtree check", lint_subtree),
111125
("std::filesystem check", lint_std_filesystem),
112126
("-help=1 documentation check", lint_doc),
113-
("all-lint.py script", lint_all),
127+
("lint-*.py scripts", lint_all),
114128
];
115129

116-
let git_root = PathBuf::from(get_git_root());
130+
let git_root = get_git_root();
117131

118132
let mut test_failed = false;
119133
for (lint_name, lint_fn) in test_list {

0 commit comments

Comments
 (0)