[Bps-public-commit] r12829 - in Test-Harness-JS: . lib/Test lib/Test/Continuous

jesse at bestpractical.com jesse at bestpractical.com
Tue Jun 3 10:43:50 EDT 2008


Author: jesse
Date: Tue Jun  3 10:43:48 2008
New Revision: 12829

Added:
   Test-Harness-JS/js-libs
   Test-Harness-JS/lib/
   Test-Harness-JS/lib/Test/
   Test-Harness-JS/lib/Test/Continuous/
   Test-Harness-JS/lib/Test/Continuous/JS.pm
   Test-Harness-JS/test.js.t
Removed:
   Test-Harness-JS/code.js
Modified:
   Test-Harness-JS/   (props changed)
   Test-Harness-JS/jsharness.pl

Log:
Ugly, but worky.


Added: Test-Harness-JS/js-libs
==============================================================================
--- (empty file)
+++ Test-Harness-JS/js-libs	Tue Jun  3 10:43:48 2008
@@ -0,0 +1,13 @@
+/home/jesse/svk/jifty-trunk/share/web/static/js/json.js
+/home/jesse/svk/jifty-trunk/share/web/static/js/jquery-1.2.3.js
+/home/jesse/svk/jifty-trunk/share/web/static/js/jquery_patch.js
+/home/jesse/svk/jifty-trunk/share/web/static/js/jquery_noconflict.js
+/home/jesse/svk/pie-named/pieplate/PIE-Plate/share/web/static/js/jquery.superflydom.js
+/home/jesse/svk/pie-named/pieplate/PIE-Plate/share/web/static/js/jquery.jeditable.js
+/home/jesse/svk/pie-named/pieplate/PIE-Plate/share/web/static/js/jquery.dimensions.js
+/home/jesse/svk/pie-named/pieplate/PIE-Plate/share/web/static/js/jquery.ui-1.5b4/ui.core.js
+/home/jesse/svk/pie-named/pieplate/PIE-Plate/share/web/static/js/jquery.ui-1.5b4/ui.sortable.js
+/home/jesse/svk/pie-named/pieplate/PIE-Plate/share/web/static/js/jquery.ui-1.5b4/ui.selectable.js
+/home/jesse/svk/pie-named/pieplate/PIE-Plate/share/web/static/js/jquery.ui-1.5b4/ui.draggable.js
+/home/jesse/svk/pie-named/pieplate/PIE-Plate/share/web/static/js/jquery.ui-1.5b4/ui.droppable.js
+/home/jesse/svk/pie-named/pieplate/PIE-Plate/share/web/static/js/pieui.js

Modified: Test-Harness-JS/jsharness.pl
==============================================================================
--- Test-Harness-JS/jsharness.pl	(original)
+++ Test-Harness-JS/jsharness.pl	Tue Jun  3 10:43:48 2008
@@ -104,12 +104,23 @@
 package main;
 
 use Path::Class;
-my $source=file($ENV{'JSSOURCE'}||'code.js')->slurp();
+my $source=file($ENV{'JS_TEST'}||'test.js.t')->slurp();
+my @libs  = split(/\n/,file($ENV{'JS_LIBS'}||'js-libs')->slurp());
+
+my $libs;
+foreach my $lib (@libs) {
+    $libs .= file($lib)->slurp();
+}
+
 
 my $server = JSH::Server->new( 8000+ int(rand(1000)));
 $server->load_server(<<"EOF");
 <html>
-<head></head>
+<head>
+<script>
+@{[$libs]}
+</script>
+</head>
 <body>
 <pre id="results"># Javascript. TAP. Lurking Horror
 </pre>
@@ -147,7 +158,7 @@
     req = new ActiveXObject("Microsoft.XMLHTTP");
   }
   if (req != undefined) {
-    req.onreadystatechange = function() {window.close()}
+    req.onreadystatechange = function() {}
     req.open("POST", 'http://localhost:@{[$server->port]}/done', true);
     req.send(document.getElementById('results').innerHTML);
   }

