lib/VSGDR/UnitTest/replaceGDRSql.pl untested

filter: Statementstmt 0.0% 0 / 99 Branchbran 0.0% 0 / 12 Conditioncond 0.0% 0 / 2 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 18 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 133 SCAR 6.9
CC
1
Cov
0%
END
2.0
getFile
2.0
BEGIN
2.0
CRAP 2.0
1 #!/bin/perl
2  
3 use strict;
4 use warnings;
5 use autodie qw(:all);
6 no indirect ':fatal';
7  
8 use 5.010;
9 use Carp;
10  
11 our $opt_infile;
12 our $opt_action;
13 our $opt_test;
14 our $opt_sinfile;
15  
16 use Getopt::Euclid qw( :vars<opt_> );
17 use List::MoreUtils qw{firstidx} ;
18 use version ; our $VERSION = qv('1.0.1');
19  
20 use VSGDR::UnitTest::TestSet::Test;
21 use VSGDR::UnitTest::TestSet::Test::TestCondition;
22 use VSGDR::UnitTest::TestSet::Representation;
23  
24 use VSGDR::UnitTest::TestSet::Resx;
25  
26 use Data::Dumper;
27  
28 use IO::File ;
29 #use Smart::Comments;
30 use File::Basename;
31  
32 my %ValidParserMakeArgs = ( vb => "NET::VB"
33 , cs => "NET::CS"
34 , xls => "XLS"
35 , xml => "XML"
36 ) ;
37 my %ValidParserMakeArgs2 = ( vb => "NET2::VB"
38 , cs => "NET2::CS"
39 ) ;
40
41 #my @validSuffixes = keys %ValidParserMakeArgs ;
42 my @validSuffixes = map { '.'.$_ } keys %ValidParserMakeArgs ;
43  
44  
45 croak 'no input file' unless defined($opt_infile) ;
46 my $infile;
47 $infile = $opt_infile;
48  
49 my($infname, $directories, $insfx) = fileparse($infile , @validSuffixes);
50 croak 'Invalid input file' unless defined $insfx ;
51 $insfx = lc $insfx ;
52 $insfx = substr $insfx,1;
53 #warn Dumper $insfx;
54  
55 ### Validate parameters
56 die 'Invalid input file' unless exists $ValidParserMakeArgs{$insfx} ;
57  
58 ### Build parsers
59  
60 my %Parsers = () ;
61 $Parsers{${insfx}} = VSGDR::UnitTest::TestSet::Representation->make( { TYPE => $ValidParserMakeArgs{${insfx}} } );
62 # if input is in a .net language, add in a .net2 parser to the list
63 if ( firstidx { $_ eq ${insfx} } ['cs','vb'] != -1 ) {
64 $Parsers{"${insfx}2"} = VSGDR::UnitTest::TestSet::Representation->make( { TYPE => $ValidParserMakeArgs2{${insfx}} } );
65 }
66  
67  
68 my $resxname = $infname . ".resx" ;
69 my $o_resx = VSGDR::UnitTest::TestSet::Resx->new() ;
70  
71 ### Deserialise tests scripts
72 $o_resx->deserialise($resxname) ;
73 my $rh_testScripts = $o_resx->scripts() ;
74 #warn Dumper $rh_testScripts ;
75 #exit ;
76  
77 my %test_Actions =
78 ( test => VSGDR::UnitTest::TestSet::Test->testActionLiteral()
79 , pre => VSGDR::UnitTest::TestSet::Test->preTestActionLiteral()
80 , post => VSGDR::UnitTest::TestSet::Test->postTestActionLiteral()
81 , init => VSGDR::UnitTest::TestSet->initializeActionLiteral()
82 , cleanup => VSGDR::UnitTest::TestSet->cleanupActionLiteral()
83 ) ;
84  
85 #say Dumper %test_Suffixes;
86 #exit;
87  
88 my $action = $test_Actions{${opt_action}} ;
89 croak "Invalid action ${opt_action}" unless $action;
90  
91 if ( exists $rh_testScripts->{"${opt_test}_${action}"} ) {
92 $rh_testScripts->{"${opt_test}_${action}"} = getFile($opt_sinfile);
93 #$o_resx->scripts(rh_testScripts) ;
94 $o_resx->serialise($infname.'.resx',$o_resx) ;
95
96 }
97 else {
98 croak "Invalid test/action $opt_test/$opt_action" ;
99 }
100  
101 ### End
102  
103 exit ;
104  
105 END {}
106  
107  
108 sub getFile {
109 local $_ = undef ;
110 my $infile = shift or croak 'no input filename' ;
111 my $SQL = q{} ;
112 open my $infh, '<', $infile ;
113 { local $/=undef ; $SQL = <$infh> ; close $infh ; } ;
114 return scalar $SQL ;
115 }
116  
117  
118 __END__