mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: CaoRuichuang <create0818@163.com>
To: apw@canonical.com, joe@perches.com
Cc: dwaipayanray1@gmail.com, lukas.bulwahn@gmail.com,
	linux-kernel@vger.kernel.org, CaoRuichuang <create0818@163.com>
Subject: [PATCH v2 2/2] scripts: add sparse checkout regression test for checkpatch tools
Date: Mon,  6 Apr 2026 03:15:55 +0800	[thread overview]
Message-ID: <20260405191555.80315-3-create0818@163.com> (raw)
In-Reply-To: <20260405191555.80315-1-create0818@163.com>

Add a shell-based regression test that exercises checkpatch.pl and get_maintainer.pl from a minimal sparse checkout style tree.

This locks in the sparse checkout behavior added by the preceding patch and catches future regressions in top_of_kernel_tree() handling for these scripts.

Signed-off-by: CaoRuichuang <create0818@163.com>
---
 scripts/checkpatch-sparse-checkout-test.sh | 48 ++++++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100755 scripts/checkpatch-sparse-checkout-test.sh

diff --git a/scripts/checkpatch-sparse-checkout-test.sh b/scripts/checkpatch-sparse-checkout-test.sh
new file mode 100755
index 000000000..02e2774a8
--- /dev/null
+++ b/scripts/checkpatch-sparse-checkout-test.sh
@@ -0,0 +1,48 @@
+#!/bin/sh -eu
+# SPDX-License-Identifier: GPL-2.0
+
+srctree=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
+tmpdir=$(mktemp -d)
+trap 'rm -rf "$tmpdir"' EXIT
+
+mkdir -p "$tmpdir/Documentation/process" "$tmpdir/scripts"
+
+for file in COPYING CREDITS Kbuild MAINTAINERS Makefile README; do
+	cp "$srctree/$file" "$tmpdir/$file"
+done
+
+cp "$srctree/Documentation/process/submitting-patches.rst" \
+	"$tmpdir/Documentation/process/"
+cp "$srctree/scripts/checkpatch.pl" "$tmpdir/scripts/"
+cp "$srctree/scripts/get_maintainer.pl" "$tmpdir/scripts/"
+cp "$srctree/scripts/spdxcheck.py" "$tmpdir/scripts/"
+cp "$srctree/scripts/spelling.txt" "$tmpdir/scripts/"
+
+git -C "$tmpdir" init -q
+git -C "$tmpdir" add \
+	COPYING CREDITS Kbuild MAINTAINERS Makefile README \
+	Documentation/process/submitting-patches.rst \
+	scripts/checkpatch.pl scripts/get_maintainer.pl \
+	scripts/spdxcheck.py scripts/spelling.txt
+
+checkpatch_out=$(
+	cd "$tmpdir" &&
+	perl scripts/checkpatch.pl --file Documentation/process/submitting-patches.rst \
+		2>&1 || true
+)
+
+echo "$checkpatch_out" |
+	grep -q "Must be run from the top-level dir. of a kernel tree" &&
+		exit 1
+
+get_maintainer_out=$(
+	cd "$tmpdir" &&
+	perl scripts/get_maintainer.pl -f Documentation/process/submitting-patches.rst \
+		2>&1
+)
+
+echo "$get_maintainer_out" |
+	grep -q "The current directory does not appear to be a linux kernel source tree" &&
+		exit 1
+
+echo "$get_maintainer_out" | grep -q "Jonathan Corbet" || exit 1
-- 
2.39.5 (Apple Git-154)


      parent reply	other threads:[~2026-04-05 19:16 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-05 18:55 [PATCH] scripts: allow checkpatch and get_maintainer in sparse checkouts CaoRuichuang
2026-04-05 19:12 ` Joe Perches
2026-04-05 19:15 ` [PATCH v2 0/2] scripts: support sparse checkouts in checkpatch tools CaoRuichuang
2026-04-05 19:15   ` [PATCH v2 1/2] scripts: allow checkpatch and get_maintainer in sparse checkouts CaoRuichuang
2026-04-05 19:26     ` Joe Perches
2026-04-05 19:39       ` CaoRuichuang
2026-04-05 19:15   ` CaoRuichuang [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260405191555.80315-3-create0818@163.com \
    --to=create0818@163.com \
    --cc=apw@canonical.com \
    --cc=dwaipayanray1@gmail.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukas.bulwahn@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®