]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add meson lint check rejecting hand-indented template includes 12474/head
authorNicki Křížek <nicki@isc.org>
Fri, 31 Jul 2026 13:56:39 +0000 (13:56 +0000)
committerNicki Křížek <nicki@isc.org>
Thu, 6 Aug 2026 11:50:09 +0000 (13:50 +0200)
An indented plain {% include %} pastes the included file at column zero
and a {% filter indent %} wrapper repeats the depth by hand;
{% include_indented %} replaces both. Reject them in CI so the system
test templates stay consistent.

Assisted-by: Claude:claude-fable-5
meson.build
util/check-jinja-include-indentation.sh [new file with mode: 0755]

index 7d3e358b6670c519d20b869f59d4c7b6ebca150f..dd536d86c9c549c61c3708438aa39946242e16ba 100644 (file)
@@ -2211,6 +2211,15 @@ if git.found()
         workdir: meson.project_source_root(),
     )
 
+    test(
+        'jinja-include-indentation',
+        sh,
+        suite: 'lint',
+        args: ['util/check-jinja-include-indentation.sh'],
+        verbose: true,
+        workdir: meson.project_source_root(),
+    )
+
     if grep.found() and xargs.found()
         test(
             'checklibs',
diff --git a/util/check-jinja-include-indentation.sh b/util/check-jinja-include-indentation.sh
new file mode 100755 (executable)
index 0000000..ebc0eb7
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/sh
+
+# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
+#
+# SPDX-License-Identifier: MPL-2.0
+#
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0.  If a copy of the MPL was not distributed with this
+# file, you can obtain one at https://mozilla.org/MPL/2.0/.
+#
+# See the COPYRIGHT file distributed with this work for additional
+# information regarding copyright ownership.
+
+# Ensure jinja2 templates in system tests use {% include_indented %} for
+# indented includes: a plain {% include %} pastes the file at column zero
+# and a {% filter indent %} wrapper repeats the depth by hand.
+bad_includes="$(git grep -nE '^[[:blank:]]+[{]% include |[{]% filter indent' -- 'bin/tests/system/*.j2' 'bin/tests/system/*.j2.manual')"
+
+if [ -n "${bad_includes}" ]; then
+  echo "The following template lines indent an include by hand:"
+  echo
+  echo "${bad_includes}"
+  echo
+  echo "Please use {% include_indented \"...\" %} instead."
+  exit 1
+fi