| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | #!/usr/bin/perl -w | 
| 2 | 1 |  |  | 1 |  | 141669 | use strict; | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 65 |  | 
| 3 |  |  |  |  |  |  |  | 
| 4 | 1 |  |  | 1 |  | 491 | use Test::More tests => 21; | 
|  | 1 |  |  |  |  | 17667 |  | 
|  | 1 |  |  |  |  | 8 |  | 
| 5 | 1 |  |  | 1 |  | 1339 | use Test::Exception; | 
|  | 1 |  |  |  |  | 2720 |  | 
|  | 1 |  |  |  |  | 3 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 1 |  |  | 1 |  | 598 | use Data::Dumper; | 
|  | 1 |  |  |  |  | 6903 |  | 
|  | 1 |  |  |  |  | 50 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 1 |  |  | 1 |  | 277 | use lib "../lib"; | 
|  | 1 |  |  |  |  | 522 |  | 
|  | 1 |  |  |  |  | 7 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 | 1 |  |  | 1 |  | 76518 | use_ok("Devel::PerlySense"); | 
|  | 1 |  |  |  |  | 664 |  | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 2 |  | 
|  | 1 |  |  |  |  | 5 |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  |  | 
| 14 | 1 | 50 |  | 1 |  | 690 | BEGIN { -d "t" and chdir("t"); } | 
| 15 |  |  |  |  |  |  |  | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 1 |  |  |  |  | 272 | my $dot = "[.]"; | 
| 20 | 1 |  |  |  |  | 3 | my $up = "${dot}${dot}"; | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 1 |  |  |  |  | 4 | note("Identify which file type to debug"); | 
| 25 |  |  |  |  |  |  | { | 
| 26 | 1 |  |  |  |  | 53 | my $dirBase = "data/project/with-perlysenseproject"; | 
|  | 1 |  |  |  |  | 3 |  | 
| 27 | 1 |  |  |  |  | 2 | my $dirProject = "$dirBase/source"; | 
| 28 | 1 |  |  |  |  | 3 | my $dirTest = "$dirProject/bogus/t"; | 
| 29 | 1 |  |  |  |  | 2 | my $fileTest = "$dirTest/Game-Lawn.t"; | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  |  | 
| 32 | 1 |  |  |  |  | 3 | ok( | 
| 33 |  |  |  |  |  |  | my $oPerlySense = Devel::PerlySense->new(), | 
| 34 |  |  |  |  |  |  | "New PerlySense object ok", | 
| 35 |  |  |  |  |  |  | ); | 
| 36 | 1 |  |  |  |  | 189 | ok($oPerlySense->setFindProject(file => $fileTest), "Found Project"); | 
| 37 | 1 |  |  |  |  | 241 | ok(my $oProject = $oPerlySense->oProject, "  got project property"); | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  |  | 
| 40 | 1 |  |  |  |  | 183 | note("  Bad config formats"); | 
| 41 |  |  |  |  |  |  | { | 
| 42 | 1 |  |  |  |  | 37 | local $oProject->rhConfig->{debug_file}->[0]->{rex} = undef; | 
|  | 1 |  |  |  |  | 5 |  | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | throws_ok( | 
| 45 | 1 |  |  | 1 |  | 30 | sub { $oProject->rhConfigTypeForFile( | 
| 46 |  |  |  |  |  |  | file      => $fileTest, | 
| 47 |  |  |  |  |  |  | keyConfig => "debug_file", | 
| 48 |  |  |  |  |  |  | ) }, | 
| 49 | 1 |  |  |  |  | 40 | qr/Missing rex key/, | 
| 50 |  |  |  |  |  |  | "Missing regex found ok", | 
| 51 |  |  |  |  |  |  | ); | 
| 52 |  |  |  |  |  |  | } | 
| 53 |  |  |  |  |  |  |  | 
| 54 |  |  |  |  |  |  | { | 
| 55 | 1 |  |  |  |  | 290 | local $oProject->rhConfig->{debug_file}->[0]->{rex} = 'abc('; | 
|  | 1 |  |  |  |  | 3 |  | 
| 56 |  |  |  |  |  |  |  | 
| 57 |  |  |  |  |  |  | throws_ok( | 
| 58 | 1 |  |  | 1 |  | 16 | sub { $oProject->rhConfigTypeForFile(file => $fileTest, keyConfig => "debug_file") }, | 
| 59 | 1 |  |  |  |  | 36 | qr/Invalid rex value in config/, | 
| 60 |  |  |  |  |  |  | "Invalid regex found ok", | 
| 61 |  |  |  |  |  |  | ); | 
| 62 |  |  |  |  |  |  | } | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | { | 
| 67 | 1 |  |  |  |  | 263 | local $oProject->rhConfig->{debug_file} = []; | 
|  | 1 |  |  |  |  | 4 |  | 
| 68 |  |  |  |  |  |  |  | 
| 69 |  |  |  |  |  |  | throws_ok( | 
| 70 | 1 |  |  | 1 |  | 16 | sub { $oProject->rhConfigTypeForFile(file => $fileTest, keyConfig => "debug_file") }, | 
| 71 | 1 |  |  |  |  | 35 | qr/No run_perl rex matched the/, | 
| 72 |  |  |  |  |  |  | "No matching type found ok", | 
| 73 |  |  |  |  |  |  | ); | 
| 74 |  |  |  |  |  |  | } | 
| 75 |  |  |  |  |  |  |  | 
| 76 |  |  |  |  |  |  |  | 
| 77 | 1 |  |  |  |  | 195 | my $rhConfigType; | 
| 78 |  |  |  |  |  |  |  | 
| 79 | 1 |  |  |  |  | 3 | ok($rhConfigType = $oProject->rhConfigTypeForFile(file => "abc.t", keyConfig => "debug_file"), "Identify a .t file"); | 
| 80 | 1 |  |  |  |  | 188 | is($rhConfigType->{moniker}, "Test", "  correct moniker"); | 
| 81 |  |  |  |  |  |  |  | 
| 82 | 1 |  |  |  |  | 195 | ok($rhConfigType = $oProject->rhConfigTypeForFile(file => "abc.pm", keyConfig => "debug_file"), "Identify a .pm file"); | 
| 83 | 1 |  |  |  |  | 185 | is($rhConfigType->{moniker}, "Module", "  correct moniker"); | 
| 84 |  |  |  |  |  |  |  | 
| 85 | 1 |  |  |  |  | 187 | ok($rhConfigType = $oProject->rhConfigTypeForFile(file => "abc.pl", keyConfig => "debug_file"), "Identify a .pl file"); | 
| 86 | 1 |  |  |  |  | 186 | is($rhConfigType->{moniker}, "Script", "  correct moniker"); | 
| 87 |  |  |  |  |  |  |  | 
| 88 | 1 |  |  |  |  | 195 | ok($rhConfigType = $oProject->rhConfigTypeForFile(file => "abc", keyConfig => "debug_file"), "Identify everything else"); | 
| 89 | 1 |  |  |  |  | 187 | is($rhConfigType->{moniker}, "Script (no .pl)", "  correct moniker"); | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | } | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  |  | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  |  | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  |  | 
| 98 | 1 |  |  |  |  | 186 | note("Debug test file inside dir"); | 
| 99 |  |  |  |  |  |  | { | 
| 100 |  |  |  |  |  |  | #This is to avoid identifying the .PerlySenseProject directory | 
| 101 |  |  |  |  |  |  | #_of_the_development_project_ to interfere with the test which | 
| 102 |  |  |  |  |  |  | #expects a free way all the way up to the root without any | 
| 103 |  |  |  |  |  |  | #projects. | 
| 104 | 1 |  |  | 1 |  | 36 | no warnings; | 
|  | 1 |  |  |  |  | 4 |  | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 1259 |  | 
| 105 |  |  |  |  |  |  | local *Devel::PerlySense::Project::newFindExplicit = sub { | 
| 106 | 1 |  |  | 1 |  | 8 | undef; | 
| 107 | 1 |  |  |  |  | 5 | }; | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  |  | 
| 110 | 1 |  |  |  |  | 2 | my $dirBase = "data/project/with-dir"; | 
| 111 | 1 |  |  |  |  | 2 | my $dirProject = "$dirBase/source"; | 
| 112 | 1 |  |  |  |  | 2 | my $dirTest = "$dirProject/t"; | 
| 113 | 1 |  |  |  |  | 3 | my $fileTest = "$dirTest/Game-Lawn.t"; | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  |  | 
| 116 | 1 |  |  |  |  | 5 | ok( | 
| 117 |  |  |  |  |  |  | my $oPerlySense = Devel::PerlySense->new(), | 
| 118 |  |  |  |  |  |  | "New PerlySense object ok", | 
| 119 |  |  |  |  |  |  | ); | 
| 120 | 1 |  |  |  |  | 185 | ok( | 
| 121 |  |  |  |  |  |  | my $rhDebug = $oPerlySense->rhDebugFile(file => $fileTest), | 
| 122 |  |  |  |  |  |  | "rhDebugFile returned a data structure", | 
| 123 |  |  |  |  |  |  | ); | 
| 124 | 1 |  |  |  |  | 284 | is(scalar keys %$rhDebug, 3, "  correct item count"); | 
| 125 | 1 |  |  |  |  | 188 | is($rhDebug->{type_source_file}, "Test", "    type_source_file"); | 
| 126 | 1 |  |  |  |  | 189 | like( | 
| 127 |  |  |  |  |  |  | $rhDebug->{command_debug}, | 
| 128 |  |  |  |  |  |  | qr|perl -d "-I." "-Ilib" "t.Game-Lawn.t"|, | 
| 129 |  |  |  |  |  |  | "    command_debug", | 
| 130 |  |  |  |  |  |  | ); | 
| 131 | 1 |  |  |  |  | 189 | like($rhDebug->{dir_debug_from}, qr|t.data.project.with-dir.source|, "    dir_debug_from"); | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  | } | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  |  | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  |  | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | __END__ |