Added: Test-Harness-JS/lib/Test/Continuous/JS.pm
==============================================================================
--- (empty file)
+++ Test-Harness-JS/lib/Test/Continuous/JS.pm	Tue Jun  3 10:43:48 2008
@@ -0,0 +1,205 @@
+use warnings;
+use strict;
+package Test::Continuous::JS;
+
+use 5.008;
+
+our $VERSION = '0.0.5';
+
+use Exporter::Lite;
+use App::Prove;
+use File::Find;
+use File::Modified;
+use Cwd;
+use List::MoreUtils qw(uniq);
+use Path::Class;
+
+our @EXPORT = qw(&runtests);
+{
+    no warnings;
+    *{App::Prove::_exit} = sub {};
+}
+
+my @tests;
+my @changes;
+my @files;
+
+sub _files {
+    return @files if @files;
+    find sub {
+        my $filename = $File::Find::name;
+        return if ! -f $filename;
+        return unless $filename =~ /\.(js|t)$/ && -f $filename;
+        push @files, $filename;
+    }, getcwd;
+
+    my @otherfiles = split(/\n/, file('js-libs')->slurp());
+    push @files, @otherfiles;
+    warn join(",,,", at files);
+    return @files;
+}
+
+sub _tests_to_run {
+    my %dep;
+
+    my @tests_to_run = uniq sort map {
+        if (/.t$/) {
+            $_;
+        }
+    } @files;
+
+    return @tests_to_run;
+}
+
+sub _run_once {
+    my $prove = App::Prove->new;
+
+    $prove->process_args(
+        "--formatter" => "Test::Continuous::Formatter",
+        "-m", "--norc", "--nocolor", '-l',  'jsharness.pl'
+    );
+    $prove->run;
+}
+
+sub runtests {
+    @tests = @ARGV ? @ARGV : <t/*.t>;
+    print "[MSG] Will run continuously test $_\n" for @tests;
+    my $d = File::Modified->new( files => [ _files ] );
+    while(1) {
+        if ( @changes = $d->changed ) {
+            print "[MSG]: $_ was changed.\n" for @changes;
+            $d->update();
+            _run_once;
+        }
+        sleep 3;
+    }
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Test::Continuous - Run your tests suite continusouly when developing.
+
+=head1 VERSION
+
+This document describes Test::Continuous version 0.0.4
+
+=head1 SYNOPSIS
+
+    % cd MyModule/
+    % perl -MTest::Continuous -e runtests
+
+=head1 DESCRIPTION
+
+I<Continuous Testing> is a concept and tool to re-run software tests
+as soon as the developer saved the source code.
+
+See also L<http://groups.csail.mit.edu/pag/continuoustesting/> for the
+original implementation of Continuous Testing as a Eclipse plugin.
+
+See also Zentest L<http://www.zenspider.com/ZSS/Products/ZenTest/> for
+the same concept of implementation in Ruby's world.
+
+=head1 INTERFACE
+
+=over
+
+=item runtests
+
+This is the only function that you should be calling, directly
+from command line:
+
+    perl -MTest::Continuous -e runtests
+
+It'll start monitoring the mtime of all files under current working
+directy. If there's any update, it'll run your module test under t/
+directory with L<App::Prove>.
+
+Test result are displayed on terminal. Also dispatched to Growl if
+C<Log::Dispatch::MacGrowl> is installed. Big plus for perl programmers
+on Mac.
+
+C<Test::Continuous> will auto detect the subset of tests to run.
+For example, say you have two test files C<feature-foo.t> and
+C<feature-bar.t> which test ,and use, your module C<Feature::Foo>
+and C<Feature::Bar> respectively. C<Test::Continuous> can catch
+this static dependency and only run C<feature-foo.t> when C<Feature::Foo>
+is modified, C<feature-bar.t> will only be ran if C<Feature::Bar>
+is modified.
+
+If a C<.t> file is modified, only that test file will be ran.
+
+Dynamic module dependency is more difficult to detect and needs
+further research.
+
+=back
+
+=head1 CONFIGURATION AND ENVIRONMENT
+
+Test::Continuous requires no configuration files or environment variables.
+
+=head1 DEPENDENCIES
+
+L<App::Prove>, L<Log::Dispatcher>, L<Log::Dispatch::MacGrowl>,
+L<Module::ExtractUse>
+
+=head1 INCOMPATIBILITIES
+
+None reported.
+
+=head1 BUGS AND LIMITATIONS
+
+No bugs have been reported.
+
+Please report any bugs or feature requests to
+C<bug-test-continuous at rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org>.
+
+=head1 TODO
+
+=over
+
+=item A good name for executable.
+
+=item Accept a per-module config file to tweak different parameters to prove command.
+
+=back
+
+=head1 AUTHOR
+
+Kang-min Liu  C<< <gugod at gugod.org> >>
+
+
+=head1 LICENCE AND COPYRIGHT
+
+Copyright (c) 2008, Kang-min Liu C<< <gugod at gugod.org> >>.
+
+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.

Added: Test-Harness-JS/test.js.t
==============================================================================
--- (empty file)
+++ Test-Harness-JS/test.js.t	Tue Jun  3 10:43:48 2008
@@ -0,0 +1,4 @@
+ok(1,"ok");
+ok(1,"fail");
+var t = lorzy_make_empty_drop_target();
+ok(t.hasClass('lorzy-target'), "It has a target's class");



More information about the Bps-public-commit mailing list