* [PATCH] [pre-commit] Add tclint hook
@ 2025-09-15 8:41 Tom de Vries
2025-09-17 15:42 ` Tom Tromey
0 siblings, 1 reply; 8+ messages in thread
From: Tom de Vries @ 2025-09-15 8:41 UTC (permalink / raw)
To: gdb-patches
Add a pre-commit hook that enables tclint [1] (a Tcl linter) for the gdb
testsuite.
The pre-commit hook doesn't reference the official url, because that one
doesn't have pre-commit support yet [2].
Instead, it uses a fork on my personal github account. The fork contains a
tag v0.6.0-gdb, which is the official v0.6.0 release plus a commit adding a
.pre-commit-hooks.yaml file. Given that this is a personal github account, I
thought it would be safer to refer to the git SHA than to the tag.
Also add a tclint configuration file gdb/testsuite/tclint.toml.
In the configuration file, we still ignore most dirs because they're not
tclint-clean.
Consequently, the tclint pre-commit check passes:
...
$ pre-commit run --all-files -v tclint
tclint........................Passed
- hook id: tclint
- duration: 0.25s
$
...
PR testsuite/33403
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=33403
[1] https://github.com/nmoroze/tclint
[2] https://github.com/nmoroze/tclint/issues/110
---
.pre-commit-config.yaml | 15 ++++++++
gdb/testsuite/tclint.toml | 75 +++++++++++++++++++++++++++++++++++++++
2 files changed, 90 insertions(+)
create mode 100644 gdb/testsuite/tclint.toml
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index a4a8a5fa1ef..6bbd51fb6d0 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -88,3 +88,18 @@ repos:
verbose: true
always_run: true
stages: [commit-msg]
+ - # We'd like to use the official repo, like this:
+ # repo: https://github.com/nmoroze/tclint
+ # rev: v0.6.0
+ # but it doesn't have a .pre-commit-hooks.yaml file.
+ # Work around this by using an unoffical repo. The repo contains a tag
+ # v0.6.0-gdb that adds a .pre-commit-hooks.yaml file to the v0.6.0 release
+ # of the offical repo. Since we're using an unofficial repo, use the git
+ # SHA instead of the tag.
+ repo: https://github.com/vries/tclint.git
+ rev: 2e6b4510fb3d3d6f8f2609af0f7158fabc0c96e4
+ hooks:
+ - id: tclint
+ args: [--config, gdb/testsuite/tclint.toml]
+ types_or: [file]
+ files: 'gdb/testsuite/.*\.(exp|tcl)$'
diff --git a/gdb/testsuite/tclint.toml b/gdb/testsuite/tclint.toml
new file mode 100644
index 00000000000..c30fc210d63
--- /dev/null
+++ b/gdb/testsuite/tclint.toml
@@ -0,0 +1,75 @@
+# Copyright 2025 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Configuration file for tclint ( https://github.com/nmoroze/tclint ).
+
+exclude = [
+"gdb/testsuite/boards",
+"gdb/testsuite/config",
+"gdb/testsuite/lib",
+"gdb/testsuite/gdb.ada",
+"gdb/testsuite/gdb.arch",
+"gdb/testsuite/gdb.asm",
+"gdb/testsuite/gdb.base",
+"gdb/testsuite/gdb.btrace",
+"gdb/testsuite/gdb.compile",
+"gdb/testsuite/gdb.cp",
+"gdb/testsuite/gdb.ctf",
+"gdb/testsuite/gdb.dap",
+"gdb/testsuite/gdb.debuginfod",
+"gdb/testsuite/gdb.disasm",
+"gdb/testsuite/gdb.dlang",
+"gdb/testsuite/gdb.dwarf2",
+"gdb/testsuite/gdb.fortran",
+"gdb/testsuite/gdb.gdb",
+"gdb/testsuite/gdb.go",
+"gdb/testsuite/gdb.guile",
+"gdb/testsuite/gdb.linespec",
+"gdb/testsuite/gdb.mi",
+"gdb/testsuite/gdb.multi",
+"gdb/testsuite/gdb.opencl",
+"gdb/testsuite/gdb.perf",
+"gdb/testsuite/gdb.python",
+"gdb/testsuite/gdb.reverse",
+"gdb/testsuite/gdb.rocm",
+"gdb/testsuite/gdb.server",
+"gdb/testsuite/gdb.stabs",
+"gdb/testsuite/gdb.threads",
+"gdb/testsuite/gdb.trace",
+]
+
+# A maximum line length of 80 is current policy, but hasn't been too strictly
+# enforced. It's the most frequent and least harmful violation.
+# Ignore this for now.
+ignore = ["line-length"]
+
+extensions = ["exp", "tcl"]
+
+[style]
+# Used by tclfmt. Doesn't support mixed TAB and spaces style we use. See
+# this tclint issue ( https://github.com/nmoroze/tclint/issues/109 ).
+indent = 4
+
+# Used by both tclint and tclfmt. Current policy is 80.
+line-length = 80
+
+# Used by tclfmt.
+max-blank-lines = 1
+
+# Used by tclfmt. False conflicts with emacs tcl mode.
+indent-namespace-eval = true
+
+# Used by tclfmt.
+spaces-in-braces = false
base-commit: 6affec82bd4186aaf2e6733425b1e05870fc0582
--
2.51.0
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] [pre-commit] Add tclint hook
2025-09-15 8:41 [PATCH] [pre-commit] Add tclint hook Tom de Vries
@ 2025-09-17 15:42 ` Tom Tromey
2025-09-17 18:15 ` Tom de Vries
0 siblings, 1 reply; 8+ messages in thread
From: Tom Tromey @ 2025-09-17 15:42 UTC (permalink / raw)
To: Tom de Vries; +Cc: gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> Add a pre-commit hook that enables tclint [1] (a Tcl linter) for the gdb
Tom> testsuite.
Tom> The pre-commit hook doesn't reference the official url, because that one
Tom> doesn't have pre-commit support yet [2].
My first reaction was to say we should wait but after reflecting a bit,
I think it's probably better to just go ahead and then switch when
tclint upstream catches up.
Tom> Also add a tclint configuration file gdb/testsuite/tclint.toml.
How about using pyproject.toml so we can have (nearly) all this kind of
config in one spot?
Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] [pre-commit] Add tclint hook
2025-09-17 15:42 ` Tom Tromey
@ 2025-09-17 18:15 ` Tom de Vries
2025-09-17 18:35 ` Tom Tromey
0 siblings, 1 reply; 8+ messages in thread
From: Tom de Vries @ 2025-09-17 18:15 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 9/17/25 17:42, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> Add a pre-commit hook that enables tclint [1] (a Tcl linter) for the gdb
> Tom> testsuite.
>
> Tom> The pre-commit hook doesn't reference the official url, because that one
> Tom> doesn't have pre-commit support yet [2].
>
> My first reaction was to say we should wait but after reflecting a bit,
> I think it's probably better to just go ahead and then switch when
> tclint upstream catches up.
>
> Tom> Also add a tclint configuration file gdb/testsuite/tclint.toml.
>
> How about using pyproject.toml so we can have (nearly) all this kind of
> config in one spot?
Hi Tom,
thanks for the review, and for supporting the idea.
I've just tried transferring settings to gdb/pyproject.toml (see patch
below), but that didn't work. The docs say it's supposed to work
though, so some debugging is needed.
Thanks,
- Tom
diff --git a/gdb/pyproject.toml b/gdb/pyproject.toml
index 4469f1cd61d..d271939df5c 100644
--- a/gdb/pyproject.toml
+++ b/gdb/pyproject.toml
@@ -3,3 +3,57 @@ include = "\\.py(\\.in)?$"
[tool.pyright]
typeCheckingMode = "strict"
+
+[tool.tclint]
+exclude = [
+"gdb/testsuite/boards",
+"gdb/testsuite/config",
+"gdb/testsuite/lib",
+"gdb/testsuite/gdb.ada",
+"gdb/testsuite/gdb.arch",
+"gdb/testsuite/gdb.asm",
+"gdb/testsuite/gdb.base",
+"gdb/testsuite/gdb.btrace",
+"gdb/testsuite/gdb.compile",
+"gdb/testsuite/gdb.cp",
+"gdb/testsuite/gdb.ctf",
+"gdb/testsuite/gdb.dap",
+"gdb/testsuite/gdb.debuginfod",
+"gdb/testsuite/gdb.disasm",
+"gdb/testsuite/gdb.dlang",
+"gdb/testsuite/gdb.dwarf2",
+"gdb/testsuite/gdb.fortran",
+"gdb/testsuite/gdb.gdb",
+"gdb/testsuite/gdb.go",
+"gdb/testsuite/gdb.guile",
+"gdb/testsuite/gdb.linespec",
+"gdb/testsuite/gdb.mi",
+"gdb/testsuite/gdb.multi",
+"gdb/testsuite/gdb.opencl",
+"gdb/testsuite/gdb.perf",
+"gdb/testsuite/gdb.python",
+"gdb/testsuite/gdb.reverse",
+"gdb/testsuite/gdb.rocm",
+"gdb/testsuite/gdb.server",
+"gdb/testsuite/gdb.stabs",
+"gdb/testsuite/gdb.threads",
+"gdb/testsuite/gdb.trace",
+]
+# A maximum line length of 80 is current policy, but hasn't been too
strictly
+# enforced. It's the most frequent and least harmful violation.
+# Ignore this for now.
+ignore = ["line-length"]
+extensions = ["exp", "tcl"]
+
+[tool.tclint.style]
+# Used by tclfmt. Doesn't support mixed TAB and spaces style we use. See
+# this tclint issue ( https://github.com/nmoroze/tclint/issues/109 ).
+indent = 4
+# Used by both tclint and tclfmt. Current policy is 80.
+line-length = 80
+# Used by tclfmt.
+max-blank-lines = 1
+# Used by tclfmt. False conflicts with emacs tcl mode.
+indent-namespace-eval = true
+# Used by tclfmt.
+spaces-in-braces = false
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] [pre-commit] Add tclint hook
2025-09-17 18:15 ` Tom de Vries
@ 2025-09-17 18:35 ` Tom Tromey
2025-09-17 19:08 ` Tom de Vries
2025-09-19 7:14 ` Tom de Vries
0 siblings, 2 replies; 8+ messages in thread
From: Tom Tromey @ 2025-09-17 18:35 UTC (permalink / raw)
To: Tom de Vries; +Cc: Tom Tromey, gdb-patches
>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
Tom> I've just tried transferring settings to gdb/pyproject.toml (see patch
Tom> below), but that didn't work. The docs say it's supposed to work
Tom> though, so some debugging is needed.
Thanks for trying it. I guess maybe file an upstream bug report?
Anyway let's just go with your original patch. We can always move the
config if/when tclint is fixed.
Approved-By: Tom Tromey <tom@tromey.com>
Tom> +# Used by tclfmt. Doesn't support mixed TAB and spaces style we use. See
Tom> +# this tclint issue ( https://github.com/nmoroze/tclint/issues/109 ).
Tom> +indent = 4
Probably not the best spot to bring it up, but FWIW I never liked the 4
indent step for Tcl. I always used 2 in my own code. The reason is
that with 4 you end up with:
if {something complicated
&& requiring multiple lines} {
then the code is indented just like the condition
}
as opposed to
if {something complicated
&& requiring multiple lines} {
then the code is outdented just a little
}
Tom
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] [pre-commit] Add tclint hook
2025-09-17 18:35 ` Tom Tromey
@ 2025-09-17 19:08 ` Tom de Vries
2025-09-17 19:43 ` Tom de Vries
2025-09-19 7:14 ` Tom de Vries
1 sibling, 1 reply; 8+ messages in thread
From: Tom de Vries @ 2025-09-17 19:08 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 9/17/25 20:35, Tom Tromey wrote:
>>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:
>
> Tom> I've just tried transferring settings to gdb/pyproject.toml (see patch
> Tom> below), but that didn't work. The docs say it's supposed to work
> Tom> though, so some debugging is needed.
>
> Thanks for trying it. I guess maybe file an upstream bug report?
I understand it now. Using pyproject.toml works, provided you're
running the command from the same directory.
So, in this case the pyproject.toml file is read, which prevents
line-length warnings:
...
$ ( cd gdb; tclint testsuite/lib/gdb.exp ) | grep -c line-length
0
...
And in this case (which is what I do usually) not:
...
$ tclint gdb/testsuite/lib/gdb.exp | grep -c line-length
17
...
I think that also might make it difficult to use tclint from pre-commit.
> Anyway let's just go with your original patch. We can always move the
> config if/when tclint is fixed.
>
Thanks, I'll push it.
> Approved-By: Tom Tromey <tom@tromey.com>
>
> Tom> +# Used by tclfmt. Doesn't support mixed TAB and spaces style we use. See
> Tom> +# this tclint issue ( https://github.com/nmoroze/tclint/issues/109 ).
> Tom> +indent = 4
>
> Probably not the best spot to bring it up, but FWIW I never liked the 4
> indent step for Tcl. I always used 2 in my own code. The reason is
> that with 4 you end up with:
>
> if {something complicated
> && requiring multiple lines} {
> then the code is indented just like the condition
> }
>
> as opposed to
>
> if {something complicated
> && requiring multiple lines} {
> then the code is outdented just a little
> }
I got used to it, but I don't care too much one way or the other. As
long as I can use emacs with auto-indent, I'm fine :)
FWIW, atm we don't use tclfmt, but I thought it'd be useful to at least
document current practice.
Thanks,
- Tom
^ permalink raw reply [flat|nested] 8+ messages in thread* Re: [PATCH] [pre-commit] Add tclint hook
2025-09-17 19:08 ` Tom de Vries
@ 2025-09-17 19:43 ` Tom de Vries
2025-09-18 0:22 ` Tom Tromey
0 siblings, 1 reply; 8+ messages in thread
From: Tom de Vries @ 2025-09-17 19:43 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 9/17/25 21:08, Tom de Vries wrote:
> So, in this case the pyproject.toml file is read, which prevents line-
> length warnings:
> ...
> $ ( cd gdb; tclint testsuite/lib/gdb.exp ) | grep -c line-length
> 0
> ...
>
> And in this case (which is what I do usually) not:
> ...
> $ tclint gdb/testsuite/lib/gdb.exp | grep -c line-length
> 17
> ...
Hmm, I missed that the same thing happens for gdb/testsuite/tclint.toml:
...
$ tclint gdb/testsuite/lib/gdb.exp | grep -c line-length
17
$ ( cd gdb; tclint testsuite/lib/gdb.exp ) | grep -c line-length
17
$ ( cd gdb/testsuite/; tclint lib/gdb.exp ) | grep -c line-length
0
...
So, then maybe gdb/tclint.toml, or ./tclint.toml or ./.tclint ?
Thanks,
- Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH] [pre-commit] Add tclint hook
2025-09-17 18:35 ` Tom Tromey
2025-09-17 19:08 ` Tom de Vries
@ 2025-09-19 7:14 ` Tom de Vries
1 sibling, 0 replies; 8+ messages in thread
From: Tom de Vries @ 2025-09-19 7:14 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
On 9/17/25 20:35, Tom Tromey wrote:
> om> I've just tried transferring settings to gdb/pyproject.toml (see patch
> Tom> below), but that didn't work. The docs say it's supposed to work
> Tom> though, so some debugging is needed.
>
> Thanks for trying it. I guess maybe file an upstream bug report?
I've filed a bug report ( https://github.com/nmoroze/tclint/issues/120 ).
Thanks,
- Tom
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-09-19 7:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-15 8:41 [PATCH] [pre-commit] Add tclint hook Tom de Vries
2025-09-17 15:42 ` Tom Tromey
2025-09-17 18:15 ` Tom de Vries
2025-09-17 18:35 ` Tom Tromey
2025-09-17 19:08 ` Tom de Vries
2025-09-17 19:43 ` Tom de Vries
2025-09-18 0:22 ` Tom Tromey
2025-09-19 7:14 ` Tom de Vries
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox