cpanreport 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/perl
  2. # $OpenBSD: cpanreport,v 1.1 2011/11/27 13:29:35 jasper Exp $
  3. # Copyright (c) 2007, 2008 Simon Bertrang <simon@openbsd.org>
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions
  6. # are met:
  7. # 1. Redistributions of code must retain the above copyright
  8. # notice, this list of conditions and the following disclaimer.
  9. # 2. Neither the name of OpenBSD nor the names of its contributors
  10. # may be used to endorse or promote products derived from this software
  11. # without specific prior written permission.
  12. #
  13. # THIS SOFTWARE IS PROVIDED BY ITS AUTHOR AND THE OpenBSD project ``AS IS'' AND
  14. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  15. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  16. # ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  17. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  19. # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  20. # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21. # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22. # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. # SUCH DAMAGE.
  24. use strict;
  25. use Getopt::Std qw(getopts);
  26. use Test::Reporter;
  27. my $distname;
  28. my $log;
  29. my %opts = (
  30. 'f' => $ENV{'REGRESS_LOGFILE'} || '-',
  31. 'g' => '',
  32. 's' => $ENV{'CPAN_REPORT_FROM'} || '',
  33. );
  34. my $reporter;
  35. sub usage {
  36. die("usage: $0 [-f regress.log] -s address" .
  37. " -g fail|pass|na|unknown distname\n");
  38. }
  39. unless (getopts('f:g:s:', \%opts)) {
  40. usage();
  41. }
  42. unless ($opts{'g'} && $opts{'g'} =~ m/^(?:pass|fail|na|unknown)$/o) {
  43. usage();
  44. }
  45. unless ($distname = shift(@ARGV)) {
  46. usage();
  47. }
  48. unless ($opts{'g'} eq 'pass') {
  49. my $fh;
  50. unless (open($fh, $opts{'f'})) {
  51. die("$0: $!: $opts{'f'}\n");
  52. }
  53. {
  54. local($/) = undef;
  55. $log = <$fh>;
  56. }
  57. close($fh);
  58. }
  59. $reporter = Test::Reporter->new();
  60. $reporter->from($opts{'s'});
  61. $reporter->grade($opts{'g'});
  62. $reporter->distribution($distname);
  63. if ($log) {
  64. $reporter->comments($log);
  65. }
  66. printf STDOUT "To: %s\n", $reporter->address();
  67. $reporter->write(\*STDOUT);