12 open(my $fh, '<', shift) || return;
13 if(my $whole_file = <$fh>) {
20 sub extract_synopsis {
21 my $string = shift || return;
22 my $head_or_cut = qr[head|cut]x;
23 if($string=~m/^=head1 SYNOPSIS\n(.*?)^=$head_or_cut/sm) {
25 $extracted=~s/^\S.+?$//m; # wipe out non code lines in pod
26 my $begin_end = qr[begin|end]x;
27 $extracted=~s/\n^=$begin_end testinfo\n\n//smg; # remove test block
34 sub normalize_indent {
35 my $extracted = shift || return;
36 if($extracted=~m/([ \t]+)(\S+)/) {
37 $extracted=~s/^$1//gsm;
44 sub create_test_string {
45 my $extracted = shift || return;
48 use warnings FATAL => 'all';
49 use Test::More qw(no_plan);
54 sub create_test_path_from_lib {
55 my $module_name = shift;
56 $module_name =~s/\.pm$//;
57 return File::Spec->catfile($Bin, '..', 't', 'synopsis', lc($module_name).'.t');
60 sub create_or_update_test_file {
61 my ($target, $synopsis_string) = @_;
62 return unless $synopsis_string && $target;
63 print "Writing $target\n";
64 open my $syn_test, '>', $target
65 or die "Couldn't open $target - you screwed something up. Go fix it.\n";
66 print $syn_test $synopsis_string;
71 create_test_path_from_lib $_;
76 slurp_file $File::Find::name;
77 create_or_update_test_file
82 find(\&wanted, File::Spec->catfile($Bin, '..', 'lib'));