From c854d8f9b7936c89a47045109d783722d7cff30f Mon Sep 17 00:00:00 2001 From: brian d foy Date: Thu, 2 Sep 2004 01:19:23 +0000 Subject: [PATCH] * 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 --- t/run.t | 123 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 123 insertions(+) create mode 100644 t/run.t diff --git a/t/run.t b/t/run.t new file mode 100644 index 0000000..3bf32d5 --- /dev/null +++ b/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`; + } \ No newline at end of file