George S. Baugh před 10 roky
rodič
revize
6478f92b83

+ 4 - 1
Changes

@@ -1,6 +1,9 @@
 Revision history for Perl module TestRail::API
 
-0.033 2016-01-6 TEODESIAN
+0.034 2016-01-?? TEODESIAN
+    - Use Capture::Tiny rahter than IO::CaptureOutput in unit tests
+
+0.033 2016-01-06 TEODESIAN
     - Fix issue where running TestRail::Parser with multiple -j in prove corrupted results
     - Add timestamps to every step reported for better test bottleneck detection
 

+ 1 - 1
dist.ini

@@ -1,6 +1,6 @@
 name = TestRail-API
 main_module = lib/TestRail/API.pm
-version = 0.033
+version = 0.034
 author = George S. Baugh <teodesian@cpan.org>
 license = Perl_5
 copyright_holder = George S. Baugh

+ 2 - 3
t/TestRail-Utils.t

@@ -16,15 +16,14 @@ use Test::Fatal;
 use TestRail::API;
 use TestRail::Utils;
 use Test::LWP::UserAgent::TestRailMock;
-use IO::CaptureOutput qw{capture};
+use Capture::Tiny qw{capture_merged};
 
 use File::Basename qw{dirname};
 
 my ($apiurl,$user,$password);
 
 #check help output
-my $out;
-my $code = capture { TestRail::Utils::help() } \$out;
+my ($out,($code)) = capture_merged { TestRail::Utils::help() };
 is($code,0,"Help works OK");
 like($out,qr/bogus bogus/i,"Displays POD OK");
 

+ 2 - 2
t/testrail-bulk-mark-results.t

@@ -3,7 +3,7 @@ use warnings;
 
 use Test::More "tests" => 4;
 use FindBin;
-use IO::CaptureOutput qw{capture};
+use Capture::Tiny qw{capture_merged};
 
 use lib $FindBin::Bin.'/../bin';
 require 'testrail-bulk-mark-results';
@@ -20,7 +20,7 @@ like($out,qr/set the status of 1 cases to blocked/,"Sets test correctly in singl
 
 @args = qw{--help};
 $0 = $FindBin::Bin.'/../bin/testrail-bulk-mark-results';
-(undef,$code) = capture {TestRail::Bin::BulkMarkResults::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)} \$out, \$out;
+($out,(undef,$code)) = capture_merged {TestRail::Bin::BulkMarkResults::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 0, "Exit code OK asking for help");
 like($out,qr/encoding of arguments/i,"Help output OK");
 

+ 2 - 2
t/testrail-cases.t

@@ -10,7 +10,7 @@ use lib $FindBin::Bin.'/lib';
 use Test::LWP::UserAgent::TestRailMock;
 
 use Test::More "tests" => 6;
-use IO::CaptureOutput qw{capture};
+use Capture::Tiny qw{capture_merged};
 
 #check plan mode
 my @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject -t}, 'HAMBURGER-IZE HUMANITY', qw{-d t --test --extension .test});
@@ -32,6 +32,6 @@ like($out,qr/t\/skipall\.test/,"Shows missing tests");
 #Verify no-match returns non path
 @args = qw{--help};
 $0 = $FindBin::Bin.'/../bin/testrail-cases';
-(undef,$code) = capture {TestRail::Bin::Cases::run('args' => \@args)} \$out, \$out;
+($out,(undef,$code)) = capture_merged {TestRail::Bin::Cases::run('args' => \@args)};
 is($code, 0, "Exit code OK asking for help");
 like($out,qr/encoding of arguments/i,"Help output OK");

+ 2 - 3
t/testrail-lock.t

@@ -3,7 +3,7 @@ use warnings;
 
 use Test::More "tests" => 4;
 use FindBin;
-use IO::CaptureOutput qw{capture};
+use Capture::Tiny qw{capture_merged};
 
 use lib $FindBin::Bin.'/../bin';
 require 'testrail-lock';
@@ -13,8 +13,7 @@ use Test::LWP::UserAgent::TestRailMock;
 
 my @args = qw{--help};
 $0 = $FindBin::Bin.'/../bin/testrail-lock';
-my $out;
-my (undef,$code) = capture {TestRail::Bin::Lock::run('args' => \@args)} \$out, \$out;
+my ($out,(undef,$code)) = capture_merged {TestRail::Bin::Lock::run('args' => \@args)};
 is($code, 0, "Exit code OK asking for help");
 like($out,qr/encoding of arguments/i,"Help output OK");
 

+ 9 - 10
t/testrail-report.t

@@ -6,61 +6,60 @@ use lib $FindBin::Bin.'/../bin';
 require 'testrail-report';
 
 use Test::More 'tests' => 16;
-use IO::CaptureOutput qw{capture};
+use Capture::Tiny qw{capture_merged};
 
 use lib $FindBin::Bin.'/lib';
 use Test::LWP::UserAgent::TestRailMock;
 
 my @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project}, "CRUSH ALL HUMANS", '--run', "SEND T-1000 INFILTRATION UNITS BACK IN TIME", qw{ t/test_multiple_files.tap});
