Skip to content

Commit

Permalink
Test: Add syntax tests and add missing use warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nicomen committed Oct 30, 2024
1 parent aac1207 commit 9cdcf93
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions cpanfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ requires "File::Copy::Recursive";
requires "Moo", ">= 2.0";

test_requires "Test::MockModule";
test_requires "Test2::AsyncSubtest";
1 change: 1 addition & 0 deletions share/shutter/resources/modules/Shutter/App/AboutDialog.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package Shutter::App::AboutDialog;
#--------------------------------------
use utf8;
use strict;
use warnings;
use Gtk3;

#Glib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package Shutter::App::GlobalSettings;
#--------------------------------------
use utf8;
use strict;
use warnings;

#Glib
use Glib qw/TRUE FALSE/;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package Shutter::App::HelperFunctions;
#--------------------------------------
use utf8;
use strict;
use warnings;
use Gtk3;

#Glib
Expand Down
1 change: 1 addition & 0 deletions share/shutter/resources/modules/Shutter/App/Menu.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package Shutter::App::Menu;
#--------------------------------------
use utf8;
use strict;
use warnings;
use Gtk3;

#Glib
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package Shutter::App::Optional::Exif;
#--------------------------------------
use utf8;
use strict;
use warnings;

use Glib qw/TRUE FALSE/;

Expand Down
1 change: 1 addition & 0 deletions share/shutter/resources/modules/Shutter/App/Toolbar.pm
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ package Shutter::App::Toolbar;
#--------------------------------------
use utf8;
use strict;
use warnings;
use Gtk3;

#Glib
Expand Down
1 change: 1 addition & 0 deletions share/shutter/resources/modules/Shutter/Upload/FTP.pm
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ package Shutter::Upload::FTP;

use utf8;
use strict;
use warnings;
use Net::FTP;
use URI;
use URI::Split qw(uri_split);
Expand Down
1 change: 1 addition & 0 deletions share/shutter/resources/modules/Shutter/Upload/Shared.pm
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ package Shutter::Upload::Shared;

use utf8;
use strict;
use warnings;
use POSIX qw/setlocale/;
use Locale::gettext;
use Glib qw/TRUE FALSE/;
Expand Down
1 change: 1 addition & 0 deletions share/shutter/resources/modules/X11/Protocol/Ext/XFIXES.pm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ BEGIN { require 5 }
package X11::Protocol::Ext::XFIXES;
use X11::Protocol 'padded';
use strict;
use warnings;
use Carp;

use vars '$VERSION', '@CARP_NOT';
Expand Down
52 changes: 52 additions & 0 deletions t/~syntax.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;
use Test::Strict;
use Test2::AsyncSubtest;

use FindBin qw/$Bin/;
use POSIX qw( waitpid WNOHANG );
use Time::HiRes qw( sleep );

local $Test::Strict::TEST_WARNINGS = 1;

my @dirs = ('t', 'bin', "$Bin/../share/shutter/resources/modules/");
my @files = Test::Strict::_all_perl_files(@dirs);

run_parallel_tests(
4,
[
map {
my $file = $_;
sub { all_perl_files_ok($file); };
} @files
],
"Syntax and strict checks for @dirs"
);

sub run_parallel_tests {
my ($MAX_JOBS, $tests, $name) = @_;

my $ast = Test2::AsyncSubtest->new(name => $name);

my @tests = @{$tests || []};

my %children;

while (@tests) {
if (keys %children < $MAX_JOBS) {
my $pid = $ast->run_fork(shift @tests);
$children{$pid}++;
}
waitpid($_, WNOHANG) && delete $children{$_} for keys %children;

last if !@tests;
sleep 0.01;
}
$ast->finish;
}

done_testing;

0 comments on commit 9cdcf93

Please sign in to comment.