PageRenderTime 34ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/Games-Go-KGS/t/boilerplate.t

http://games-go-kgs.googlecode.com/
Perl | 55 lines | 52 code | 2 blank | 1 comment | 0 complexity | d3778653d8534f199f551d9a5a053304 MD5 | raw file
  1. #!perl -T
  2. use strict;
  3. use warnings;
  4. use Test::More tests => 3;
  5. sub not_in_file_ok {
  6. my ($filename, %regex) = @_;
  7. open( my $fh, '<', $filename )
  8. or die "couldn't open $filename for reading: $!";
  9. my %violated;
  10. while (my $line = <$fh>) {
  11. while (my ($desc, $regex) = each %regex) {
  12. if ($line =~ $regex) {
  13. push @{$violated{$desc}||=[]}, $.;
  14. }
  15. }
  16. }
  17. if (%violated) {
  18. fail("$filename contains boilerplate text");
  19. diag "$_ appears on lines @{$violated{$_}}" for keys %violated;
  20. } else {
  21. pass("$filename contains no boilerplate text");
  22. }
  23. }
  24. sub module_boilerplate_ok {
  25. my ($module) = @_;
  26. not_in_file_ok($module =>
  27. 'the great new $MODULENAME' => qr/ - The great new /,
  28. 'boilerplate description' => qr/Quick summary of what the module/,
  29. 'stub function definition' => qr/function[12]/,
  30. );
  31. }
  32. TODO: {
  33. local $TODO = "Need to replace the boilerplate text";
  34. not_in_file_ok(README =>
  35. "The README is used..." => qr/The README is used/,
  36. "'version information here'" => qr/to provide version information/,
  37. );
  38. not_in_file_ok(Changes =>
  39. "placeholder date/time" => qr(Date/time)
  40. );
  41. module_boilerplate_ok('lib/Games/Go/KGS.pm');
  42. }