Selaa lähdekoodia

Fix #95: pass args to binaries correctly, add spot check tests

George S. Baugh 9 vuotta sitten
vanhempi
sitoutus
fa9e193538

+ 3 - 0
Changes

@@ -1,5 +1,8 @@
 Revision history for Perl module TestRail::API
 
+0.035 2016-04-17 TEODESIAN
+    - Fix testrail-report and testrail-cases broken binary arg passing
+
 0.034 2016-02-18 TEODESIAN
     - Use Capture::Tiny rahter than IO::CaptureOutput in unit tests
     - Allow users to signal Test::Rail::Parser to set a custom status

+ 1 - 1
bin/testrail-cases

@@ -98,7 +98,7 @@ use Getopt::Long qw{GetOptionsFromArray};
 use File::HomeDir qw{my_home};
 
 if (!caller()) {
-    my ($out,$code) = run('args' => @ARGV);
+    my ($out,$code) = run('args' => \@ARGV);
     print $out;
     exit $code;
 }

+ 3 - 3
bin/testrail-report

@@ -121,7 +121,7 @@ use Test::Rail::Parser;
 use File::HomeDir qw{my_home};
 
 if (!caller()) {
-    my ($out,$code) = run(@ARGV);
+    my ($out,$code) = run('args' => \@ARGV);
     print $out;
     exit $code;
 }
@@ -131,8 +131,6 @@ sub run {
     my %params = @_;
     my %opts;
 
-    print "testrail-report\n----------------------\n";
-
     #parse switches
     GetOptionsFromArray($params{'args'},
         'run=s'          => \$opts{run},
@@ -168,6 +166,8 @@ sub run {
 
     die "ERROR: Interactive mode not allowed when piping input.  See --help for options." if ( !$opts{run} || !$opts{apiurl} || !$opts{password} || !$opts{user} || !$opts{project} );
 
+    print "testrail-report\n----------------------\n";
+
     my @files = TestRail::Utils::TAP2TestFiles($file);
 
     TestRail::Utils::interrogateUser(\%opts,qw{apiurl user password project run});

+ 5 - 1
t/testrail-bulk-mark-results.t

@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More "tests" => 4;
+use Test::More "tests" => 5;
 use FindBin;
 use Capture::Tiny qw{capture_merged};
 
@@ -24,4 +24,8 @@ $0 = $FindBin::Bin.'/../bin/testrail-bulk-mark-results';
 is($code, 0, "Exit code OK asking for help");
 like($out,qr/encoding of arguments/i,"Help output OK");
 
+#Make sure that the binary itself processes args correctly
+$out = `$0 --help`;
+like($out,qr/encoding of arguments/i,"Appears we can run binary successfully");
+
 #TODO more thorough testing

+ 5 - 1
t/testrail-cases.t

@@ -9,7 +9,7 @@ require 'testrail-cases';
 use lib $FindBin::Bin.'/lib';
 use Test::LWP::UserAgent::TestRailMock;
 
-use Test::More "tests" => 6;
+use Test::More "tests" => 7;
 use Capture::Tiny qw{capture_merged};
 
 #check plan mode
@@ -35,3 +35,7 @@ $0 = $FindBin::Bin.'/../bin/testrail-cases';
 ($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");
+
+#Make sure that the binary itself processes args correctly
+$out = `$0 --help`;
+like($out,qr/encoding of arguments/i,"Appears we can run binary successfully");

+ 5 - 1
t/testrail-lock.t

@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More "tests" => 4;
+use Test::More "tests" => 5;
 use FindBin;
 use Capture::Tiny qw{capture_merged};
 
@@ -22,3 +22,7 @@ like($out,qr/encoding of arguments/i,"Help output OK");
 is($code, 255, "Exit code bad when no case could be locked");
 chomp $out;
 like($out,qr/could not lock case/i,"Output is as expected");
+
+#Make sure that the binary itself processes args correctly
+$out = `$0 --help`;
+like($out,qr/encoding of arguments/i,"Appears we can run binary successfully");

+ 5 - 1
t/testrail-report.t

@@ -5,7 +5,7 @@ use FindBin;
 use lib $FindBin::Bin.'/../bin';
 require 'testrail-report';
 
-use Test::More 'tests' => 16;
+use Test::More 'tests' => 17;
 use Capture::Tiny qw{capture_merged};
 
 use lib $FindBin::Bin.'/lib';
@@ -63,3 +63,7 @@ $0 = $FindBin::Bin.'/../bin/testrail-report';
 ($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");
+
+#Make sure that the binary itself processes args correctly
+$out = `$0 --help`;
+like($out,qr/encoding of arguments/i,"Appears we can run binary successfully");

+ 5 - 1
t/testrail-runs.t

@@ -9,7 +9,7 @@ require 'testrail-runs';
 use lib $FindBin::Bin.'/lib';
 use Test::LWP::UserAgent::TestRailMock;
 
-use Test::More 'tests' => 12;
+use Test::More 'tests' => 13;
 use Capture::Tiny qw{capture_merged};
 
 #check status filters
@@ -53,3 +53,7 @@ $0 = $FindBin::Bin.'/../bin/testrail-runs';
 ($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");
+
+#Make sure that the binary itself processes args correctly
+$out = `$0 --help`;
+like($out,qr/encoding of arguments/i,"Appears we can run binary successfully");

+ 5 - 1
t/testrail-tests.t

@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More "tests" => 31;
+use Test::More "tests" => 32;
 use Test::Fatal;
 use FindBin;
 use Capture::Tiny qw{capture_merged};
@@ -104,3 +104,7 @@ $0 = $FindBin::Bin.'/../bin/testrail-tests';
 ($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");
+
+#Make sure that the binary itself processes args correctly
+$out = `$0 --help`;
+like($out,qr/encoding of arguments/i,"Appears we can run binary successfully");