mirror of
https://github.com/curl/curl.git
synced 2026-08-02 08:30:30 +03:00
checksrc: avoid extra runs in CI, enable more check locally, fix fallouts
To avoid redundant work in CI and to avoid a single checksrc issue make all autotools jobs fail. After this patch checksrc issues make fail the checksrc job, the `dist / verify-out-of-tree-autotools-debug`, `dist / maketgz-and-verify-in-tree` jobs and the fuzzer job (if run). Of these, the `dist` jobs replicate local builds, also testing the build logic. Also add a script to check the complete local repository, optionally with the build tree to verify generated C files. Also: - automatically run checksrc in subdirectories having a `checksrc` target. (examples, OS400, tests http/client, unit and tunit) - tests/libtest: make sure to run `checksrc` on generated `lib1521.c`. (requires in-tree autotools build.) - tests: run `checksrc` on targets also for non-`DEBUGBUILD` builds. It ensures to check `lib1521.c` in CI via job `dist / maketgz-and-verify-in-tree`. - src: drop redundant `$(builddir)` in autotools builds. - scripts: add `checksrc-all.sh` script to check all C sources and the build directory as an option. - use the above from CI, also make it verify all generated sources. - silence `checksrc` issues in generated C sources. - checksrc: add `-v` option to enable verbose mode. - checksrc: make verbose mode show checked filename and fix to only return error on failure. - make sure that generated C files pass `checksrc`. Assisted-by: Daniel Stenberg Closes #17376
This commit is contained in:
parent
414ec13840
commit
e785e898a6
26 changed files with 119 additions and 25 deletions
|
|
@ -22,9 +22,9 @@
|
|||
#
|
||||
###########################################################################
|
||||
|
||||
EXTRA_DIST = coverage.sh completion.pl firefox-db2pem.sh checksrc.pl \
|
||||
mk-ca-bundle.pl mk-unity.pl schemetable.c cd2nroff nroff2cd cdall cd2cd managen \
|
||||
dmaketgz maketgz release-tools.sh verify-release cmakelint.sh mdlinkcheck \
|
||||
EXTRA_DIST = coverage.sh completion.pl firefox-db2pem.sh checksrc.pl checksrc-all.sh \
|
||||
mk-ca-bundle.pl mk-unity.pl schemetable.c cd2nroff nroff2cd cdall cd2cd managen \
|
||||
dmaketgz maketgz release-tools.sh verify-release cmakelint.sh mdlinkcheck \
|
||||
CMakeLists.txt pythonlint.sh randdisable wcurl
|
||||
|
||||
dist_bin_SCRIPTS = wcurl
|
||||
|
|
|
|||
23
scripts/checksrc-all.sh
Executable file
23
scripts/checksrc-all.sh
Executable file
|
|
@ -0,0 +1,23 @@
|
|||
#!/bin/sh
|
||||
# Copyright (C) Viktor Szakats
|
||||
#
|
||||
# SPDX-License-Identifier: curl
|
||||
|
||||
set -eu
|
||||
|
||||
anyfailed=0
|
||||
|
||||
for dir in $({
|
||||
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
git ls-files '*.[ch]'
|
||||
else
|
||||
find . -name '*.[ch]'
|
||||
fi
|
||||
[ -n "${1:-}" ] && find "$@" -name '*.[ch]'
|
||||
} | grep -v -F '/CMakeFiles/' | sed -E 's|/[^/]+$||' | sort -u); do
|
||||
if ! ./scripts/checksrc.pl "${dir}"/*.[ch]; then
|
||||
anyfailed=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit "${anyfailed}"
|
||||
|
|
@ -39,7 +39,7 @@ my $dir=".";
|
|||
my $wlist="";
|
||||
my @alist;
|
||||
my $windows_os = $^O eq 'MSWin32' || $^O eq 'cygwin' || $^O eq 'msys';
|
||||
my $verbose;
|
||||
my $verbose = 0;
|
||||
my %skiplist;
|
||||
|
||||
my %ignore;
|
||||
|
|
@ -288,6 +288,11 @@ while(defined $file) {
|
|||
$file = shift @ARGV;
|
||||
next;
|
||||
}
|
||||
elsif($file =~ /^-v/) {
|
||||
$verbose = 1;
|
||||
$file = shift @ARGV;
|
||||
next;
|
||||
}
|
||||
elsif($file =~ /^(-h|--help)/) {
|
||||
undef $file;
|
||||
last;
|
||||
|
|
@ -307,6 +312,7 @@ if(!$file) {
|
|||
print " -W[file] Skip the given file - ignore all its flaws\n";
|
||||
print " -i<n> Indent spaces. Default: 2\n";
|
||||
print " -m<n> Maximum line length. Default: 79\n";
|
||||
print " -v Verbose\n";
|
||||
print "\nDetects and warns for these problems:\n";
|
||||
my @allw = keys %warnings;
|
||||
push @allw, keys %warnings_extended;
|
||||
|
|
@ -448,6 +454,11 @@ sub scanfile {
|
|||
my $l = "";
|
||||
my $prep = 0;
|
||||
my $prevp = 0;
|
||||
|
||||
if($verbose) {
|
||||
printf "Checking file: $file\n";
|
||||
}
|
||||
|
||||
open(my $R, '<', $file) || die "failed to open $file";
|
||||
|
||||
my $incomment=0;
|
||||
|
|
@ -1123,5 +1134,7 @@ if($errors || $warnings || $verbose) {
|
|||
$serrors,
|
||||
$swarnings;
|
||||
}
|
||||
exit 5; # return failure
|
||||
if($errors || $warnings) {
|
||||
exit 5; # return failure
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue