소스 검색

Fix #40 - Make sure the --help option works in scripts

George S. Baugh 10 년 전
부모
커밋
aa8d1a698c
5개의 변경된 파일27개의 추가작업 그리고 4개의 파일을 삭제
  1. 1 0
      Changes
  2. 2 1
      bin/testrail-tests
  3. 10 1
      t/testrail-report.t
  4. 7 1
      t/testrail-runs.t
  5. 7 1
      t/testrail-tests.t

+ 1 - 0
Changes

@@ -2,6 +2,7 @@ Revision history for Perl module TestRail::API
 
 0.025 2015-05-?? TEODESIAN
     - Fix test failures on windows (and an issue in testrail-tests on win32)
+    - Fix issue where testrail-tests was unresponsive to --help
 
 0.024 2015-05-17 TEODESIAN
     - Allow spawning of plans in Test::Rail::Parser (and those programs depending on it)

+ 2 - 1
bin/testrail-tests

@@ -126,7 +126,8 @@ GetOptions(
     'a|assignedto=s@' => \$opts{'users'},
     'mock'            => \$opts{'mock'},
     'm|match=s'       => \$opts{'match'},
-    'n|no-recurse'    => \$opts{'no-recurse'}
+    'n|no-recurse'    => \$opts{'no-recurse'},
+    'h|help'          => \$opts{'help'}
 );
 
 if ($opts{help}) { help(); }

+ 10 - 1
t/testrail-report.t

@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More 'tests' => 10;
+use Test::More 'tests' => 12;
 
 my @args = ($^X,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`;
@@ -35,3 +35,12 @@ $out = `@args`;
 is($? >> 8, 0, "Exit code OK reported with spawn");
 $matches = () = $out =~ m/Reporting result of case.*OK/ig;
 is($matches,2,"Attempts to spawn work");
+
+#Test that help works
+@args = ($^X,qw{bin/testrail-report --help});
+$out = `@args`;
+is($? >> 8, 0, "Exit code OK reported with help");
+$matches = () = $out =~ m/usage/ig;
+is($matches,1,"Help output OK");
+
+

+ 7 - 1
t/testrail-runs.t

@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More 'tests' => 8;
+use Test::More 'tests' => 10;
 
 #check status filters
 my @args = ($^X,qw{bin/testrail-runs --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -j "TestProject" --mock});
@@ -29,3 +29,9 @@ $out = `@args`;
 is($? >> 8, 0, "Exit code OK looking for runs with passes");
 chomp $out;
 is($out,'',"Gets no run correctly when filtering by unassigned config");
+
+#help options
+@args = ($^X,qw{bin/testrail-runs --help});
+$out = `@args`;
+is($? >> 8, 0, "Exit code OK looking for help");
+like($out,qr/usage/i,"Help output OK");

+ 7 - 1
t/testrail-tests.t

@@ -1,7 +1,7 @@
 use strict;
 use warnings;
 
-use Test::More "tests" => 20;
+use Test::More "tests" => 22;
 
 #check plan mode
 my @args = ($^X,qw{bin/testrail-tests --apiurl http://testrail.local --user "test@fake.fake" --password "fake" -j TestProject -p "GosPlan" -r "Executing the great plan" -m t --config testConfig --mock --no-recurse});
@@ -67,4 +67,10 @@ is($? >> 8, 0, "Exit code OK running no plan mode, no recurse");
 chomp $out;
 like($out,qr/\nskipall\.test$/,"Gets test correctly in no plan mode, no recurse");
 
+#Verify no-match returns non path
+@args = ($^X,qw{bin/testrail-tests --help});
+$out = `@args`;
+is($? >> 8, 0, "Exit code OK asking for help");
+like($out,qr/usage/i,"Help output OK");
+