From: Nicki Křížek Date: Fri, 31 Jul 2026 13:56:39 +0000 (+0000) Subject: Add meson lint check rejecting hand-indented template includes X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fb0d6e766349d70bf4496fdb20b55ef792e136ad;p=thirdparty%2Fbind9.git Add meson lint check rejecting hand-indented template includes 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 --- diff --git a/meson.build b/meson.build index 7d3e358b667..dd536d86c9c 100644 --- a/meson.build +++ b/meson.build @@ -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 index 00000000000..ebc0eb77696 --- /dev/null +++ b/util/check-jinja-include-indentation.sh @@ -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