Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* run the file and see what we get

git-svn-id: http://brian-d-foy.svn.sourceforge.net/svnroot/brian-d-foy/trunk@1351 d9f60a02-fc28-0410-9752-bc0d6c4f57a6
  • Loading branch information...
commit c854d8f9b7936c89a47045109d783722d7cff30f 1 parent 93c4160
@briandfoy authored
Showing with 123 additions and 0 deletions.
  1. +123 −0 t/run.t
View
123 t/run.t
@@ -0,0 +1,123 @@
+# $Id$
+use strict;
+use warnings;
+
+use Cwd;
+use File::Spec;
+use URI;
+
+use Test::Data qw(Array);
+use Test::More tests => 22;
+
+my $corpus = 'data';
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+my $file = 'index.html';
+my @urls = ();
+
+@urls = run( '', $file );
+is( scalar @urls, 80, "Extracts 80 URLs from $file" );
+
+@urls = run( '-1', $file );
+is( scalar @urls, 42, "Extracts 42 unique URLs from $file" );
+
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+@urls = run( '-a', $file );
+is( scalar @urls, 80, "Extracts 80 URLs from $file" );
+array_sortedstr_ascending_ok( @urls );
+
+@urls = run( '-a -1', $file );
+is( scalar @urls, 42, "Extracts 42 URLs from $file" );
+array_sortedstr_ascending_ok( @urls );
+
+@urls = run( '-A', $file );
+is( scalar @urls, 80, "Extracts 80 URLs from $file" );
+array_sortedstr_descending_ok( @urls );
+
+@urls = run( '-A -1', $file );
+is( scalar @urls, 42, "Extracts 42 URLs from $file" );
+array_sortedstr_descending_ok( @urls );
+
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+@urls = run( '-e jpg', $file );
+is( scalar @urls, 42, "Extracts 42 jpg URLs from $file" );
+
+@urls = run( '-e jpg -1', $file );
+is( scalar @urls, 6, "Extracts 6 unique jpg URLs from $file" );
+
+@urls = run( '-e html', $file );
+is( scalar @urls, 6, "Extracts 6 html URLs from $file" );
+
+@urls = run( '-e jpg,html', $file );
+is( scalar @urls, 48, "Extracts 42 jpg and html URLs from $file" );
+
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+@urls = run( '-h www.theperlreview.com', $file );
+is( scalar @urls, 5, "Extracts 42 jpg and html URLs from $file" );
+
+@urls = run( '-H www.ddj.com', $file );
+is( scalar @urls, 74, "Extracts 42 jpg and html URLs from $file" );
+
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+@urls = run( '-s mailto', $file );
+is( scalar @urls, 3, "Extracts 3 mailto URLs from $file" );
+
+@urls = run( '-s file -b', $file );
+is( scalar @urls, 51, "Extracts 51 file URLs from $file" );
+
+@urls = run( '-S http', $file );
+is( scalar @urls, 54, "Extracts 54 non-HTTP URLs from $file" );
+
+@urls = run( '-S http -1', $file );
+is( scalar @urls, 18, "Extracts 18 unique, relative non-HTTP URLs from $file" );
+
+@urls = run( '-S file -b', $file );
+is( scalar @urls, 29, "Extracts 29 absolute non-file URLs from $file" );
+
+@urls = run( '-S file,http -b', $file );
+is( scalar @urls, 3, "Extracts 3 absolute non-HTTP, non-file URLs from $file" );
+
+
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+ # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+sub run
+ {
+ my( $options, $file ) = @_;
+
+ my $command = 'blib/script/grepurl';
+ my $url = local_file( $file );
+
+ my $command_line = command_line( $command, $options, $url );
+
+ get_output( $command_line );
+ }
+
+sub command_line
+ {
+ my( $command, $options, $url ) = @_;
+
+ "$command $options -u $url";
+ }
+
+sub local_file
+ {
+ my( $file ) = @_;
+
+ my $cwd = cwd;
+
+ my $path = File::Spec->catfile( $cwd, $corpus, $file );
+ my $url = "file://$path";
+ }
+
+sub get_output
+ {
+ my $command_line = shift;
+
+ my @lines = `$command_line`;
+ }
Please sign in to comment.
Something went wrong with that request. Please try again.