Skip to content

Commit fa673cf

Browse files
author
MarcoFalke
committed
lint: Call lint_scripted_diff from test_runner
Allowing to call the check from the test_runner allows for consistent error messages and better UX by having a single test_runner for all checks. This requires the env var to be set for now. The next commit makes the commit range optional.
1 parent 35bf426 commit fa673cf

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed

ci/lint/06_script.sh

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export COMMIT_RANGE
2525
echo
2626
git log --no-merges --oneline "$COMMIT_RANGE"
2727
echo
28-
test/lint/commit-script-check.sh "$COMMIT_RANGE"
2928
RUST_BACKTRACE=1 "${LINT_RUNNER_PATH}/test_runner"
3029

3130
if [ "$CIRRUS_REPO_FULL_NAME" = "bitcoin/bitcoin" ] && [ "$CIRRUS_PR" = "" ] ; then

test/lint/test_runner/src/main.rs

+23
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ fn get_linter_list() -> Vec<&'static Linter> {
6868
name: "subtree",
6969
lint_fn: lint_subtree
7070
},
71+
&Linter {
72+
description: "Check scripted-diffs",
73+
name: "scripted_diff",
74+
lint_fn: lint_scripted_diff
75+
},
7176
&Linter {
7277
description: "Check that tabs are not used as whitespace",
7378
name: "tabs_whitespace",
@@ -173,6 +178,11 @@ fn get_git_root() -> PathBuf {
173178
PathBuf::from(check_output(git().args(["rev-parse", "--show-toplevel"])).unwrap())
174179
}
175180

181+
/// Return the commit range, or panic
182+
fn commit_range() -> String {
183+
env::var("COMMIT_RANGE").unwrap()
184+
}
185+
176186
/// Return all subtree paths
177187
fn get_subtrees() -> Vec<&'static str> {
178188
vec![
@@ -210,6 +220,19 @@ fn lint_subtree() -> LintResult {
210220
}
211221
}
212222

223+
fn lint_scripted_diff() -> LintResult {
224+
if Command::new("test/lint/commit-script-check.sh")
225+
.arg(commit_range())
226+
.status()
227+
.expect("command error")
228+
.success()
229+
{
230+
Ok(())
231+
} else {
232+
Err("".to_string())
233+
}
234+
}
235+
213236
fn lint_py_lint() -> LintResult {
214237
let bin_name = "ruff";
215238
let checks = format!(

0 commit comments

Comments
 (0)