curl-curl/scripts
Viktor Szakats 39542f0993
cmake: add native clang-tidy support for tests, with concatenated sources
Tests are build in "unity"-style, by including sources into an umbrella
C files (similar to how CMake unity works). This does not play well with
clang-tidy, which seems to unconditionally ignore C sources included
like this. To fix it, curl's CMake implements a manual clang-tidy
support for tests, which  compiles sources one-by-one, while also making
sure sources compile cleanly standalone (e.g. all sources need to
include `first.h`). The manual clang-tidy implementation is fragile, and
performance, in particular when targeting Windows, is abysmal.

This patch introduces an alternate solution, enabled by the
`_CURL_TESTS_CONCAT=ON` option. In this mode, umbrella sources include
the actual sources instead of `#including` them. Allowing to use CMake's
built-in clang-tidy support to compile them, with clang-tidy actually
checking the sources. Making the manual clang-tidy support unnecessary.
In the Windows CI job it results in a 4x performance improvement (4m ->
1m), making it practical to run clang-tidy on tests on Windows, in CI.

The main downside is that clang-tidy doesn't understand the `#line`
directive. Meaning issues found show the wrong filename and line number
next to them. It's not impossible to locate errors this way, but also
not convenient.

Minor/potential downside is that the concatenated source needs to be
reassembled each time an original source is updated. This may result in
more copying on the disk when used in local development. The largest
source is 1.4MB, so probably not a show-stopper on most machines.

Another is the complexity of maintaining two methods in parallel, which
may be necessary till clang-tidy understands `#line`:
https://github.com/llvm/llvm-project/issues/62405

This solution may in theory also enable adding clang-tidy support for
tests in autotools, though I haven't tried.

Targeted for curl CI for now, and used in a GHA/windows job. 100%
experimental, not recommended outside these.

Closes #20667
2026-02-25 17:28:35 +01:00
..
.checksrc REUSE: move copyright headers to .checksrc 2025-10-13 11:54:22 +02:00
cd2cd tidy-up: miscellaneous 2026-02-12 14:52:16 +01:00
cd2nroff tidy-up: miscellaneous 2026-02-12 14:52:16 +01:00
cdall badwords: fix issues found in scripts and other files 2025-11-17 17:18:07 +01:00
checksrc-all.pl checksrc-all.pl: skip non-repository files 2026-01-26 16:07:58 +01:00
checksrc.pl tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
ciconfig.pl tidy-up: miscellaneous 2026-02-12 14:52:16 +01:00
cijobs.pl tidy-up: miscellaneous 2026-02-12 14:52:16 +01:00
cmakelint.sh cmake: improve clang-tidy invocation for tests in cross-builds 2026-02-20 12:08:52 +01:00
CMakeLists.txt cmake: replace deprecated PERL_FOUND with Perl_FOUND 2025-12-17 17:56:32 +01:00
completion.pl badwords: fix issues found in scripts and other files 2025-11-17 17:18:07 +01:00
contributors.sh tidy-up: miscellaneous 2026-01-15 13:06:13 +01:00
contrithanks.sh contrithanks.sh: adopt the stricter by: check from contributors.sh 2025-12-20 17:45:15 +01:00
coverage.sh GHA: add shellcheck job and fix warnings, shell tidy-ups 2024-04-08 09:37:24 +00:00
delta delta: fix grep patterns after white space edits 2025-12-30 14:04:10 +01:00
dmaketgz dmaketgz: use --no-cache when building docker image 2024-12-05 15:41:53 +01:00
extract-unit-protos scripts: enable strict warnings in Perl where missing, fix fallouts 2025-07-27 22:35:18 +02:00
firefox-db2pem.sh tidy-up: miscellaneous 2025-12-12 04:18:48 +01:00
installcheck.sh GHA: add shellcheck job and fix warnings, shell tidy-ups 2024-04-08 09:37:24 +00:00
Makefile.am build: add curl-lint/lint targets, CURL_LINT cmake option 2026-01-12 16:45:24 +01:00
maketgz scripts: use end-of-options marker in find -exec commands 2025-11-10 18:52:29 +01:00
managen tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
mdlinkcheck mdlinkcheck: only look for markdown links in markdown files 2025-12-11 23:40:07 +01:00
mk-ca-bundle.pl tidy-up: miscellaneous 2026-02-12 14:52:16 +01:00
mk-unity.pl cmake: add native clang-tidy support for tests, with concatenated sources 2026-02-25 17:28:35 +01:00
nroff2cd scripts: enable strict warnings in Perl where missing, fix fallouts 2025-07-27 22:35:18 +02:00
perlcheck.sh cmake: match filename suffixes with file content 2025-12-20 11:34:27 +01:00
pythonlint.sh scripts: move the ruff linter command into a script 2025-05-13 16:41:32 -07:00
randdisable spelling: file system 2025-08-22 15:53:41 +02:00
release-notes.pl badwords: fix issues found in scripts and other files 2025-11-17 17:18:07 +01:00
release-tools.sh badwords: fix issues found in scripts and other files 2025-11-17 17:18:07 +01:00
schemetable.c lib: separate scheme info from protocol implementation 2026-01-19 23:15:13 +01:00
singleuse.pl tidy-up: merge root packages directory into projects 2026-01-12 23:49:35 +01:00
spacecheck.pl tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
top-complexity tidy-up: miscellaneous 2026-02-25 14:44:56 +01:00
verify-release verify-release: update to avoid shellcheck warning SC2034 2025-11-10 16:06:48 +01:00
wcurl wcurl: import v2026.01.05 2026-01-06 10:12:31 +01:00