Skip to content

Commit

Permalink
Continuous Testing app for Perl.
Browse files Browse the repository at this point in the history
Design for running CPAN distribution tests.


git-svn-id: http://code.handlino.com/svn/people/gugod/perl5/Test-Continuously@216 b19cb30a-9f2e-4084-8847-5e1a13269302
  • Loading branch information
gugod committed Feb 16, 2008
0 parents commit 4e4aca4
Show file tree
Hide file tree
Showing 11 changed files with 304 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .cvsignore
@@ -0,0 +1,10 @@
blib*
Makefile
Makefile.old
Build
_build*
pm_to_blib*
*.tar.gz
.lwpcookies
Test-Continuously-*
cover_db
5 changes: 5 additions & 0 deletions Changes
@@ -0,0 +1,5 @@
Revision history for Test-Continuously

0.0.1 Sat Feb 16 14:09:02 2008
Initial release.

10 changes: 10 additions & 0 deletions MANIFEST
@@ -0,0 +1,10 @@
Changes
MANIFEST
META.yml # Will be created by "make dist"
Makefile.PL
README
lib/Test/Continuously.pm
t/00.load.t
t/perlcritic.t
t/pod-coverage.t
t/pod.t
11 changes: 11 additions & 0 deletions Makefile.PL
@@ -0,0 +1,11 @@
use strict;
use warnings;
use inc::Module::Install;

all_from 'lib/Test/Continuously.pm';

build_requires 'Test::More' => '0.42';

WriteAll;


38 changes: 38 additions & 0 deletions README
@@ -0,0 +1,38 @@
Test-Continuously version 0.0.1

This module is inspired by "Continuous Testing"

http://groups.csail.mit.edu/pag/continuoustesting/

Perl module developers can use this module to keep testing their work
at the same moment they are coding. It keeps polling if any code is
changed, and run tests if so.

INSTALLATION

To install this module, run the following commands:

perl Makefile.PL
make
make test
make install

USAGE

To use this, run this at your module directory (where a t/ lives):

perl -MTest::Continuously -e runtests

Then just switch to your editor and start coding. You shall be
notified when a round of test is finished.

DEPENDENCIES

Mac::Growl

COPYRIGHT AND LICENCE

Copyright (C) 2008, Kang-min Liu

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
162 changes: 162 additions & 0 deletions lib/Test/Continuously.pm
@@ -0,0 +1,162 @@
use warnings;
use strict;
package Test::Continuously;

use 5.008;

our $VERSION = '0.0.1';

use Exporter::Lite;
use App::Prove;
use File::Find;
use Cwd;

our @EXPORT = qw(&runtests);
{
no warnings;
*{App::Prove::_exit} = sub {};
}

sub run_once {
my $prove = App::Prove->new;
$prove->process_args(
"--formatter" => "Test::Continuously::Formatter",
"--norc", "--nocolor", "-Q", "-l", "t"
);
$prove->run;
}

my %files;
sub _changed {
my $modified = 0;
find sub {
my $filename = $File::Find::name;
return if $filename =~ /~$/;
return if ! -f $filename;

my $mtime = (stat($filename))[9];
if (exists $files{$filename}) {
if ( $files{$filename} < $mtime) {
$modified = 1;
print STDERR "[MSG] $filename is updated\n";
}
}
else {
$modified = 1;
}
$files{$filename} = $mtime;
}, getcwd;
return $modified;
}

sub runtests {
while (1) {
run_once if _changed;
sleep 5;
}
}

1;

__END__
=head1 NAME
Test::Continuously - [One line description of module's purpose here]
=head1 VERSION
This document describes Test::Continuously version 0.0.1
=head1 SYNOPSIS
use Test::Continuously;
=head1 DESCRIPTION
=head1 INTERFACE
=over
=item new()
=back
=head1 DIAGNOSTICS
=over
=item C<< Error message here, perhaps with %s placeholders >>
[Description of error here]
=item C<< Another error message here >>
[Description of error here]
[Et cetera, et cetera]
=back
=head1 CONFIGURATION AND ENVIRONMENT
Test::Continuously requires no configuration files or environment variables.
=head1 DEPENDENCIES
None.
=head1 INCOMPATIBILITIES
None reported.
=head1 BUGS AND LIMITATIONS
No bugs have been reported.
Please report any bugs or feature requests to
C<bug-test-continuously@rt.cpan.org>, or through the web interface at
L<http://rt.cpan.org>.
=head1 AUTHOR
Kang-min Liu C<< <gugod@gugod.org> >>
=head1 LICENCE AND COPYRIGHT
Copyright (c) 2008, Kang-min Liu C<< <gugod@gugod.org> >>. All rights reserved.
This module is free software; you can redistribute it and/or
modify it under the same terms as Perl itself. See L<perlartistic>.
=head1 DISCLAIMER OF WARRANTY
BECAUSE THIS SOFTWARE IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE SOFTWARE, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE SOFTWARE "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE
ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE SOFTWARE IS WITH
YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
NECESSARY SERVICING, REPAIR, OR CORRECTION.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE SOFTWARE AS PERMITTED BY THE ABOVE LICENCE, BE
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL,
OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE
THE SOFTWARE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE SOFTWARE TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
38 changes: 38 additions & 0 deletions lib/Test/Continuously/Formatter.pm
@@ -0,0 +1,38 @@
package Test::Continuously::Formatter;
use base 'TAP::Formatter::Console';

use Mac::Growl ':all';
use IO::String;

sub summary {
my ( $self, $aggregate ) = @_;

my $str;
my $io = IO::String->new($str);
$self->stdout($io);

$self->SUPER::summary($aggregate);

RegisterNotifications(
"Test::Continuously",
["TestResult"],
["TestResult"]
);

$str =~ s/^\s*//s;
$str =~ s/\s*$//s;
my @lines = split(/\n/, $str);
shift @lines; shift @lines;

for (split(/\n(?! )/, join("\n", @lines) )) {
s/ +/ /gs;
PostNotification(
"Test::Continuously",
"TestResult",
"Test Summary Report",
$_,
);
}
}

1;
7 changes: 7 additions & 0 deletions t/00.load.t
@@ -0,0 +1,7 @@
use Test::More tests => 1;

BEGIN {
use_ok( 'Test::Continuously' );
}

diag( "Testing Test::Continuously $Test::Continuously::VERSION" );
11 changes: 11 additions & 0 deletions t/perlcritic.t
@@ -0,0 +1,11 @@
#!perl

eval { require Test::Perl::Critic };
if ($@) {
require Test::More;
Test::More::plan(
skip_all => "Test::Perl::Critic required for testing PBP compliance"
);
}

Test::Perl::Critic::all_critic_ok();
6 changes: 6 additions & 0 deletions t/pod-coverage.t
@@ -0,0 +1,6 @@
#!perl -T

use Test::More;
eval "use Test::Pod::Coverage 1.04";
plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
all_pod_coverage_ok();
6 changes: 6 additions & 0 deletions t/pod.t
@@ -0,0 +1,6 @@
#!perl -T

use Test::More;
eval "use Test::Pod 1.14";
plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
all_pod_files_ok();

0 comments on commit 4e4aca4

Please sign in to comment.