File Coverage

blib/lib/CPAN/Reporter/Smoker/OpenBSD.pm
Criterion Covered Total %
statement 33 37 89.1
branch 5 8 62.5
condition 1 2 50.0
subroutine 7 7 100.0
pod 2 2 100.0
total 48 56 85.7


line stmt bran cond sub pod time code
1             package CPAN::Reporter::Smoker::OpenBSD;
2 2     2   117481 use warnings;
  2         9  
  2         55  
3 2     2   9 use strict;
  2         3  
  2         34  
4 2     2   8 use Exporter 'import';
  2         3  
  2         59  
5 2     2   2629 use CPAN;
  2         546759  
  2         827  
6 2     2   42 use CPAN::HandleConfig;
  2         11  
  2         950  
7              
8             our @EXPORT_OK = qw(is_distro_ok block_distro);
9              
10             our $VERSION = '0.021'; # VERSION
11              
12             =pod
13              
14             =head1 NAME
15              
16             CPAN::Reporter::Smoker::OpenBSD - set of scripts to manage a
17             L on OpenBSD
18              
19             =head1 DEPRECATION WARNING
20              
21             This distribution was replaced by L distribution and this
22             is the latest release that will be maintained at CPAN.
23              
24             You're advised to start using L as soon as possible.
25              
26             =head1 DESCRIPTION
27              
28             This module exports some functions used to manage a smoker testing machine based L.
29              
30             =head1 EXPORTS
31              
32             Only the C C is exported, if explicit requested.
33              
34             =head2 is_distro_ok
35              
36             Expects as parameter a string in the format /.
37              
38             It executes some very basic testing against the string.
39              
40             Returns true or false depending if the string passes the tests. It will also C if things are not going OK.
41              
42             =cut
43              
44             sub is_distro_ok {
45 151     151 1 35211 my $distro = shift;
46              
47 151 50       310 unless ( defined($distro) ) {
48 0         0 warn "--distro is a required parameter!\n\n";
49 0         0 return 0;
50             }
51              
52 151 100       794 unless ( $distro =~ /^\w+\/[\w-]+$/ ) {
53 1         10 warn "invalid string '$distro' in --distro!\n\n";
54 1         7 return 0;
55             }
56             else {
57 150         483 return 1;
58             }
59             }
60              
61             =head2 block_distro
62              
63             Blocks a distribution to be tested under the smoker by using a distroprefs file.
64              
65             Expects as parameters:
66              
67             =over
68              
69             =item 1.
70              
71             a distribution name (for example, "JOHNDOE/Some-Distro-Name").
72              
73             =item 2.
74              
75             The perl interpreter (which is in execution) configuration.
76              
77             =item 3.
78              
79             An comment to include in the distroprefs file.
80              
81             =back
82              
83             It returns a hash reference containing keys/values that could be directly
84             serialized to YAML (or other format) but the C key, that contains
85             a suggest complete path to the distroprefs file (based on the L C configuration
86             client.
87              
88             If there is an already file created as defined in C key, it will C and return C.
89              
90             =cut
91              
92             sub block_distro {
93 2     2 1 429 my ( $distro, $perl_info, $comment ) = @_;
94 2         5 my $distribution = '^' . $distro;
95 2         5 my $filename = "$distro.yml";
96 2         23 $filename =~ s/\//./;
97              
98 2   50     15 my %data = (
99             comment => $comment || 'Tests hang smoker',
100             match => {
101             distribution => $distribution,
102             perlconfig => $perl_info
103             },
104             disabled => 1
105             );
106              
107 2         10 CPAN::HandleConfig->load;
108 2         132 my $prefs_dir = $CPAN::Config->{prefs_dir};
109 2 50       27 die "$prefs_dir does not exist or it is not readable\n"
110             unless ( -d $prefs_dir );
111 2         22 my $full_path = File::Spec->catfile( $prefs_dir, $filename );
112              
113 2 50       31 if ( -f $full_path ) {
114 0         0 warn "$full_path already exists, will not overwrite it.";
115 0         0 return;
116             }
117             else {
118 2         6 $data{full_path} = $full_path;
119 2         10 return \%data;
120             }
121             }
122              
123             =head1 SEE ALSO
124              
125             For more details about those programs interact with the smoker and L, be sure
126             to read the documentation about L client, especially the part about DistroPrefs.
127              
128             You will also want to take a look at the following programs documentation:
129              
130             =over
131              
132             =item *
133              
134             C
135              
136             =item *
137              
138             C
139              
140             =item *
141              
142             C
143              
144             =back
145              
146             =head1 AUTHOR
147              
148             Alceu Rodrigues de Freitas Junior, Earfreitas@cpan.orgE
149              
150             =head1 COPYRIGHT AND LICENSE
151              
152             This software is copyright (c) 2017 of Alceu Rodrigues de Freitas Junior, arfreitas@cpan.org
153              
154             This file is part of CPAN OpenBSD Smoker.
155              
156             CPAN OpenBSD Smoker is free software: you can redistribute it and/or modify
157             it under the terms of the GNU General Public License as published by
158             the Free Software Foundation, either version 3 of the License, or
159             (at your option) any later version.
160              
161             CPAN OpenBSD Smoker is distributed in the hope that it will be useful,
162             but WITHOUT ANY WARRANTY; without even the implied warranty of
163             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
164             GNU General Public License for more details.
165              
166             You should have received a copy of the GNU General Public License
167             along with CPAN OpenBSD Smoker. If not, see .
168              
169             =cut
170              
171             1;