Преглед изворни кода

Fixes #6: found issue with testrail-report and subtests.

George S. Baugh пре 11 година
родитељ
комит
e5a4674078
4 измењених фајлова са 54 додато и 4 уклоњено
  1. 0 2
      bin/testrail-report
  2. 37 1
      t/Test-Rail-Parser.t
  3. 8 0
      t/test_subtest.tap
  4. 9 1
      t/testrail-report.t

+ 0 - 2
bin/testrail-report

@@ -208,7 +208,6 @@ if ($file) {
     open($fh,'<',$file);
     while (<$fh>) {
         $_ = colorstrip($_); #strip prove brain damage
-        s/^\s*//g; #Fix more brain damage
         if ($_ =~ /(.*)\s\.\.$/) {
             #File marker from default prove
             unless ($_ =~ /^[ok|not ok] - /) {
@@ -232,7 +231,6 @@ if ($file) {
     }
     while (<>) {
         $_ = colorstrip($_); #strip prove brain damage
-        s/^\s*//g; #Fix prove brain damage
         if ($_ =~ /(.*)\s\.\.$/) {
             #File marker from default prove
             unless ($_ =~ /^[ok|not ok] - /) {

+ 37 - 1
t/Test-Rail-Parser.t

@@ -6,7 +6,7 @@ use warnings;
 use TestRail::API;
 use Test::LWP::UserAgent::TestRailMock;
 use Test::Rail::Parser;
-use Test::More 'tests' => 12;
+use Test::More 'tests' => 15;
 use Test::Fatal qw{exception};
 
 #Same song and dance as in TestRail-API.t
@@ -128,4 +128,40 @@ if (!$res) {
     is($tap->{'errors'},0,"No errors encountered uploading case results");
 }
 
+#Default mode
+undef $tap;
+$fcontents = "
+fake.test ..
+1..2
+ok 1 - STORAGE TANKS SEARED
+    #Subtest NOT SO SEARED AFTER ARR
+    ok 1 - STROGGIFY POPULATION CENTERS
+    not ok 2 - STROGGIFY POPULATION CENTERS
+#goo
+not ok 2 - NOT SO SEARED AFTER ARR
+";
+
+$res = exception {
+    $tap = Test::Rail::Parser->new({
+        'tap'         => $fcontents,
+        'apiurl'      => $apiurl,
+        'user'        => $login,
+        'pass'        => $pw,
+        'debug'       => $debug,
+        'browser'     => $browser,
+        'run'         => 'TestingSuite',
+        'project'     => 'TestProject',
+        'case_per_ok' => 1,
+        'merge'       => 1
+    });
+};
+is($res,undef,"TR Parser doesn't explode on instantiation");
+isa_ok($tap,"Test::Rail::Parser");
+
+if (!$res) {
+    $tap->run();
+    is($tap->{'errors'},0,"No errors encountered uploading case results");
+}
+
+
 0;

+ 8 - 0
t/test_subtest.tap

@@ -0,0 +1,8 @@
+fake.test ..
+1..2
+ok 1 - STORAGE TANKS SEARED
+    #Subtest NOT SO SEARED AFTER ARR
+    ok 1 - STROGGIFY POPULATION CENTERS
+    not ok 2 - STROGGIFY POPULATION CENTERS
+#goo
+not ok 2 - NOT SO SEARED AFTER ARR

+ 9 - 1
t/testrail-report.t

@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More 'tests' => 4;
+use Test::More 'tests' => 6;
 
 my @args = qw{bin/testrail-report --apiurl http://testrail.local --user "test@fake.fake" --password "fake" --project "CRUSH ALL HUMANS" --run "SEND T-1000 INFILTRATION UNITS BACK IN TIME" --mock t/test_multiple_files.tap};
 my $out = `@args`;
@@ -14,3 +14,11 @@ $out = `@args`;
 is($? >> 8, 0, "Exit code OK reported with multiple files (case-ok mode)");
 $matches = () = $out =~ m/Reporting result of case/ig;
 is($matches,4,"Attempts to upload multiple times (case-ok mode)");
+
+@args = qw{bin/testrail-report --apiurl http://testrail.local --user "test@fake.fake" --password "fake" --project "TestProject" --run "TestingSuite" --case-ok --mock t/test_subtest.tap};
+$out = `@args`;
+is($? >> 8, 0, "Exit code OK reported with subtests (case-ok mode)");
+$matches = () = $out =~ m/Reporting result of case/ig;
+is($matches,2,"Attempts to upload do not do subtests (case-ok mode)");
+
+