From c2a8810eb1143782cfab13b52bafb53534287773 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 25 Jan 2023 22:12:18 -0500 Subject: [PATCH] Tests: Check for new .pl file copyrights --- test_regress/t/t_dist_copyright.pl | 32 ++++++++++++++------- test_regress/t/t_func_no_parentheses_bad.pl | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/test_regress/t/t_dist_copyright.pl b/test_regress/t/t_dist_copyright.pl index e69ddb798..809b9af7b 100755 --- a/test_regress/t/t_dist_copyright.pl +++ b/test_regress/t/t_dist_copyright.pl @@ -57,14 +57,26 @@ my $Exempt_Files_List_Re = '^(' . join('|', (map { quotemeta $_ } @Exempt_Files_ if (!-r "$root/.git") { skip("Not in a git repository"); } else { - my $files = `cd $root && git ls-files --exclude-standard`; + my $out = `cd $root && git ls-files --exclude-standard`; my $year = strftime("%Y", localtime); - - $files =~ s/\s+/ /g; - foreach my $filename (split /\s+/, $files) { + my %files; + $out =~ s/\s+/ /g; + foreach my $filename (split /\s+/, $out) { next if $filename =~ /$Exempt_Files_Re/; next if $filename =~ /$Exempt_Files_List_Re/; + $files{$filename} = 1; + } + + my %added; + $out = `cd $root && git diff --name-status HEAD^^^^^`; + foreach my $line (split /\n/, $out) { + next if $line !~ /^A\s+(.*)/; + $added{$1} = 1; + } + + foreach my $filename (sort keys %files) { my $fh = IO::File->new("<$root/$filename") or error("$! $filename"); + next if !$fh; my $spdx; my $copyright; my $release; @@ -73,13 +85,13 @@ if (!-r "$root/.git") { $spdx = $line; } elsif ($line =~ /Copyright 20[0-9][0-9]/) { $copyright = $line; - if ($line !~ /Wilson Snyder|Geza Lore/ - && !($filename =~ /test_regress/ && $line =~ /Antmicro|Todd Strader/)) { + if ($line =~ /Wilson Snyder/) { + } elsif (!$added{$filename} && $line =~ /Antmicro|Geza Lore|Todd Strader/) { + } elsif ($filename =~ /$Exempt_Author_Re/) { + } else { my $yeardash = ($filename =~ m!test_regress/t!) ? $year : $year."-".$year; - if ($filename !~ /$Exempt_Author_Re/) { - warn " ".$copyright; - error("$filename: Please use standard 'Copyright $yeardash by Wilson Snyder'"); - } + warn " ".$copyright; + error("$filename: Please use standard 'Copyright $yeardash by Wilson Snyder'"); } } elsif ($line =~ m!Creative Commons Public Domain! || $line =~ m!freely copied and/or distributed! diff --git a/test_regress/t/t_func_no_parentheses_bad.pl b/test_regress/t/t_func_no_parentheses_bad.pl index ba65deaec..bd07fc421 100755 --- a/test_regress/t/t_func_no_parentheses_bad.pl +++ b/test_regress/t/t_func_no_parentheses_bad.pl @@ -2,7 +2,7 @@ if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } # DESCRIPTION: Verilator: Verilog Test driver/expect definition # -# Copyright 2023 by Antmicro Ltd. This program is free software; you +# Copyright 2023 by Wilson Snyder. This program is free software; you # can redistribute it and/or modify it under the terms of either the GNU # Lesser General Public License Version 3 or the Perl Artistic License # Version 2.0.