aboutsummaryrefslogtreecommitdiff
path: root/t/prep.pl
diff options
context:
space:
mode:
Diffstat (limited to 't/prep.pl')
-rwxr-xr-xt/prep.pl47
1 files changed, 47 insertions, 0 deletions
diff --git a/t/prep.pl b/t/prep.pl
index e2fe9bf..c51a200 100755
--- a/t/prep.pl
+++ b/t/prep.pl
@@ -1,5 +1,6 @@
#!/usr/bin/perl
+use 5.16.0;
use strict;
use warnings FATAL => 'all';
use File::Copy;
@@ -8,6 +9,52 @@ use Tie::File;
chomp (my $pwd = `pwd`);
mkdir "$pwd/SBO" unless -d "$pwd/SBO";
copy ('/home/d4wnr4z0r/projects/sbotools/SBO-Lib/lib/SBO/Lib.pm', "$pwd/SBO");
+
+open my $write, '>>', "$pwd/SBO/Lib.pm";
+
+sub pr ($) {
+ my $thing = shift;
+ print {$write} "our \$$thing = 1;\n";
+}
+
+for my $thing (qw(interactive compat32 no_readme jobs distclean noclean no_install no_reqs)) {
+ pr $thing;
+}
+
+print {$write} "my \%locations;\n";
+print {$write} "my \%options = (nothing => 'to see here');\n";
+
+sub get_subs ($) {
+ my $read = shift;
+ my $begin_regex = qr/^sub\s+[a-z0-9_]+/;
+ my $usage_regex = qr/^sub\s+show_usage/;
+ my $end_regex = qr/^}$/;
+ my $begin = 0;
+ my $end = 0;
+ while (my $line = <$read>) {
+ if (! $begin) {
+ if ($line =~ $begin_regex) {
+ if ($line !~ $usage_regex) {
+ $end = 0, $begin++, print {$write} $line;
+ }
+ }
+ } elsif (! $end) {
+ if ($line =~ $end_regex) {
+ $begin = 0, $end++, print {$write} $line;
+ } else {
+ print {$write} $line;
+ }
+ }
+ }
+}
+
+for my $file (qw(sbocheck sboclean sboconfig sbofind sboupgrade)) {
+ open my $read, '<', "../$file";
+ get_subs $read;
+ close $read;
+}
+close $write;
+
my @subs;
open my $file_h, '<', "$pwd/SBO/Lib.pm";
my $regex = qr/^sub\s+([^\s]+)\s+/;