File Coverage

blib/lib/App/gimpgitbuild/Command/build.pm
Criterion Covered Total %
statement 29 65 44.6
branch 0 12 0.0
condition 0 12 0.0
subroutine 10 17 58.8
pod 4 4 100.0
total 43 110 39.0


line stmt bran cond sub pod time code
1             package App::gimpgitbuild::Command::build;
2             $App::gimpgitbuild::Command::build::VERSION = '0.32.1';
3 1     1   250421 use strict;
  1         3  
  1         44  
4 1     1   6 use warnings;
  1         2  
  1         78  
5 1     1   896 use autodie;
  1         18831  
  1         6  
6 1     1   8783 use 5.014;
  1         12  
7              
8 1     1   594 use App::gimpgitbuild -command;
  1         7  
  1         14  
9              
10 1     1   14898 use File::Which qw/ which /;
  1         1109  
  1         80  
11              
12 1     1   582 use App::gimpgitbuild::API::GitBuild ();
  1         6  
  1         35  
13 1     1   597 use App::gimpgitbuild::API::Worker ();
  1         3  
  1         31  
14 1     1   21 use Git::Sync::App ();
  1         1  
  1         629  
15              
16             sub description
17             {
18 0     0 1   return "build gimp from git";
19             }
20              
21             sub abstract
22             {
23 0     0 1   return shift->description();
24             }
25              
26             sub opt_spec
27             {
28 0     0 1   return ( [ "mode=s", "Mode (e.g: \"clean\")" ],
29             [ "process-exe=s", qq#Process executor (= "sh" or "perl")#, ] );
30              
31              
32             }
33              
34             sub _ascertain_xvfb_run_presence
35             {
36 0     0     my $path = which('xvfb-run');
37 0 0         if ( not defined($path) )
38             {
39 0           die
40             "Cannot find xvfb-run ! It is required for tests to succeed: see https://gitlab.gnome.org/GNOME/gimp/-/issues/2884";
41             }
42 0           return;
43             }
44              
45             sub _ascertain_lack_of_gtk_warnings
46             {
47 0     0     my $path = which('gvim');
48 0 0         if ( defined($path) )
49             {
50 0           my $stderr = `"$path" -u NONE -U NONE -f /dev/null +q 2>&1`;
51 0 0         if ( $stderr =~ /\S/ )
52             {
53 0           die
54             "There may be gtk warnings (e.g: in KDE Plasma 5 on Fedora 32 ). Please fix them.";
55             }
56             }
57 0           return;
58             }
59              
60             sub _ascertain_gjs_presence
61             {
62 0     0     my $path = which('gjs');
63 0 0         if ( not defined($path) )
64             {
65 0           die
66             "gjs must be present for GIMP's tests to succeed - please install it (see: https://gitlab.gnome.org/GNOME/gimp/-/issues/7341 )";
67             }
68 0           return;
69             }
70              
71             sub execute
72             {
73 0     0 1   my ( $self, $opt, $args ) = @_;
74              
75 0   0       my $mode = ( $opt->{mode} || 'build' );
76 0 0 0       if ( not( ( $mode eq 'clean' ) or ( $mode eq 'build' ) ) )
77             {
78 0           die "Unsupported mode '$mode'!";
79             }
80              
81 0   0       my $_process_executor = ( $opt->{process_exe} || 'perl' );
82 0 0 0       if (
83             not( ( $_process_executor eq 'sh' )
84             or ( $_process_executor eq 'perl' ) )
85             )
86             {
87 0           die "Unsupported process-exe '$_process_executor'!";
88             }
89              
90 0           my $worker = App::gimpgitbuild::API::Worker->new(
91             { _mode => $mode, _process_executor => $_process_executor, } );
92              
93 0           my $env = App::gimpgitbuild::API::GitBuild->new()->new_env();
94 0           $ENV{LD_LIBRARY_PATH} = $env->{LD_LIBRARY_PATH};
95 0           $ENV{PATH} = $env->{PATH};
96 0           $ENV{PKG_CONFIG_PATH} = $env->{PKG_CONFIG_PATH};
97 0           $ENV{XDG_DATA_DIRS} = $env->{XDG_DATA_DIRS};
98 0           _ascertain_xvfb_run_presence();
99 0           _ascertain_lack_of_gtk_warnings();
100 0           _ascertain_gjs_presence();
101              
102 0           $worker->_run_the_mode_on_all_repositories();
103              
104 1     1   680 use Term::ANSIColor qw/ colored /;
  1         8130  
  1         880  
105 0   0       print colored( [ $ENV{HARNESS_SUMMARY_COLOR_SUCCESS} || 'bold green' ],
106             "\n== Success ==\n\n" );
107 0           return;
108             }
109              
110             1;
111              
112             __END__