-my $out;
-my (undef,$code) = capture {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)} \$out, \$out;
+my ($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 0, "Exit code OK reported with multiple files");
 my $matches = () = $out =~ m/Reporting result of case/ig;
 is($matches,2,"Attempts to upload multiple times");
 
 @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project}, "CRUSH ALL HUMANS", '--run', "SEND T-1000 INFILTRATION UNITS BACK IN TIME", qw{--case-ok  t/test_multiple_files.tap});
-(undef,$code) = capture {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)} \$out, \$out;
+($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 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)");
 
 #Test version, case-ok
 @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run TestingSuite --case-ok --version 1.0.14  t/test_subtest.tap});
-(undef,$code) = capture {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)} \$out, \$out;
+($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 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)");
 
 #Test plans/configs
 @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run}, "Executing the great plan", qw{--plan GosPlan --config testConfig --case-ok  t/test_subtest.tap});
-(undef,$code) = capture {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)} \$out, \$out;
+($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 0, "Exit code OK reported with plans");
 $matches = () = $out =~ m/Reporting result of case.*OK/ig;
 is($matches,2,"Attempts to to plans work");
 
 #Test that spawn works
 @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run TestingSuite2 --testsuite_id 9 --case-ok  t/test_subtest.tap});
-(undef,$code) = capture {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)} \$out, \$out;
+($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 0, "Exit code OK reported with spawn");
 $matches = () = $out =~ m/Reporting result of case.*OK/ig;
 is($matches,2,"Attempts to spawn work: testsuite_id");
 
 #Test that spawn works w/sections
 @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run TestingSuite2 --testsuite}, "HAMBURGER-IZE HUMANITY", qw{--case-ok --section}, "CARBON LIQUEFACTION", qw{ t/test_subtest.tap});
-(undef,$code) = capture {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)} \$out, \$out;
+($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 0, "Exit code OK reported with spawn");
 $matches = () = $out =~ m/with specified sections/ig;
 is($matches,1,"Attempts to spawn work: testsuite name");
 
 #Test that the autoclose option works
 @args = (qw{--apiurl http://testrail.local --user test@fake.fake --password fake --project TestProject --run FinalRun --plan FinalPlan --config testConfig --case-ok --autoclose  t/fake.tap});
-(undef,$code) = capture {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)} \$out, \$out;
+($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('browser' => $Test::LWP::UserAgent::TestRailMock::mockObject, 'args' => \@args)};
 is($code, 0, "Exit code OK when doing autoclose");
 like($out,qr/closing plan/i,"Run closure reported to user");
 
 #Test that help works
 @args = qw{--help};
 $0 = $FindBin::Bin.'/../bin/testrail-report';
-(undef,$code) = capture {TestRail::Bin::Report::run('args' => \@args)} \$out, \$out;
+($out,(undef,$code)) = capture_merged {TestRail::Bin::Report::run('args' => \@args)};
 is($code, 0, "Exit code OK asking for help");
 like($out,qr/encoding of arguments/i,"Help output OK");

+ 2 - 2
t/testrail-runs.t

@@ -10,7 +10,7 @@ use lib $FindBin::Bin.'/lib';
 use Test::LWP::UserAgent::TestRailMock;
 
 use Test::More 'tests' => 12;
-use IO::CaptureOutput qw{capture};
+use Capture::Tiny qw{capture_merged};
 
 #check status filters
 my @args = qw{--apiurl http://testrail.local --user test@fake.fake --password fake -j TestProject };
@@ -50,6 +50,6 @@ like($out,qr/no runs found/i,"Gets no run correctly when filtering by unassigned
 #Verify no-match returns non path
 @args = qw{--help};
 $0 = $FindBin::Bin.'/../bin/testrail-runs';
-(undef,$code) = capture {TestRail::Bin::Runs::run('args' => \@args)} \$out, \$out;
+($out,(undef,$code)) = capture_merged {TestRail::Bin::Runs::run('args' => \@args)};
 is($code, 0, "Exit code OK asking for help");
 like($out,qr/encoding of arguments/i,"Help output OK");

+ 2 - 2
t/testrail-tests.t

@@ -4,7 +4,7 @@ use warnings;
 use Test::More "tests" => 31;
 use Test::Fatal;
 use FindBin;
-use IO::CaptureOutput qw{capture};
+use Capture::Tiny qw{capture_merged};
 
 use lib $FindBin::Bin.'/../bin';
 require 'testrail-tests';
@@ -101,6 +101,6 @@ like($out,qr/NOT SO SEARED AFTER ARR/,"Gets test correctly in orphan mode");
 #Verify no-match returns non path
 @args = qw{--help};
 $0 = $FindBin::Bin.'/../bin/testrail-tests';
-(undef,$code) = capture {TestRail::Bin::Tests::run('args' => \@args)} \$out, \$out;
+($out,(undef,$code)) = capture_merged {TestRail::Bin::Tests::run('args' => \@args)};
 is($code, 0, "Exit code OK asking for help");
 like($out,qr/encoding of arguments/i,"Help output OK");