Skip to content

Commit

Permalink
Detect adding and updating .result files
Browse files Browse the repository at this point in the history
Part of #23
  • Loading branch information
ligurio committed Sep 2, 2022
1 parent fbd3f84 commit 18e91b9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
13 changes: 13 additions & 0 deletions checkpatch.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2140,6 +2140,8 @@ sub process {

my %commit_log_tags = ();
my $has_changelog = 0;
my $has_test_result_file = 0;
my $warned_about_result_file = 0;
my $has_doc = 0;
my $has_test = 0;
my $is_test = 0;
Expand Down Expand Up @@ -2731,6 +2733,9 @@ sub process {
if ($realfile =~ /^(?:static-build\/)?test\/.*\//) {
$has_test = 1;
}
if ($realfile =~ /^test\/.*\.result$/) {
$has_test_result_file = 1;
}

# check for repeated words separated by a single space
# avoid false positive from list command eg, '-rw-r--r-- 1 root root'
Expand Down Expand Up @@ -2823,6 +2828,14 @@ sub process {
"please, use spaces instead of tabs\n" . $herevet);
}

if (!$warned_about_result_file &&
$has_test_result_file &&
$line =~ /^\+/) {
$warned_about_result_file = 1;
ERROR("TEST_DIFF_FILE",
"Please avoid tests with .result files\n");
}

# check we are in a valid C source file if not then ignore this hunk
next if ($realfile !~ /\.(h|c|cc)$/);

Expand Down
4 changes: 4 additions & 0 deletions doc/checkpatch.rst
Original file line number Diff line number Diff line change
Expand Up @@ -742,6 +742,10 @@ Others
For DOS-formatted patches, there are extra ^M symbols at the end of
the line. These should be removed.

**TEST_DIFF_FILE**
For regression tests, there are .result files. Tests with .result files
should be avoided.

**MEMSET**
The memset use appears to be incorrect. This may be caused due to
badly ordered parameters. Please recheck the usage.
Expand Down

0 comments on commit 18e91b9

Please sign in to comment.