Permalink
Browse files

Flavor::Basic: added test case for jslint

  • Loading branch information...
1 parent 5334ef7 commit a44b06fa97ac1ede775954a24ffdf3f2c69c3849 @tokuhirom committed Oct 11, 2011
Showing with 32 additions and 0 deletions.
  1. +32 −0 lib/Amon2/Setup/Flavor/Basic.pm
@@ -437,6 +437,38 @@ done_testing;
-Mt::Util
...
+ $self->write_file('t/06_jslint.t', <<'...');
+#!/usr/bin/perl
+use strict;
+use warnings;
+use Test::More;
+use Test::Requires 'Text::SimpleTable';
+
+plan skip_all => 'this test requires "jsl" command'
+ unless `jsl` =~ /JavaScript Lint/;
+
+my @files = (<static/*/*.js>, <static/*/*/*.js>, <static/*/*/*/*.js>);
+plan tests => 1 * @files;
+
+my $table = Text::SimpleTable->new( 25, 5, 5 );
+
+for my $file (@files) {
+ # 0 error(s), 6 warning(s)
+ my $out = `jsl -stdin < $file`;
+ if ( $out =~ /((\d+) error\(s\), (\d+) warning\(s\))/ ) {
+ my ( $msg, $err, $warn ) = ( $1, $2, $3 );
+ $file =~ s!^static/[^/]+/!!;
+ $table->row( $file, $err, $warn );
+ is $err, 0, $file;
+ }
+ else {
+ ok 0;
+ }
+}
+
+note $table->draw;
+...
+
for my $status (qw/404 500 502 503 504/) {
$self->write_status_file("static/$status.html", $status);
}

0 comments on commit a44b06f

Please sign in to comment.