Skip to content

Commit

Permalink
* run the file and see what we get
Browse files Browse the repository at this point in the history
git-svn-id: http://brian-d-foy.svn.sourceforge.net/svnroot/brian-d-foy/trunk@1351 d9f60a02-fc28-0410-9752-bc0d6c4f57a6
  • Loading branch information
briandfoy committed Sep 2, 2004
1 parent 93c4160 commit c854d8f
Showing 1 changed file with 123 additions and 0 deletions.
123 changes: 123 additions & 0 deletions 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`;
}

0 comments on commit c854d8f

Please sign in to comment.