WWW-Mechanize-Shell-0.56/ 0000755 0001750 0001750 00000000000 13077733716 014460 5 ustar corion corion WWW-Mechanize-Shell-0.56/MANIFEST.SKIP 0000755 0001750 0001750 00000000354 13077733715 016362 0 ustar corion corion \.lwpcookies$
\.cvsignore$
\.releaserc$
\.travis.yml$
blib
WWW-Mechanize-Shell-*
WWW-Mechanize-Shell-*/
CVS/
.git/
MANIFEST.bak
pm_to_blib
pm_to_blib.ts
cvstest
Makefile$
cover_db/
blibdirs.ts
perlbug.rep
MYMETA
t/hook*
^.*.old$
^MYMETA WWW-Mechanize-Shell-0.56/Makefile.PL 0000644 0001750 0001750 00000014535 13077733715 016441 0 ustar corion corion # -*- mode: perl; c-basic-offset: 4; indent-tabs-mode: nil; -*-
use strict;
use ExtUtils::MakeMaker qw(WriteMakefile);
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
# Normalize version strings like 6.30_02 to 6.3002,
# so that we can do numerical comparisons on it.
my $eumm_version = $ExtUtils::MakeMaker::VERSION;
$eumm_version =~ s/_//;
my $module = 'WWW::Mechanize::Shell';
(my $main_file = "lib/$module.pm" ) =~ s!::!/!g;
# I should maybe use something like Shipwright...
regen_README($main_file);
#regen_EXAMPLES();
my @tests = map { glob $_ } 't/*.t', 't/*/*.t';
my %module = (
NAME => $module,
AUTHOR => q{Max Maischein },
VERSION_FROM => $main_file,
ABSTRACT_FROM => $main_file,
META_MERGE => {
"meta-spec" => { version => 2 },
resources => {
repository => {
web => 'https://github.com/Corion/WWW-Mechanize-Shell',
url => 'git://github.com/Corion/WWW-Mechanize-Shell.git',
type => 'git',
}
},
dynamic_config => 0, # we promise to keep META.* up-to-date
x_static_install => 1, # we are pure Perl and don't do anything fancy
},
MIN_PERL_VERSION => '5.006',
LICENSE => 'perl',
PL_FILES => {},
BUILD_REQUIRES => {
'ExtUtils::MakeMaker' => 0,
},
PREREQ_PM => {
'Term::Shell' => 0.02,
'parent' => 0,
'URI::URL' => 0.00,
'Test::Harness' => 2.30,
'LWP' => 5.69,
'WWW::Mechanize' => 1.20,
'WWW::Mechanize::FormFiller' => 0.05,
'Hook::LexWrap' => 0.20,
'HTML::Display' => 0,
'HTML::TokeParser::Simple' => 2.0,
},
TEST_REQUIRES => {
'Test::More' => 0,
'CGI' => 0,
},
dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
clean => { FILES => 'WWW-Mechanize-Shell-*' },
test => { TESTS => join( ' ', @tests ) },
);
# This is so that we can do
# require 'Makefile.PL'
# and then call get_module_info
sub get_module_info { %module }
if( ! caller ) {
# I should maybe use something like Shipwright...
regen_README($main_file);
#regen_EXAMPLES();
WriteMakefile1(get_module_info);
};
1;
# Below here is boilerplate for making this work across various old versions
# of ExtUtils::MakeMaker and for (re)generating README and README.mkdn
sub WriteMakefile1 { #Written by Alexandr Ciornii, version 0.21. Added by eumm-upgrade.
my %params=@_;
my $eumm_version=$ExtUtils::MakeMaker::VERSION;
$eumm_version=eval $eumm_version;
die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
die "License not specified" if not exists $params{LICENSE};
if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
#EUMM 6.5502 has problems with BUILD_REQUIRES
$params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
delete $params{BUILD_REQUIRES};
}
if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
$params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{TEST_REQUIRES}} };
delete $params{TEST_REQUIRES};
}
delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
delete $params{META_MERGE} if $eumm_version < 6.46;
delete $params{META_ADD} if $eumm_version < 6.46;
delete $params{LICENSE} if $eumm_version < 6.31;
delete $params{AUTHOR} if $] < 5.005;
delete $params{ABSTRACT_FROM} if $] < 5.005;
delete $params{BINARY_LOCATION} if $] < 5.005;
WriteMakefile(%params);
}
sub regen_README {
# README is the short version that just tells people what this is
# and how to install it
eval {
# Get description
my $readme = join "\n",
pod_section($_[0], 'NAME', 'no heading' ),
pod_section($_[0], 'DESCRIPTION' ),
<new();
# Read POD from Module.pm and write to README
$parser->parse_from_file($_[0]);
my $readme_mkdn = <as_markdown;
[](https://github.com/Corion/WWW-Mechanize-Shell)
STATUS
update_file( 'README.mkdn', $readme_mkdn );
};
}
sub pod_section {
my( $filename, $section, $remove_heading ) = @_;
open my $fh, '<', $filename
or die "Couldn't read '$filename': $!";
my @section =
grep { /^=head1\s+$section/.../^=/ } <$fh>;
pop @section if $section[-1] =~ /^=/;
unshift @section if $remove_heading;
# Trim the section
if( @section ) {
pop @section
while $section[-1] =~ /^\s*$/;
shift @section
while $section[0] =~ /^\s*$/;
};
@section = map { $_ =~ s!^=\w+\s+!!; $_ } @section;
return join "", @section;
}
sub update_file {
my( $filename, $new_content ) = @_;
my $content;
if( -f $filename ) {
open my $fh, '<', $filename
or die "Couldn't read '$filename': $!";
binmode $fh;
local $/;
$content = <$fh>;
};
if( $content ne $new_content ) {
if( open my $fh, '>', $filename ) {
binmode $fh;
print $fh $new_content;
} else {
warn "Couldn't (re)write '$filename': $!";
};
};
} WWW-Mechanize-Shell-0.56/t/ 0000755 0001750 0001750 00000000000 13077733716 014723 5 ustar corion corion WWW-Mechanize-Shell-0.56/t/27-form_number.t 0000755 0001750 0001750 00000001502 13077733715 017651 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use vars qw($_STDOUT_ $_STDERR_);
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
use Test::More tests => 4;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
delete $ENV{PAGER}
if $ENV{PAGER};
$ENV{PERL_HTML_DISPLAY_CLASS}="HTML::Display::Dump";
my @warnings;
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
my @status;
{ no warnings qw'once redefine';
*WWW::Mechanize::Shell::status = sub {};
};
$s->cmd('get file:t/27-index.html');
$s->option('warnings',1);
eval {
$s->cmd("form 2");
};
is($@, '', "Can execute 'form 2' for a page with two forms");
is($_STDOUT_,undef,"Nothing was printed");
is($_STDERR_,undef,"No warnings printed");
WWW-Mechanize-Shell-0.56/t/source.mech 0000644 0001750 0001750 00000000026 13077733715 017056 0 ustar corion corion # a test file
content
WWW-Mechanize-Shell-0.56/t/23-check-dumpresponses.t 0000755 0001750 0001750 00000001640 13077733715 021317 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use Test::HTTP::LocalServer;
use vars qw($_STDOUT_ $_STDERR_);
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
use Test::More tests => 5;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
delete @ENV{qw(HTTP_PROXY http_proxy CGI_HTTP_PROXY)};
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
# Now test
my $server = Test::HTTP::LocalServer->spawn();
{ no warnings 'redefine','once';
local *WWW::Mechanize::Shell::status = sub {};
#$s->cmd("set dumprequests 1");
$s->cmd("set dumpresponses 1");
eval { $s->cmd( sprintf 'get "%s"', $server->url); };
is($@, "", "Get url worked");
isnt($_STDOUT_,undef,"Response was not undef");
isnt($_STDOUT_,"","Response was output");
isnt($s->agent->content,"","Retrieved content");
};
WWW-Mechanize-Shell-0.56/t/99-todo.t 0000755 0001750 0001750 00000002027 13077733715 016317 0 ustar corion corion use Test::More;
use File::Spec;
use File::Find;
use strict;
# Check that all files do not contain any
# lines with "XXX" - such markers should
# either have been converted into Todo-stuff
# or have been resolved.
# The test was provided by Andy Lester.
my @files;
my $blib = File::Spec->catfile(qw(blib lib));
find(\&wanted, grep { -d } ($blib, 'bin'));
plan tests => 2* @files;
foreach my $file (@files) {
source_file_ok($file);
}
sub wanted {
push @files, $File::Find::name if /\.p(l|m|od)$/;
}
sub source_file_ok {
my $file = shift;
open( my $fh, "<$file" ) or die "Can't open $file: $!";
my @lines = <$fh>;
close $fh;
my $n = 0;
for ( @lines ) {
++$n;
s/^/$file ($n): /;
}
my @x = grep /XXX/, @lines;
if ( !is( scalar @x, 0, "Looking for XXXes in $file" ) ) {
diag( $_ ) for @x;
}
@x = grep /<<<|>>>/, @lines;
if ( !is( scalar @x, 0, "Looking for <<<<|>>>> in $file" ) ) {
diag( $_ ) for @x;
}
}
WWW-Mechanize-Shell-0.56/t/00-load.t 0000644 0001750 0001750 00000000546 13077733715 016250 0 ustar corion corion #!perl -T
use strict;
use warnings;
use Test::More tests => 1;
my $module;
BEGIN {
$module = "WWW::Mechanize::Shell";
require_ok( $module );
}
diag( sprintf "Testing %s %s, Perl %s", $module, $module->VERSION, $] );
for (sort grep /\.pm\z/, keys %INC) {
s/\.pm\z//;
s!/!::!g;
eval { diag(join(' ', $_, $_->VERSION || '')) };
}
WWW-Mechanize-Shell-0.56/t/25-save-file-nolink.t 0000755 0001750 0001750 00000002203 13077733715 020476 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use Test::HTTP::LocalServer;
use vars qw($_STDOUT_ $_STDERR_);
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
use Test::More tests => 6;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
delete @ENV{qw(HTTP_PROXY http_proxy CGI_HTTP_PROXY)};
delete $ENV{PAGER}
if $ENV{PAGER};
$ENV{PERL_HTML_DISPLAY_CLASS}="HTML::Display::Dump";
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
# Now test
my $server = Test::HTTP::LocalServer->spawn();
{ no warnings 'redefine', 'once';
local *WWW::Mechanize::Shell::status = sub {};
$s->cmd( sprintf 'get "%s"', $server->url);
isnt($s->agent->content,"","Retrieved content");
$s->cmd("save");
is($_STDOUT_,"No link given to save\n","save error message");
is($_STDERR_,undef,"No warnings");
$_STDOUT_ = undef;
$_STDERR_ = undef;
$s->cmd("save /does-not-exist/");
like($_STDOUT_,'/No match for \/\(\?(-xism|\^):does-not-exist\)\/.\n/',"save RE error message");
is($_STDERR_,undef,"No warnings");
};
WWW-Mechanize-Shell-0.56/t/99-changes.t 0000644 0001750 0001750 00000001275 13077733715 016763 0 ustar corion corion #!perl -w
use warnings;
use strict;
use File::Find;
use Test::More tests => 2;
=head1 PURPOSE
This test ensures that the Changes file
mentions the current version and that a
release date is mentioned as well
=cut
my $module = 'WWW::Mechanize::Shell';
(my $file = $module) =~ s!::!/!g;
require "$file.pm";
my $version = sprintf '%0.2f', $module->VERSION;
diag "Checking for version " . $version;
my $changes = do { local $/; open my $fh, 'Changes' or die $!; <$fh> };
ok $changes =~ /^(.*$version.*)$/m, "We find version $version";
my $changes_line = $1;
ok $changes_line =~ /$version\s+20\d{6}/, "We find a release date on the same line"
or diag $changes_line;
WWW-Mechanize-Shell-0.56/t/24-source-file.t 0000755 0001750 0001750 00000002251 13077733715 017552 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use Test::HTTP::LocalServer;
use vars qw($_STDOUT_ $_STDERR_);
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
use Test::More tests => 6;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
delete $ENV{PAGER}
if $ENV{PAGER};
$ENV{PERL_HTML_DISPLAY_CLASS}="HTML::Display::Dump";
delete @ENV{qw(HTTP_PROXY http_proxy CGI_HTTP_PROXY)};
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
# Now test
my $server = Test::HTTP::LocalServer->spawn();
{ no warnings 'redefine','once';
local *WWW::Mechanize::Shell::status = sub {};
$s->cmd( sprintf 'get "%s"', $server->url);
isnt($s->agent->content,"","Retrieved content");
$s->cmd("source t/source.mech");
isnt($_STDOUT_,"","Sourcing a file works");
is($_STDERR_,undef,"No warnings");
};
{ no warnings 'redefine','once';
my $warned;
local *WWW::Mechanize::Shell::display_user_warning = sub { $warned++ };
$s->cmd("source t/does-not-exist.mech");
is($warned,1,"Warning for nonexistent files works");
is($_STDERR_,undef,"No warnings");
};
WWW-Mechanize-Shell-0.56/t/08-unknown-command.t 0000755 0001750 0001750 00000001475 13077733715 020461 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use File::Temp qw( tempfile );
# pre-5.8.0's warns aren't caught by a tied STDERR.
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
use Test::More tests => 2;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
SKIP: {
#skip "Can't load Term::ReadKey without a terminal", 2
# unless -t STDIN;
#eval { require Term::ReadKey; Term::ReadKey::GetTerminalSize(); };
#if ($@) {
# no warnings 'redefine';
# *Term::ReadKey::GetTerminalSize = sub {80,24};
# diag "Term::ReadKey seems to want a terminal";
#};
use_ok('WWW::Mechanize::Shell');
# Silence all warnings
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
eval {
$s->cmd('this_command_does_not_exist');
};
is($@,"","An unknown command does not crash the shell");
};
WWW-Mechanize-Shell-0.56/t/401-server 0000755 0001750 0001750 00000003211 13077733715 016455 0 ustar corion corion # Thanks to merlyn for nudging me and giving me this snippet!
use strict;
use HTTP::Daemon;
use LWP::UserAgent;
$|++;
my $host = 'localhost';
my $d = HTTP::Daemon->new(
LocalAddr => $host,
) or die;
# HTTP::Deamon doesn't return http://localhost:.../
# for LocalAddr => 'localhost'. This causes the
# tests to fail of many machines.
( my $url = URI->new($d->url) )->host($host);
print "$url\n";
# How many requests do we expect?
my ($ex_user,$ex_pass) = @ARGV;
my $verbose = $ENV{TEST_HTTP_VERBOSE};
my $done = 0;
while (! $done and my $c = $d->accept) {
while (my $req = $c->get_request) {
if ($verbose) {
warn "# Request URI: " . $req->url->path;
my @lines = split "\n",$req->as_string;
warn "# $_\n" for @lines;
};
my $res;
my ($user,$pass);
if ($req->url->path eq '/exit') {
$done = 1;
$res = HTTP::Response->new(200, "OK", undef, "done");
} elsif ( ($user, $pass) = $req->authorization_basic
and $user eq $ex_user
and $pass eq $ex_pass) {
$res = HTTP::Response->new(200, "OK", undef,
"user = '$user' pass = '$pass'");
} else {
warn "# User : '$user' Password : '$pass'\n"
if $verbose;
$res = HTTP::Response->new(401, "Auth Required", undef,
"auth required ($user/$pass)");
$res->www_authenticate("Basic realm=\"testing realm\"");
};
if ($verbose) {
warn "---\n";
my @lines = split "\n",$res->as_string;
warn "# $_\n" for @lines;
};
$c->send_response($res);
}
$c->close;
undef($c);
};
WWW-Mechanize-Shell-0.56/t/28-html-tableextract.t 0000755 0001750 0001750 00000003675 13077733715 021000 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use Test::More tests => 3;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
delete $ENV{PAGER}
if $ENV{PAGER};
$ENV{PERL_HTML_DISPLAY_CLASS}="HTML::Display::Dump";
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
isa_ok $s, 'WWW::Mechanize::Shell';
my $have_tableextract = eval {
require HTML::TableExtract;
die "Need at least HTML::TableExtract v2, found '$HTML::TableExtract::VERSION'"
unless $HTML::TableExtract::VERSION > 2;
1
};
SKIP: {
if ($@) {
skip "Error loading HTML::TableExtract: '$@'", 1;
} elsif (! $have_tableextract) {
skip "Unknown error loading HTML::TableExtract, skipping tests", 1;
} else {
no warnings qw'redefine once';
local *WWW::Mechanize::Shell::status = sub {};
my @output;
local *WWW::Mechanize::Shell::print_paged = sub {
shift @_;
push @output, grep { /\S/ } @_;
};
$s->agent->{base} = 'http://example.com';
$s->agent->update_html(<
ID
age
name
1
John
41
2
Paul
47
3
George
45
4
Ringo
47
HTML
$s->cmd('table name age');
# TableExtract seems to be confused about the column order
# hence we just check the number of rows:
is(scalar @output, 5, "Five lines captured")
or diag "@output";
}
};
WWW-Mechanize-Shell-0.56/t/03-documentation.t 0000644 0001750 0001750 00000001651 13077733715 020203 0 ustar corion corion use strict;
use FindBin;
use vars qw( @methods );
BEGIN {
my $module = "$FindBin::Bin/../lib/WWW/Mechanize/Shell.pm";
open MODULE, "< $module"
or die "Couldn't open module file '$module'";
@methods = map { /^\s*sub run_([a-z]+)\s*\{/ ? $1 : () } ;
close MODULE;
};
use Test::More tests => scalar @methods*3 +2;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
SKIP: {
eval { require Pod::Constants;};
skip "Need Pod::Constants to test the documentation", 2 + scalar @methods*3
if $@;
use_ok("WWW::Mechanize::Shell");
my $shell = WWW::Mechanize::Shell->new("shell", rcfile => undef, warnings => undef );
isa_ok($shell,"WWW::Mechanize::Shell");
for my $method (@methods) {
my $helptext = $shell->catch_smry($method);
is($@,'',"No error");
isnt( $helptext, undef, "Documentation for $method is there");
isnt( $helptext, '', "Documentation for $method is not empty");
};
};
WWW-Mechanize-Shell-0.56/t/04-history-invariant.t 0000755 0001750 0001750 00000003771 13077733715 021035 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
# pre-5.8.0's warns aren't caught by a tied STDERR.
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
use vars qw( @history_invariant @history_add );
BEGIN {
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
# Also disable the paged output of Term::Shell
@history_invariant = qw(
browse
cookies
dump
eval
exit
forms
history
links
parse
quit
restart
script
set
source
tables
versions
ct
response
title
headers
);
push @history_invariant, "headers 1","headers 12","headers 2","headers 12345";
push @history_invariant, "#"," #", "# a comment", " # another comment";
@history_add = qw(
autofill
back
click
content
fillout
get
open
reload
save
submit
table
ua
value
tick
untick
referer
referrer
timeout
);
};
# For testing the "versions" command
sub WWW::Mechanize::Shell::print_pairs {};
use Test::More tests => scalar @history_invariant +1;
SKIP: {
use_ok('WWW::Mechanize::Shell');
# Silence all warnings
#$SIG{__WARN__} = sub {};
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
$s->agent->{content} = '';
my @history;
sub disable {
my ($namespace,$subname) = @_;
no strict 'refs';
no warnings 'redefine';
*{"$namespace\::$subname"} = sub { return };
};
{ no warnings 'redefine','once';
*WWW::Mechanize::Shell::add_history = sub {
shift;
push @history, join "", @_;
};
*WWW::Mechanize::links = sub {()};
};
disable( "WWW::Mechanize::Shell", $_ )
for (qw( restart_shell browser ));
disable( "WWW::Mechanize",$_ )
for (qw( cookie_jar current_form forms ));
disable( "Term::Shell",$_ )
for (qw( print_pairs ));
for my $cmd (@history_invariant) {
@history = ();
$s->cmd($cmd);
is_deeply( \@history, [], "$cmd is history invariant");
};
};
WWW-Mechanize-Shell-0.56/t/18-browser-autosync.t 0000755 0001750 0001750 00000003464 13077733715 020675 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
# pre-5.8.0's warns aren't caught by a tied STDERR.
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
use vars qw( %tests );
BEGIN {
%tests = (
back => { count => 3, commands => ['get %s','click submit','back']},
browse => { count => 2, commands => [ 'get %s', 'browse' ] },
get => { count => 1, commands => ['get %s']} ,
open => { count => 2, commands => ['get %s','open 1'] },
submit => { count => 2, commands => ['get %s','submit']},
click => { count => 2, commands => ['get %s','click submit']},
reload => { count => 2, commands => ['get %s','reload'] },
)
};
use Test::More tests => scalar (keys %tests) +1;
SKIP: {
BEGIN {
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
use_ok('WWW::Mechanize::Shell');
eval { require HTTP::Daemon; };
skip "HTTP::Daemon required to test browser synchronisation",(scalar keys %tests)*6
if ($@);
use lib './inc';
require Test::HTTP::LocalServer; # from inc
delete @ENV{qw(HTTP_PROXY http_proxy CGI_HTTP_PROXY)};
};
my $browser_synced;
{ no warnings 'redefine';
*WWW::Mechanize::Shell::sync_browser = sub {
$browser_synced++;
};
};
sub sync_ok {
my %args = @_;
my $name = $args{name};
my $count = $args{count};
my (@commands) = @{$args{commands}};
my $server = Test::HTTP::LocalServer->spawn();
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
$s->option('autosync', 1);
$browser_synced = 0;
for my $cmd (@commands) {
no warnings;
$cmd = sprintf $cmd, $server->url;
$s->cmd($cmd);
};
is($browser_synced,$count,"'$name' synchronizes $count times")
or diag join "\n", @commands;
$server->stop;
};
for my $cmd (sort keys %tests) {
sync_ok( name => $cmd, %{$tests{$cmd}} );
};
};
WWW-Mechanize-Shell-0.56/t/20-restart-without-script.t 0000755 0001750 0001750 00000001013 13077733715 022013 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use Test::More tests => 4;
BEGIN{
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
use_ok("WWW::Mechanize::Shell");
};
delete @ENV{qw(HTTP_PROXY http_proxy CGI_HTTP_PROXY)};
my $output= `$^X -I./lib -MWWW::Mechanize::Shell -e "WWW::Mechanize::Shell->new('t',rcfile=>undef,warnings=>undef)->cmd('restart');print'OK'" 2>&1`;
chomp $output;
is($@, "","'restart' on -e dosen't crash");
is($?, 0,"'restart' on -e dosen't crash");
is($output,"OK","'restart' on -e dosen't crash");
WWW-Mechanize-Shell-0.56/t/00-use.t 0000644 0001750 0001750 00000005214 13077733715 016122 0 ustar corion corion use strict;
use Test::More tests => 22;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
$ENV{COLUMNS} = 80;
$ENV{LINES} = 24;
use_ok("WWW::Mechanize::Shell") or BAIL_OUT('Does not compile correctly');
diag "Running under $]";
for (qw(WWW::Mechanize LWP::UserAgent)) {
diag "Using '$_' version " . $_->VERSION;
};
my $s = do {
WWW::Mechanize::Shell->new("shell",rcfile => undef, warnings => undef);
};
isa_ok($s,"WWW::Mechanize::Shell");
# Now check our published API :
for my $meth (qw( source_file cmdloop agent option restart_shell option cmd )) {
can_ok($s,$meth);
};
# Check that we can set known options
# See also t/05-options.t
my $oldvalue = $s->option('autosync');
$s->option('autosync',"foo");
is($s->option('autosync'),"foo","Setting an option works");
$s->option('autosync',$oldvalue);
is($s->option('autosync'),$oldvalue,"Setting an option still works");
# Check that trying to set an unknown option gives an error
{
no warnings 'redefine';
my $called;
local *Carp::carp = sub {
$called++;
};
$s->option('nonexistingoption',"foo");
is($called,1,"Setting an nonexisting option calls Carp::carp");
}
{
no warnings 'redefine';
my $called;
my $filename;
local *WWW::Mechanize::Shell::source_file = sub {
$filename = $_[1];
$called++;
};
my $test_filename = '/does/not/need/to/exist';
my $s = do {
WWW::Mechanize::Shell->new("shell",rcfile => $test_filename, warnings => undef);
};
isa_ok($s,"WWW::Mechanize::Shell");
ok($called,"Passing an .rc file tries to load it");
is($filename,$test_filename,"Passing an .rc file tries to load the right file");
};
{
no warnings 'redefine';
my $called = 0;
my $filename;
local *WWW::Mechanize::Shell::source_file = sub {
$filename = $_[1];
$called++;
};
my $s = do {
WWW::Mechanize::Shell->new("shell",rcfile => undef, warnings => undef);
};
isa_ok($s,"WWW::Mechanize::Shell");
diag "Tried to load '$filename'" unless is($called,0,"Passing in no .rc file tries not to load it");
};
$s = WWW::Mechanize::Shell->new("shell",rcfile => undef, cookiefile => 'test.cookiefile', warnings => undef);
isa_ok($s,"WWW::Mechanize::Shell");
is($s->option('cookiefile'),'test.cookiefile',"Passing in a cookiefile filename works");
# Also check what gets exported:
ok(defined *main::shell{CODE},"'shell' gets exported");
{
no warnings 'once';
is(*main::shell{CODE},*WWW::Mechanize::Shell::shell{CODE},"'shell' is the right sub");
};
{
no warnings 'redefine','once';
my $called;
local *WWW::Mechanize::Shell::cmdloop = sub { $called++ };
# Need to suppress status warnings here
shell(warnings => undef);
is($called,1,"Shell function works");
};
WWW-Mechanize-Shell-0.56/t/14-command-identity.t 0000755 0001750 0001750 00000033223 13077733715 020604 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use FindBin;
use IO::Catch;
use File::Temp qw( tempfile );
use vars qw( %tests $_STDOUT_ $_STDERR_ );
use URI::URL;
use LWP::Simple;
# Catch output:
$SIG{__WARN__} = sub { $main::_STDERR_ .= join '', @_; };
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
#tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
# Make HTML::Display do nothing:
BEGIN {
$ENV{PERL_HTML_DISPLAY_CLASS} = 'HTML::Display::Dump';
delete $ENV{PAGER};
};
use HTML::Display;
BEGIN {
%tests = (
autofill => { requests => 2, lines => [ 'get %s',
'autofill query Fixed foo',
'autofill cat Keep',
'fillout',
'submit' ], location => qr'^%s/formsubmit\?session=1&query=foo&cat=cat_foo&cat=cat_bar$'},
auth => { requests => 1, lines => [ 'auth user password', 'get %s' ], location => qr'^%s/$' },
back => { requests => 2, lines => [ 'get %s','open 0','back' ], location => qr'^%s/$' },
content_save => { requests => 1, lines => [ 'get %s','content tmp.content','eval unlink "tmp.content"'], location => qr'^%s/$' },
comment => { requests => 1, lines => [ '# a comment','get %s','# another comment' ], location => qr'^%s/$' },
eval => { requests => 1, lines => [ 'eval "Hello World"', 'get %s','eval "Goodbye World"' ], location => qr'^%s/$' },
eval_shell => { requests => 1, lines => [ 'get %s', 'eval $self->agent->ct' ], location => qr'^%s/$' },
eval_sub => { requests => 2, lines => [
'# Fill in the "date" field with the current date/time as string',
'eval sub ::custom_today { "20030511" };',
'autofill session Callback ::custom_today',
'autofill query Keep',
'autofill cat Keep',
'get %s',
'fillout',
'eval $self->agent->current_form->value("session")',
'submit',
'content',
], location => qr'^%s/formsubmit\?session=20030511&query=\(empty\)&cat=cat_foo&cat=cat_bar$' },
eval_multiline => { requests => 2,
lines => [ 'get %s',
'autofill query Keep',
'autofill cat Keep',
'fillout',
'submit',
'eval "Hello World ",
"from ",$self->agent->uri',
'content' ],
location => qr'^%s/formsubmit\?session=1&query=\(empty\)&cat=cat_foo&cat=cat_bar$' },
form_name => { requests => 2, lines => [ 'get %s','form f','submit' ],
location => qr'^%s/formsubmit\?session=1&query=\(empty\)&cat=cat_foo&cat=cat_bar$'
},
form_num => { requests => 2, lines => [ 'get %s','form 1','submit' ],
location => qr'^%s/formsubmit\?session=1&query=\(empty\)&cat=cat_foo&cat=cat_bar$'
},
formfiller_chars => { requests => 2,
lines => [ 'eval srand 0',
'autofill cat Keep',
'autofill query Random::Chars size 5 set alpha', 'get %s', 'fillout','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=[a-zA-Z]{5}&cat=cat_foo&cat=cat_bar$' },
formfiller_date => { requests => 2,
lines => [ 'eval srand 0',
'autofill cat Keep',
'autofill query Random::Date string %%Y%%m%%d', 'get %s', 'fillout','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=\d{8}&cat=cat_foo&cat=cat_bar$' },
formfiller_default => { requests => 2,
lines => [ 'autofill query Default foo',
'autofill cat Keep',
'get %s', 'fillout','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=\(empty\)&cat=cat_foo&cat=cat_bar$' },
formfiller_fixed => { requests => 2,
lines => [ 'autofill query Fixed foo',
'autofill cat Keep',
'get %s', 'fillout','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=foo&cat=cat_foo&cat=cat_bar$' },
formfiller_keep => { requests => 2,
lines => [ 'autofill query Keep',
'autofill cat Keep',
'get %s', 'fillout','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=\(empty\)&cat=cat_foo&cat=cat_bar' },
formfiller_random => { requests => 2,
lines => [ 'autofill query Random foo',
'autofill cat Keep',
'get %s', 'fillout','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=foo&cat=cat_foo&cat=cat_bar' },
formfiller_re => { requests => 2,
lines => [ 'eval srand 0',
'autofill cat Keep',
'autofill /qu/ Random::Date string %%Y%%m%%d', 'get %s', 'fillout','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=\d{8}&cat=cat_foo&cat=cat_bar' },
formfiller_word => { requests => 2,
lines => [ 'eval srand 0',
'autofill cat Keep',
'autofill query Random::Word size 1', 'get %s', 'fillout','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=\w+&cat=cat_foo&cat=cat_bar' },
get => { requests => 1, lines => [ 'get %s' ], location => qr'^%s/' },
get_content => { requests => 1, lines => [ 'get %s', 'content' ], location => qr'^%s/' },
get_redirect => { requests => 2, lines => [ 'get %sredirect/startpage' ], location => qr'^%s/startpage' },
get_save => { requests => 4, lines => [ 'get %s','save "/\.save_log_server_test\.tmp$/"' ], location => qr'^%s/' },
get_value_click => { requests => 2, lines => [ 'get %s','value query foo', 'click submit' ], location => qr'^%s/formsubmit\?session=1&query=foo&submit=Go&cat=cat_foo&cat=cat_bar' },
get_value_submit => { requests => 2, lines => [ 'get %s','value query foo', 'submit' ], location => qr'^%s/formsubmit\?session=1&query=foo&cat=cat_foo&cat=cat_bar' },
get_value2_submit => { requests => 2, lines => [
'get %s',
'value query foo',
'value session 2',
'submit'
], location => qr'^%s/formsubmit\?session=2&query=foo&cat=cat_foo&cat=cat_bar' },
interactive_script_creation => { requests => 2,
lines => [ 'eval @::list=qw(foo bar xxx)',
'eval no warnings qw"redefine once"; *WWW::Mechanize::FormFiller::Value::Ask::ask_value = sub { my $value=shift @::list; push @{$_[0]->{shell}->{answers}}, [ $_[1]->name, $value ]; $value }',
'autofill cat Keep',
'get %s',
'fillout',
'submit',
'content' ],
location => qr'^%s/formsubmit\?session=foo&query=bar&cat=cat_foo&cat=cat_bar$' },
open_parm => { requests => 2, lines => [ 'get %s','open 1','content' ], location => qr'^%s/test$' },
open_re => { requests => 2, lines => [ 'get %s','open "Link foo1.save_log_server_test.tmp"','content' ], location => qr'^%s/foo1.save_log_server_test.tmp$' },
open_re2 => { requests => 2, lines => [ 'get %s','open "/foo1/"','content' ], location => qr'^%s/foo1.save_log_server_test.tmp$' },
open_re3 => { requests => 2, lines => [ 'get %s','open "/Link /foo/"','content' ], location => qr'^%s/foo$' },
open_re4 => { requests => 2, lines => [ 'get %s','open "/Link \/foo/"','content' ], location => qr'^%s/foo$' },
open_re5 => { requests => 2, lines => [ 'get %s','open "/Link /$/"','content' ], location => qr'^%s/slash_end$' },
open_re6 => { requests => 2, lines => [ 'get %s','open "/^/Link$/"','content' ], location => qr'^%s/slash_front$' },
open_re7 => { requests => 2, lines => [ 'get %s','open "/^/Link in slashes//"','content' ], location => qr'^%s/slash_both$' },
reload => { requests => 2, lines => [ 'get %s','reload','content' ], location => qr'^%s/$' },
reload_2 => { requests => 3, lines => [ 'get %s','open "/Link \/foo/"','reload','content' ], location => qr'^%s/foo$' },
tick => { requests => 2,
lines => [ 'get %s','tick cat cat_foo','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=\(empty\)&cat=cat_foo&cat=cat_bar$' },
tick_all => { requests => 2,
lines => [ 'get %s','tick cat','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=\(empty\)&cat=cat_foo&cat=cat_bar&cat=cat_baz$' },
timeout => { requests => 1, lines => [ 'timeout 60', 'get %s', 'content' ], location => qr'^%s/' },
ua_get => { requests => 1, lines => [ 'ua foo/1.1', 'get %s' ], location => qr'^%s/$' },
ua_get_content => { requests => 1, lines => [ 'ua foo/1.1', 'get %s', 'content' ], location => qr'^%s/$' },
untick => { requests => 2,
lines => [ 'get %s','untick cat cat_foo','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=\(empty\)&cat=cat_bar$' },
untick_all => { requests => 2,
lines => [ 'get %s','untick cat','submit','content' ],
location => qr'^%s/formsubmit\?session=1&query=\(empty\)$' },
);
eval {
require HTML::TableExtract;
$tests{get_table} = { requests => 1, lines => [ 'get %s','table' ], location => qr'^%s/$' };
$tests{get_table_params} = { requests => 1, lines => [ 'get %s','table Col2 Col1' ], location => qr'^%s/$' };
};
# To ease zeroing in on tests
if (@ARGV) {
my $re = join "|", @ARGV;
for (sort keys %tests) {
delete $tests{$_} unless /$re/o;
};
};
};
use Test::More tests => 1 + (scalar keys %tests)*8;
BEGIN {
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
require LWP::UserAgent;
#my $old = \&LWP::UserAgent::request;
#print STDERR $old;
#*LWP::UserAgent::request = sub {print STDERR "LWP::UserAgent::request\n"; goto &$old };
use_ok('WWW::Mechanize::Shell');
};
SKIP: {
diag "Loading HTTP::Daemon";
eval { require HTTP::Daemon; };
skip "HTTP::Daemon required to test script/code identity",(scalar keys %tests)*8
if ($@);
# require Test::HTTP::LocalServer; # from inc
use Test::HTTP::LocalServer; # from inc
# We want to be safe from non-resolving local host names
delete @ENV{qw(HTTP_PROXY http_proxy CGI_HTTP_PROXY)};
use vars qw( $actual_requests $dumped_requests );
{
no warnings qw'redefine once';
my $old_request = *WWW::Mechanize::_make_request{CODE};
*WWW::Mechanize::_make_request = sub {
$actual_requests++;
goto &$old_request;
};
*WWW::Mechanize::Shell::status = sub {};
*WWW::Mechanize::Shell::request_dumper = sub { $dumped_requests++; return 1 };
#*Hook::LexWrap::Cleanup::DESTROY = sub {
#print STDERR "Disabling hook.\n";
#$_[0]->();
#};
};
diag "Spawning local test server";
my $server = Test::HTTP::LocalServer->spawn();
diag sprintf "on port %s", $server->port;
for my $name (sort keys %tests) {
$_STDOUT_ = '';
undef $_STDERR_;
$actual_requests = 0;
$dumped_requests = 0;
my @lines = @{$tests{$name}->{lines}};
my $requests = $tests{$name}->{requests};
my $code_port = $server->port;
my $url = $server->url;
$url =~ s!/$!!;
my $result_location = sprintf $tests{$name}->{location}, $url;
$result_location = qr{$result_location};
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
$s->option("dumprequests",1);
my @commands;
eval {
for my $line (@lines) {
no warnings;
$line = sprintf $line, $server->url;
push @commands, $line;
$s->cmd($line);
};
};
is $@, '', "Commands ran without dieing"
or do { diag for @commands };
$s->cmd('eval $self->agent->uri');
my $code_output = $_STDOUT_;
diag join( "\n", $s->history )
unless like($s->agent->uri,$result_location,"Shell moved to the specified url for $name");
is($_STDERR_,undef,"Shell produced no error output for $name");
is($actual_requests,$requests,"$requests requests were made for $name");
is($dumped_requests,$requests,"$requests requests were dumped for $name");
my $code_requests = $server->get_log;
# Get a clean start
my $script_port = $server->port;
# Modify the generated Perl script to match the new? port
my $script = join "\n", $s->script;
s!\b$code_port\b!$script_port!smg for ($script, $code_output);
#print STDERR "Releasing hook";
undef $s->{request_wrapper};
#{
# local *WWW::Mechanize::Shell::request_dumper = sub { die };
# use HTTP::Request::Common;
# $s->agent->request(GET 'http://google.de/');
#};
$s->release_agent;
undef $s;
# Write the generated Perl script
my ($fh,$tempname) = tempfile();
print $fh $script;
close $fh;
my ($compile) = `"$^X" -c "$tempname" 2>&1`;
chomp $compile;
SKIP: {
unless (is($compile,"$tempname syntax OK","$name compiles")) {
$server->get_log;
diag $script;
skip "Script $name didn't compile", 2;
};
my ($output);
my $command = qq("$^X" -Iblib/lib "$tempname" 2>&1);
$output = `$command`;
$output =~ s!^Cookie:.*$!Cookie: !smg; # cookies get re-ordered, sometimes
$code_output =~ s!^Cookie:.*$!Cookie: !smg; # cookies get re-ordered, sometimes
is( $output, $code_output, "Output of $name is identical" )
or diag "Script:\n$script";
my $script_requests = $server->get_log;
$code_requests =~ s!\b$code_port\b!$script_port!smg;
$code_requests =~ s!^Cookie:.*$!Cookie: !smg; # cookies get re-ordered, sometimes
$script_requests =~ s!^Cookie:.*$!Cookie: !smg; # cookies get re-ordered, sometimes
is($code_requests,$script_requests,"$name produces identical queries")
or diag $script;
};
unlink $tempname
or diag "Couldn't remove tempfile '$name' : $!";
};
# $server->stop;
unlink $_ for (<*.save_log_server_test.tmp>);
};
WWW-Mechanize-Shell-0.56/t/12-comments.t 0000755 0001750 0001750 00000002150 13077733715 017155 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use vars qw( @comments $_STDOUT_ $_STDERR_ );
# pre-5.8.0's warns aren't caught by a tied STDERR.
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
BEGIN { @comments = ( "#", "# a test", "#eval 1", "# eval 1", "## eval 1" )};
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
use Test::More tests => 1 + scalar @comments * 3;
SKIP: {
#skip "Can't load Term::ReadKey without a terminal", 1 + scalar @comments * 3
# unless -t STDIN;
#eval { require Term::ReadKey; Term::ReadKey::GetTerminalSize(); };
#if ($@) {
# no warnings 'redefine';
# *Term::ReadKey::GetTerminalSize = sub {80,24};
# diag "Term::ReadKey seems to want a terminal";
#};
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
for (@comments) {
$_STDOUT_ = "";
$_STDERR_ = "";
eval { $s->cmd($_); };
is($@,"","Comment '$_' produces no error");
is($_STDOUT_,"","Comment '$_' produces no output");
is($_STDERR_,"","Comment '$_' produces no error output");
};
};
WWW-Mechanize-Shell-0.56/t/00a-Term-Shell-catch-smry.t 0000755 0001750 0001750 00000002643 13077733715 021521 0 ustar corion corion use strict;
use Test::More tests => 1;
use lib 'inc';
use IO::Catch;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
$ENV{COLUMNS} = 80;
$ENV{LINES} = 24;
TODO: {
#local $TODO = "Term::Shell::catch_smry is buggy";
# Now check that the Term::Shell summary calls catch_smry
require Term::Shell;
use vars qw( $called );
{
package Term::Shell::Test;
use base 'Term::Shell';
sub summary { $::called++ };
sub print_pairs {};
};
my $s = { handlers => { foo => { run => sub {}}} };
bless $s, 'Term::Shell::Test';
{ local *STDOUT;
tie *STDOUT, 'IO::Catch', '_STDOUT_';
$s->run_help();
};
if (not is($called,1,"Term::Shell::Test::catch_smry gets called for unknown methods")) {
diag "Term::Shell did not call a custom catch_smry handler";
diag "This is most likely because your version of Term::Shell";
diag "has a bug. Please upgrade to v0.02 or higher, which";
diag "should close this bug.";
diag "If that is no option, patch sub help() in Term/Shell.pm, line 641ff.";
diag "to:";
diag ' #my $smry = exists $o->{handlers}{$h}{smry};';
diag ' #? $o->summary($h);';
diag ' #: "undocumented";';
diag ' my $smry = $o->summary($h);';
diag 'Fixing this is not necessary - you will get no online help';
diag 'but the shell will otherwise work fine. Help is still';
diag 'available through ``perldoc WWW::Mechanize::Shell``';
};
};
WWW-Mechanize-Shell-0.56/t/15-history-save.t 0000755 0001750 0001750 00000003202 13077733715 017767 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use File::Temp qw( tempfile );
# pre-5.8.0's warns aren't caught by a tied STDERR.
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
use Test::More tests => 7;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
my ($fh,$name) = tempfile();
close $fh;
$s->cmd('autofill foo Fixed bar');
$s->cmd(sprintf 'history "%s"', $name);
my $script = join("\n", $s->history)."\n";
ok(-f $name, "History file exists");
open F, "< $name"
or die "Couldn't open tempfile $name : $!";
my $file = do { local $/; };
close F;
is($file, $script, "Written history is the same as history()");
unlink $name
or warn "Couldn't remove tempfile $name : $!";
($fh,$name) = tempfile();
close $fh;
$s->cmd(sprintf 'script "%s"', $name);
$script = join("\n", $s->script(" "))."\n";
ok(-f $name, "Script file exists");
open F, "< $name"
or die "Couldn't open tempfile $name : $!";
$file = do { local $/; };
close F;
is($file, $script, "Written script is the same as script()");
unlink $name
or warn "Couldn't remove tempfile $name : $!";
($fh,$name) = tempfile();
close $fh;
$s->agent->{content} = "test";
$s->cmd(sprintf 'content "%s"', $name);
my $content = $s->agent->content . "\n";
ok(-f $name, "Script file exists");
open F, "< $name"
or die "Couldn't open tempfile $name : $!";
$file = do { local $/; };
close F;
is($file, $content, 'Written content is the same as $agent->content');
unlink $name
or warn "Couldn't remove tempfile $name : $!";
WWW-Mechanize-Shell-0.56/t/99-manifest.t 0000755 0001750 0001750 00000001546 13077733715 017165 0 ustar corion corion use strict;
use Test::More;
# Check that MANIFEST and MANIFEST.skip are sane :
use File::Find;
use File::Spec;
my @files = qw( MANIFEST MANIFEST.SKIP );
plan tests => scalar @files * 4
+1 # MANIFEST existence check
;
for my $file (@files) {
ok(-f $file, "$file exists");
open F, "<$file"
or die "Couldn't open $file : $!";
my @lines = ;
is_deeply([grep(/^$/, @lines)],[], "No empty lines in $file");
is_deeply([grep(/^\s+$/, @lines)],[], "No whitespace-only lines in $file");
is_deeply([grep(/^\s*\S\s+$/, @lines)],[],"No trailing whitespace on lines in $file");
if ($file eq 'MANIFEST') {
chomp @lines;
is_deeply([grep { s/\s.*//; ! -f } @lines], [], "All files in $file exist")
or do { diag "$_ is mentioned in $file but doesn't exist on disk" for grep { ! -f } @lines };
};
close F;
};
WWW-Mechanize-Shell-0.56/t/02-fallback-HTML-TableExtract.t 0000755 0001750 0001750 00000002361 13077733715 022214 0 ustar corion corion use strict;
use Test::More tests => 4;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
SKIP: {
#skip "Can't load Term::ReadKey without a terminal", 4
# unless -t STDIN;
eval {
require Test::Without::Module;
Test::Without::Module->import('HTML::TableExtract')
};
skip "Need Test::Without::Module to test the fallback", 4
if $@;
#eval { require Term::ReadKey; Term::ReadKey::GetTerminalSize(); };
#if ($@) {
# no warnings 'redefine';
# *Term::ReadKey::GetTerminalSize = sub {80,24};
# diag "Term::ReadKey seems to want a terminal";
#};
use_ok("WWW::Mechanize::Shell");
my $shell = do {
WWW::Mechanize::Shell->new("shell", rcfile => undef, warnings => undef );
};
isa_ok($shell,"WWW::Mechanize::Shell");
my $text;
my $warned;
{
local $SIG{__WARN__} = sub {
$warned = $_[0];
};
$shell->option('warnings',1);
eval {
$shell->cmd("tables");
};
};
is( $@, '', "No error without HTML::TableExtract");
my $pass = ($warned =~ qr'^HTML\W+TableExtract\.pm did not return a true value')
|| ($warned =~ qr!^Can't locate HTML/TableExtract.pm in \@INC!);
ok $pass, "Missing HTML::TableExtract raises warning"
or diag "Caught warning '$warned'";
};
WWW-Mechanize-Shell-0.56/t/09-invalid-filename.t 0000755 0001750 0001750 00000001501 13077733715 020541 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use File::Temp qw( tempfile );
# pre-5.8.0's warns aren't caught by a tied STDERR.
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
use Test::More tests => 2;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
SKIP: {
#skip "Can't load Term::ReadKey without a terminal", 2
# unless -t STDIN;
#eval { require Term::ReadKey; Term::ReadKey::GetTerminalSize(); };
#if ($@) {
# no warnings 'redefine';
# *Term::ReadKey::GetTerminalSize = sub {80,24};
# diag "Term::ReadKey seems to want a terminal";
#};
use_ok('WWW::Mechanize::Shell');
# Silence all warnings
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
eval {
$s->cmd('source this_file_does_not_exist');
};
is($@,"","A nonexisting file does not crash the shell");
};
WWW-Mechanize-Shell-0.56/t/99-unix-text.t 0000755 0001750 0001750 00000001404 13077733715 017315 0 ustar corion corion use Test::More;
# Check that all released module files are in
# UNIX text format
use File::Spec;
use File::Find;
use strict;
my @files;
my $blib = File::Spec->catfile(qw(blib lib));
find(\&wanted, grep { -d } ($blib, 'bin'));
plan tests => scalar @files;
foreach my $file (@files) {
unix_file_ok($file);
}
sub wanted {
push @files, $File::Find::name if /\.p(l|m|od)$/;
}
sub unix_file_ok {
my ($filename) = @_;
local $/;
open F, "< $filename"
or die "Couldn't open '$filename' : $!\n";
binmode F;
my $content = ;
my $i;
my @lines = grep { /\x0D\x0A$/sm } map { sprintf "%s: %s\x0A", $i++, $_ } split /\x0A/, $content;
unless (is(scalar @lines, 0,"'$filename' contains no windows newlines")) {
diag $_ for @lines;
};
close F;
};
WWW-Mechanize-Shell-0.56/t/28-cmd-title.t 0000755 0001750 0001750 00000003466 13077733715 017234 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use vars qw($_STDOUT_ );
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
delete $ENV{PAGER}
if $ENV{PAGER};
$ENV{PERL_HTML_DISPLAY_CLASS}="HTML::Display::Dump";
use Test::More tests => 6;
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
isa_ok $s, 'WWW::Mechanize::Shell';
SKIP: {
$s->agent->{base} = 'http://example.com';
$s->agent->update_html(<
An HTML page
Some body
HTML
$s->cmd('title');
chomp $_STDOUT_;
is($_STDOUT_,"An HTML page", "Title gets output correctly");
undef $_STDOUT_;
$s->agent->update_html(<
Some body
HTML
$s->cmd('title');
chomp $_STDOUT_;
is($_STDOUT_,"", "Empty title gets output correctly");
undef $_STDOUT_;
$s->agent->update_html(<
0
Some body
HTML
$s->cmd('title');
chomp $_STDOUT_;
is($_STDOUT_,"0", "False title gets output correctly");
undef $_STDOUT_;
$s->agent->update_html(<
Some body
HTML
$s->cmd('title');
chomp $_STDOUT_;
is($_STDOUT_,"", "A missing title gets output correctly");
};
WWW-Mechanize-Shell-0.56/t/05-options.t 0000755 0001750 0001750 00000002565 13077733715 017037 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use vars qw( @options );
BEGIN {
@options = qw(
autosync
autorestart
watchfiles
cookiefile
dumprequests
dumpresponses
verbose
warnings
);
};
use Test::More tests => scalar @options*4 +1+4;
SKIP: {
BEGIN {
$ENV{PERL_RL} = 0;
use_ok('WWW::Mechanize::Shell');
};
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
for my $option (@options) {
my $oldval = $s->option($option);
my $oldval2 = $s->option($option,"newvalue");
is( $s->option($option), "newvalue", "Setting option '$option' via ->option()" );
is( $oldval, $oldval2, "->option('$option','newvalue') returns the previous value");
is( $s->option($option,$oldval2), "newvalue", "->option('$option','newvalue') returns the previous value (2)");
is( $s->option($option), $oldval, "Setting option '$option' via ->option() (2)");
};
my $warned;
no warnings 'redefine';
local *Carp::carp = sub { $warned = $_[0] };
my $res = $s->option('doesnotexist');
is( $res, undef, "Nonexisting option returns undef");
is( $warned, "Unknown option 'doesnotexist'", "Nonexisting option raises a warning");
$res = $s->option('doesnotexist','newvalue');
is( $res, undef, "Nonexisting option returns undef" );
is( $warned, "Unknown option 'doesnotexist'","Nonexisting option raises a warning" );
};
WWW-Mechanize-Shell-0.56/t/29-launch-shell.t 0000755 0001750 0001750 00000001212 13077733715 017715 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use Test::More tests => 4;
use File::Spec;
use File::Temp qw(tempfile);
my $perl = $^X;
if ($perl =~ /\s/) {
$perl = qq{"$perl"};
};
my ($fh,$temp) = tempfile();
print {$fh} "quit\n";
close $fh;
my $res = system($perl, "-I./blib/lib", "-MWWW::Mechanize::Shell", "-eshell(warnings=>undef)", $temp);
is $res,0,"Shell launch works";
is $?, 0, "No error on exit";
unlink $temp
or diag "Couldn't remove '$temp': $!";
use_ok "WWW::Mechanize::Shell";
my $s = WWW::Mechanize::Shell->new("shell",warnings=>undef);
my $prompt = eval { $s->prompt_str };
is $@, '', "prompt_str() doesn't die for empty WWW::Mechanize";
WWW-Mechanize-Shell-0.56/t/11-browse-without-request.t 0000755 0001750 0001750 00000000722 13077733715 022022 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use Test::More tests => 2;
BEGIN {
# Choose a nonannoying HTML displayer:
$ENV{PERL_HTML_DISPLAY_CLASS} = 'HTML::Display::Dump';
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
use_ok('WWW::Mechanize::Shell');
};
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
# Now test
eval { $s->cmd('browse'); };
is($@, "", "Browsing without requesting anything does not crash the shell");
WWW-Mechanize-Shell-0.56/t/01-fallback-Win32-OLE.t 0000644 0001750 0001750 00000001067 13077733715 020405 0 ustar corion corion use strict;
use Test::More tests => 3;
# Disable all ReadLine functionality
SKIP: {
$ENV{PERL_RL} = 0;
eval {
require Test::Without::Module;
Test::Without::Module->import('Win32::OLE')
};
skip "Need Test::Without::Module to test the fallback", 3
if $@;
use_ok("WWW::Mechanize::Shell");
my $shell = do {
WWW::Mechanize::Shell->new("shell", rcfile => undef, warnings => undef );
};
isa_ok($shell,"WWW::Mechanize::Shell");
my $browser;
eval {
$browser = $shell->browser;
};
is( $@, '', "No error without Win32::OLE");
};
WWW-Mechanize-Shell-0.56/t/99-pod.t 0000644 0001750 0001750 00000001232 13077733715 016126 0 ustar corion corion use Test::More;
# Check our Pod
# The test was provided by Andy Lester,
# who stole it from Brian D. Foy
# Thanks to both !
use File::Spec;
use File::Find;
use strict;
eval {
require Test::Pod;
Test::Pod->import;
};
my @files;
if ($@) {
plan skip_all => "Test::Pod required for testing POD";
}
elsif ($Test::Pod::VERSION < 0.95) {
plan skip_all => "Test::Pod 0.95 required for testing POD";
}
else {
my $blib = File::Spec->catfile(qw(blib lib));
find(\&wanted, grep { -d } ($blib, 'bin'));
plan tests => scalar @files;
foreach my $file (@files) {
pod_file_ok($file);
}
}
sub wanted {
push @files, $File::Find::name if /\.p(l|m|od)$/;
}
WWW-Mechanize-Shell-0.56/t/06-valid-output.t 0000755 0001750 0001750 00000007471 13077733715 020003 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use Test::More ();
use File::Temp qw( tempfile );
use WWW::Mechanize::Link;
# pre-5.8.0's warns aren't caught by a tied STDERR.
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
BEGIN {
# Choose a nonannoying HTML displayer:
$ENV{PERL_HTML_DISPLAY_CLASS} = 'HTML::Display::Dump';
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
};
use vars qw( %tests );
BEGIN {
%tests = (
'autofill' => 'autofill test Fixed value',
'back' => 'back',
'click' => 'click',
'content' => 'content',
'eval' => 'eval 1',
'fillout' => 'fillout',
'get @' => 'get http://admin@www.google.com/',
'get plain' => 'get http://www.google.com/',
'open' => 'open "foo link"',
'reload' => 'reload',
'referrer' => 'referrer ""',
'referrer val' => 'referrer "foo"',
'referer' => 'referer ""',
'save' => 'save 0',
'save re' => 'save /.../',
'submit' => 'submit',
'tick' => 'tick key value',
'tick_all' => 'tick key',
'timeout' => 'timeout 60',
'value' => 'value key value',
'ua' => 'ua foo/1.1',
'untick' => 'untick key value',
'untick_all' => 'untick key',
);
eval {
require HTML::TableExtract;
$HTML::TableExtract::VERSION >= 2
or die "Need HTML::TableExtract version >= 2";
$tests{table} = 'table';
$tests{'table params'} = 'table foo bar';
};
};
use Test::More tests => scalar (keys %tests)*2 +1;
BEGIN { use_ok('WWW::Mechanize::Shell'); };
SKIP: {
eval {
require Test::MockObject;
Test::MockObject->import();
};
skip "Test::MockObject not installed", scalar (keys %tests)*2
if $@;
my $mock_result = Test::MockObject->new;
$mock_result->set_always( code => 200 );
my $mock_form = Test::MockObject->new;
$mock_form->mock( value => sub {} )
->set_list( inputs => ())
->set_list( find_input => ());
my $mock_agent = Test::MockObject->new;
$mock_agent->set_true($_)
for qw( back content get open );
$mock_agent->set_false($_)
for qw( form forms );
my $mock_uri = Test::MockObject->new;
$mock_uri->set_always( abs => 'http://example.com/' )
->set_always( path => '/' );
$mock_uri->fake_module( 'URI::URL', new => sub {$mock_uri} );
$mock_agent->set_always( res => $mock_result )
->set_always( add_header => 1 )
->set_always( submit => $mock_result )
->set_always( click => $mock_result )
->set_always( reload => $mock_result )
->set_always( current_form => $mock_form )
->set_always( follow_link => 1 )
->set_list( links => WWW::Mechanize::Link->new('foo','foo link','foo_link',""),
WWW::Mechanize::Link->new('foo2','foo2 link','foo2_link',""))
->set_always( agent => 'foo/1.0' )
->set_always( tick => 1 )
->set_always( timeout => 1 )
->set_always( untick => 1 )
->set_always( uri => $mock_uri );
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef, watchfiles => undef );
$s->{agent} = $mock_agent;
my @history;
{ no warnings 'redefine';
*WWW::Mechanize::Shell::add_history = sub {
shift;
# warn $_ for @_;
push @history, join "", @_;
};
};
sub compiles_ok {
my ($command,$testname) = @_;
$testname ||= $command;
@history = ();
$s->cmd($command);
local $, = "\n";
my ($fh,$name) = tempfile();
print $fh ( "@history" );
close $fh;
ok( scalar @history != 0, "$testname is history relevant");
my $output = `$^X -Ilib -c $name 2>&1`;
chomp $output;
is( $output, "$name syntax OK", "$testname compiles")
or diag "Created file was :\n@history";
unlink $name
or diag "Couldn't remove tempfile '$name' : $!";
};
foreach my $name (sort keys %tests) {
compiles_ok( $tests{$name},$name );
};
};
WWW-Mechanize-Shell-0.56/t/07-history-items.t 0000755 0001750 0001750 00000006754 13077733715 020172 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use File::Temp qw( tempfile );
use WWW::Mechanize::Link;
# pre-5.8.0's warns aren't caught by a tied STDERR.
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
use vars qw( %tests );
BEGIN {
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
%tests = (
'autofill' => 'autofill test Fixed value',
'back' => 'back',
'click' => 'click',
'content' => 'content',
'eval' => 'eval 1',
'fillout' => 'fillout',
'form' => 'form 1',
'form' => 'form test',
'get @' => 'get http://admin@www.google.com/',
'get plain' => 'get http://www.google.com/',
'open' => 'open "foo link"',
'reload' => 'reload',
'referer' => 'referer ""',
'referrer' => 'referrer ""',
'save' => 'save /.../',
'submit' => 'submit',
'value' => 'value key value',
'ua' => 'ua foo/1.0',
'tick' => 'tick key value',
'tick_all' => 'tick key',
'timeout' => 'timeout 60',
'untick' => 'untick key value',
'untick_all' => 'untick key',
);
eval {
require HTML::TableExtract;
$tests{table} = 'table';
$tests{table params} = 'table foo bar';
;
};
};
use Test::More tests => scalar (keys %tests) +1;
SKIP: {
eval {
require Test::MockObject;
Test::MockObject->import();
};
skip "Test::MockObject not installed", scalar keys(%tests) +1
if $@;
my $mock_result = Test::MockObject->new;
$mock_result->set_always( code => 200 );
my $mock_form = Test::MockObject->new;
$mock_form->mock( value => sub {} )
->set_list( inputs => ())
->set_list( find_input => ())
->mock( dump => sub {} )
->set_always( form_name => 'foo' );
my $mock_uri = Test::MockObject->new;
$mock_uri->set_always( abs => 'http://example.com/' )
->set_always( path => '/' );
$mock_uri->fake_module( 'URI::URL', new => sub {$mock_uri} );
my $mock_agent = Test::MockObject->new;
$mock_agent->set_true($_)
for qw( back content get mirror open follow );
$mock_agent->set_false($_)
for qw( form forms );
$mock_agent->set_always( res => $mock_result )
->set_always( add_header => 1 )
->set_always( submit => $mock_result )
->set_always( click => $mock_result )
->set_always( reload => $mock_result )
->set_always( current_form => $mock_form )
->set_always( form_name => 'test form name' )
->set_always( follow_link => 1 )
->set_list( links => WWW::Mechanize::Link->new('foo','foo link','foo_link',""),
WWW::Mechanize::Link->new('foo2','foo2 link','foo2_link',""))
->set_always( agent => 'mocked/1.0')
->set_always( uri => $mock_uri )
->set_always( request => $mock_result )
->set_always( tick => 1 )
->set_always( timeout => 1 )
->set_always( untick => 1 )
;
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef, watchfiles => undef );
$s->{agent} = $mock_agent;
my @history;
{ no warnings 'redefine','once';
*WWW::Mechanize::Shell::add_history = sub {
my $shell = shift;
push @history, $shell->line;
};
};
sub exactly_one_line {
my ($command,$testname) = @_;
$testname ||= $command;
@history = ();
$s->cmd($command);
is_deeply([@history],[$command],"$testname adds one line to history");
};
foreach my $name (sort keys %tests) {
exactly_one_line( $tests{$name},$name );
};
};
WWW-Mechanize-Shell-0.56/t/17-eval-multiline.t 0000755 0001750 0001750 00000002076 13077733715 020273 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use File::Temp qw( tempfile );
use vars qw($_STDOUT_ $_STDERR_);
# pre-5.8.0's warns aren't caught by a tied STDERR.
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
use Test::More tests => 7;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
use_ok('WWW::Mechanize::Shell');
sub command_ok {
my ($command,$expected,$name) = @_;
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
$s->agent->get("file:t/17-eval-multiline.t");
eval { $s->cmd($command) };
is($@,"","$name does not crash")
or diag "Crash on '$command'";
is($_STDERR_,undef,"$name produces no warnings");
is($_STDOUT_,$expected,"$name produces the desired output")
or diag "Command: '$command'";
undef $_STDOUT_;
undef $_STDERR_;
};
command_ok('eval "Hello",
" World"', "Hello World\n","Multiline eval");
command_ok('eval "Hello from ",
$self->agent->uri || ""', "Hello from file:t/17-eval-multiline.t\n","Multiline eval substitution");
WWW-Mechanize-Shell-0.56/t/27-index.html 0000644 0001750 0001750 00000002642 13077733715 017151 0 ustar corion corion
WWW-Mechanize-Shell-0.56/t/21-autofill-re.t 0000755 0001750 0001750 00000001621 13077733715 017555 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use File::Temp qw( tempfile );
use IO::Catch;
use vars qw($_STDOUT_ $_STDERR_);
# pre-5.8.0's warns aren't caught by a tied STDERR.
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
use Test::More tests => 2;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
$s->agent->{content} = q{};
$s->agent->{forms} = [ HTML::Form->parse($s->agent->{content}, "http://www.example.com/" )];
$s->agent->{form} = $s->agent->{forms}->[0];
$s->cmd( 'autofill /qu/i Fixed "filled"' );
$s->cmd( 'fillout' );
is($s->agent->current_form->find_input("query")->value,"filled", "autofill via RE works");
WWW-Mechanize-Shell-0.56/t/13-command-au.t 0000755 0001750 0001750 00000006614 13077733715 017363 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use FindBin;
use lib './inc';
use IO::Catch;
use vars qw( $_STDOUT_ $_STDERR_ );
# pre-5.8.0's warns aren't caught by a tied STDERR.
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
use Test::More tests => 6;
SKIP: {
use_ok('WWW::Mechanize::Shell');
eval { require HTTP::Daemon; };
skip "HTTP::Daemon required to test basic authentication",7
if ($@);
# We want to be safe from non-resolving local host names
delete @ENV{qw(HTTP_PROXY http_proxy CGI_HTTP_PROXY)};
my $user = 'foo';
my $pass = 'bar';
# Now start a fake webserver, fork, and connect to ourselves
open SERVER, qq{"$^X" "$FindBin::Bin/401-server" $user $pass |}
or die "Couldn't spawn fake server : $!";
sleep 1; # give the child some time
my $url = ;
chomp $url;
die "Couldn't decipher host/port from '$url'"
unless $url =~ m!^http://([^/]+)/!;
my $host = $1;
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
# First try with an inline username/password
my $pwd_url = $url;
$pwd_url =~ s!^http://!http://$user:$pass\@!;
$pwd_url .= 'thisshouldpass';
diag "get $pwd_url";
$s->cmd( "get $pwd_url" );
diag $s->agent->res->message
unless is($s->agent->res->code, 200, "Request with inline credentials gives 200");
is($s->agent->content, "user = 'foo' pass = 'bar'", "Credentials are good");
# Now try without credentials
my $bare_url = $url . "thisshouldfail";
diag "get $bare_url";
$s->cmd( "get $bare_url" );
my $code = $s->agent->response->code;
my $got_url = $s->agent->uri;
if (! ok $code == 401 || $got_url ne $bare_url, "Request without credentials gives 401 (or is hidden by a WWW::Mechanize bug)") {
diag "Page location : " . $s->agent->uri;
diag $s->agent->res->as_string;
};
SKIP: {
if ($got_url ne $url) {
skip "WWW::Mechanize 1.50 has a bug that doesn't give you a 401 page", 1;
} else {
like($s->agent->content, '/^auth required /', "Content requests authentication")
or diag $s->agent->res->as_string;
};
};
# Now try the shell command for authentication
$s->cmd( "auth foo bar" );
# WWW::Mechanize breaks the LWP::UserAgent API in a bad, bad way
# it even monkeypatches LWP::UserAgent so we have no better way
# than to hope for the best :-(((
# If it didn't return our expected credentials, we're a victim of
# WWW::Mechanize's monkeypatch :-(
my @credentials = $s->agent->get_basic_credentials();
if ($credentials[0] ne 'foo') {
SKIP: {
skip "WWW::Mechanize $WWW::Mechanize::VERSION has buggy implementation/override of ->credentials", 1;
};
} else {
diag "Credentials are @credentials";
use Data::Dumper;
my $a = $s->agent;
@credentials = $a->get_basic_credentials();
diag "Credentials are @credentials";
my @real_credentials = LWP::UserAgent::credentials($a,$host,'testing realm');
SKIP: {
if ($real_credentials[0] ne $credentials[0]) {
skip "WWW::Mechanize credentials() patch breaks LWP::UserAgent credentials()", 1;
} else {
$s->cmd( "get $url" );
diag $s->agent->res->message
unless is($s->agent->res->code, 200, "Request with credentials gives 200");
is($s->agent->content, "user = 'foo' pass = 'bar'", "Credentials are good");
};
};
};
diag "Shutting down test server at $url";
$s->agent->get("${url}exit"); # shut down server
};
END {
close SERVER; # boom
};
WWW-Mechanize-Shell-0.56/t/99-versions.t 0000644 0001750 0001750 00000002322 13077733715 017215 0 ustar corion corion #!perl -w
# Stolen from ChrisDolan on use.perl.org
# http://use.perl.org/comments.pl?sid=29264&cid=44309
use warnings;
use strict;
use File::Find;
use Test::More;
BEGIN {
eval 'use File::Slurp; 1';
if ($@) {
plan skip_all => "File::Slurp needed for testing";
exit 0;
};
};
plan 'no_plan';
my $last_version = undef;
sub check {
return if (! m{blib/script/}xms && ! m{\.pm \z}xms);
my $content = read_file($_);
# only look at perl scripts, not sh scripts
return if (m{blib/script/}xms && $content !~ m/\A \#![^\r\n]+?perl/xms);
my @version_lines = $content =~ m/ ( [^\n]* \$VERSION \s* = [^=] [^\n]* ) /gxms;
if (@version_lines == 0) {
fail($_);
}
for my $line (@version_lines) {
if (!defined $last_version) {
$last_version = shift @version_lines;
diag "Checking for $last_version";
pass($_);
} else {
is($line, $last_version, $_);
}
}
}
find({wanted => \&check, no_chdir => 1}, 'blib');
if (! defined $last_version) {
fail('Failed to find any files with $VERSION');
}
WWW-Mechanize-Shell-0.56/t/19-value-multi.t 0000755 0001750 0001750 00000004446 13077733715 017615 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
# pre-5.8.0's warns aren't caught by a tied STDERR.
$SIG{__WARN__} = sub { $main::_STDERR_ .= join '', @_; };
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
use Test::More tests => 1 +3;
BEGIN {
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
use_ok('WWW::Mechanize::Shell');
};
TODO: {
local $TODO = "Implement passing of multiple values";
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
$s->agent->{content} = join "", ;
$s->agent->{forms} = [ HTML::Form->parse($s->agent->{content}, 'http://localhost/test/') ];
$s->agent->{form} = @{$s->agent->{forms}} ? $s->agent->{forms}->[0] : undef;
$s->cmd('value cat cat_foo cat_bar cat_baz');
is_deeply([$s->agent->current_form->find_input('cat')->form_name_value],[qw[cat cat_foo cat cat_bar cat cat_baz]])
or diag $s->agent->current_form->find_input('cat')->form_name_value;
$s->cmd('value cat ""');
is_deeply([$s->agent->current_form->find_input('cat')],[]);
$s->cmd('value cat "cat_bar"');
is_deeply([$s->agent->current_form->find_input('cat')],[qw[cat_bar]]);
};
__DATA__
WWW::Mechanize::Shell test page
WWW-Mechanize-Shell-0.56/t/28-cmd-headers.t 0000755 0001750 0001750 00000004521 13077733715 017517 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use vars qw($_STDOUT_);
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
delete $ENV{PAGER}
if $ENV{PAGER};
$ENV{PERL_HTML_DISPLAY_CLASS}="HTML::Display::Dump";
use Test::More tests => 8;
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
isa_ok $s, 'WWW::Mechanize::Shell';
sub cleanup() {
# clean up $_STDOUT_ so it fits on one line
#diag $_STDOUT_;
$_STDOUT_ =~ s/[\r\n]+/|/g;
$_STDOUT_ =~ s!(?<=:)(\s+)!(">" x (length($1)/2))!eg;
};
SKIP: {
$s->agent->{base} = 'http://example.com';
$s->agent->update_html(<
An HTML page
(H1.1)
(H2)
(H3.1)
(H3.2)
(H4)
(H1.2)
(H5)
Some spaces before this
A newline in
this
HTML
$s->cmd('headers');
cleanup;
is($_STDOUT_,"h1:(H1.1)|h2:>(H2)|h3:>>(H3.1)|h3:>>(H3.2)|h4:>>>(H4)|h1:(H1.2)|h5:>>>>(H5)|h1:|h1:Some spaces before this|h1:A newline in this|h2:>|h3:>>|", "The default works");
undef $_STDOUT_;
$s->cmd('headers 12345');
cleanup;
is($_STDOUT_,"h1:(H1.1)|h2:>(H2)|h3:>>(H3.1)|h3:>>(H3.2)|h4:>>>(H4)|h1:(H1.2)|h5:>>>>(H5)|h1:|h1:Some spaces before this|h1:A newline in this|h2:>|h3:>>|", "Explicitly specifying the default works as well");
undef $_STDOUT_;
$s->cmd('headers 1');
cleanup;
is($_STDOUT_,"h1:(H1.1)|h1:(H1.2)|h1:|h1:Some spaces before this|h1:A newline in this|", "H1 headers works as well");
undef $_STDOUT_;
$s->cmd('headers 23');
cleanup;
is($_STDOUT_,"h2:>(H2)|h3:>>(H3.1)|h3:>>(H3.2)|h2:>|h3:>>|", "Restricting to a subset works too");
undef $_STDOUT_;
$s->cmd('headers 25');
cleanup;
is($_STDOUT_,"h2:>(H2)|h5:>>>>(H5)|h2:>|", "A noncontingous subset as well");
undef $_STDOUT_;
$s->cmd('headers 52');
cleanup;
is($_STDOUT_,"h2:>(H2)|h5:>>>>(H5)|h2:>|", "Even in a weirdo order");
undef $_STDOUT_;
};
WWW-Mechanize-Shell-0.56/t/22-complete-command.t 0000755 0001750 0001750 00000001214 13077733715 020555 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use Test::More tests => 2;
use WWW::Mechanize::Link;
BEGIN {
# Choose a nonannoying HTML displayer:
$ENV{PERL_HTML_DISPLAY_CLASS} = 'HTML::Display::Dump';
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
use_ok('WWW::Mechanize::Shell');
};
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
# Now test
{ no warnings 'redefine';
local *WWW::Mechanize::find_all_links = sub {
return (WWW::Mechanize::Link->new("","foo","",""),WWW::Mechanize::Link->new("","bar","","")) };
my @comps = $s->comp_open("fo","fo",0);
is_deeply(\@comps,["foo"],"Completion works");
};
WWW-Mechanize-Shell-0.56/t/98-bin.t 0000755 0001750 0001750 00000001444 13077733715 016123 0 ustar corion corion use strict;
use Test::More;
# Check that all programs below bin/ compile :
use File::Find;
use File::Spec;
my $blib = File::Spec->catfile(qw(blib lib));
my @files;
my @skip;
opendir DIST,'.';
my @manifest = grep { /^manifest.skip$/i } (readdir DIST);
closedir DIST;
if (-f $manifest[0]) {
open F, "<$manifest[0]"
or die "Couldn't open $manifest[0] : $!";
@skip = map { s/\s*$//; $_ } ;
close F;
};
find(\&wanted, "bin");
plan tests => scalar @files;
foreach my $file (@files) {
my $result = `$^X "-I$blib" -c "$file" 2>&1`;
chomp $result;
is( $result, "$file syntax OK", "Script '$file' compiles");
}
sub wanted {
my $name = $File::Find::name;
push @files, $name if -f $_ and /\.pl$/ and not grep { $name =~ /$_/ } @skip;
$File::Find::prune = 1 if -d $_ and $_ ne '.';
}
WWW-Mechanize-Shell-0.56/t/26-form-no-form.t 0000755 0001750 0001750 00000002126 13077733715 017656 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use lib './inc';
use IO::Catch;
use vars qw($_STDOUT_ $_STDERR_);
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
use Test::More tests => 4;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
delete $ENV{PAGER}
if $ENV{PAGER};
$ENV{PERL_HTML_DISPLAY_CLASS}="HTML::Display::Dump";
my @warnings;
use_ok('WWW::Mechanize::Shell');
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
{ no warnings qw'redefine once';
*WWW::Mechanize::Shell::status = sub {};
};
$s->agent->{base} = 'http://www.google.com/';
$s->agent->update_html("No form here\n");
eval {
$s->cmd("form foo");
};
is($@, '', "Can execute 'form' for a page without forms");
is($_STDOUT_,"There is no form on this page.\n","Message was printed");
is($_STDERR_,undef,"No warnings printed");
#$_STDOUT_ = undef;
#$_STDERR_ = undef;
#$s->cmd("save /does-not-exist/");
#is($_STDOUT_,"No match for /(?-xism:does-not-exist)/.\n","save RE error message");
#is($_STDERR_,undef,"No warnings");
WWW-Mechanize-Shell-0.56/t/02-fallback-Pod-Constant.t 0000644 0001750 0001750 00000001650 13077733715 021376 0 ustar corion corion use strict;
use Test::More tests => 4;
# Disable all ReadLine functionality
$ENV{PERL_RL} = 0;
SKIP: {
#skip "Can't load Term::ReadKey without a terminal", 4
# unless -t STDIN;
eval {
require Test::Without::Module;
Test::Without::Module->import('Pod::Constants')
};
skip "Need Test::Without::Module to test the fallback", 4
if $@;
#eval { require Term::ReadKey; Term::ReadKey::GetTerminalSize(); };
#if ($@) {
# no warnings 'redefine';
# *Term::ReadKey::GetTerminalSize = sub {80,24};
# diag "Term::ReadKey seems to want a terminal";
#};
use_ok("WWW::Mechanize::Shell");
my $shell = do {
WWW::Mechanize::Shell->new("shell", rcfile => undef, warnings => undef );
};
isa_ok($shell,"WWW::Mechanize::Shell");
my $text;
eval {
$text = $shell->catch_smry('quit');
};
is( $@, '', "No error without Pod::Constants");
is( $text, undef, "No help without Pod::Constants");
};
WWW-Mechanize-Shell-0.56/t/16-form-fillout.t 0000755 0001750 0001750 00000102412 13077733715 017755 0 ustar corion corion #!/usr/bin/perl -w
use strict;
use FindBin;
use lib './inc';
use IO::Catch;
use File::Temp qw( tempfile );
use vars qw( %tests $_STDOUT_ $_STDERR_ );
use URI::URL;
use LWP::Simple;
# pre-5.8.0's warns aren't caught by a tied STDERR.
$SIG{__WARN__} = sub { $main::_STDERR_ .= join '', @_; };
tie *STDOUT, 'IO::Catch', '_STDOUT_' or die $!;
tie *STDERR, 'IO::Catch', '_STDERR_' or die $!;
BEGIN {
%tests = (
interactive_script_creation => { requests => 2,
lines => [ 'eval @::list=qw(1 2 3 4 5 6 7 8 9 10 foo NY 11 DE 13 V 15 16 2038-01-01)',
'eval
no warnings qw"once redefine";
*WWW::Mechanize::FormFiller::Value::Ask::ask_value = sub {
#warn "Filled out ",$_[1]->name;
my $value=shift @::list || "empty";
push @{$_[0]->{shell}->{answers}}, [ $_[1]->name, $value ];
$value
}',
'get %s',
'fillout',
'submit',
'content' ],
location => '%sgift_card/alphasite/www/cgi-bin/giftcard.cgi/checkout_process' },
);
};
use Test::More tests => 1 + (scalar keys %tests)*6;
BEGIN {
delete $ENV{PAGER};
$ENV{PERL_RL} = 0;
use_ok('WWW::Mechanize::Shell');
};
SKIP: {
# Disable all ReadLine functionality
my $HTML = do { local $/; };
eval { require HTTP::Daemon; };
skip "HTTP::Daemon required to test script/code identity",(scalar keys %tests)*6
if ($@);
require Test::HTTP::LocalServer; # from inc
# We want to be safe from non-resolving local host names
delete @ENV{qw(HTTP_PROXY http_proxy CGI_HTTP_PROXY)};
my $actual_requests;
{
no warnings 'redefine';
my $old_request = *WWW::Mechanize::request{CODE};
*WWW::Mechanize::request = sub {
$actual_requests++;
goto &$old_request;
};
*WWW::Mechanize::Shell::status = sub {};
};
for my $name (sort keys %tests) {
$_STDOUT_ = '';
undef $_STDERR_;
$actual_requests = 0;
my @lines = @{$tests{$name}->{lines}};
my $requests = $tests{$name}->{requests};
my $server = Test::HTTP::LocalServer->spawn( html => $HTML );
my $code_port = $server->port;
my $result_location = sprintf $tests{$name}->{location}, $server->url;
my $s = WWW::Mechanize::Shell->new( 'test', rcfile => undef, warnings => undef );
for my $line (@lines) {
no warnings;
$line = sprintf $line, $server->url;
$s->cmd($line);
};
$s->cmd('eval $self->agent->uri');
my $code_output = $_STDOUT_;
diag join( "\n", $s->history )
unless is($s->agent->uri,$result_location,"Shell moved to the specified url for $name");
is($_STDERR_,undef,"Shell produced no error output for $name");
is($actual_requests,$requests,"$requests requests were made for $name");
my $code_requests = $server->get_log;
my $script_server = Test::HTTP::LocalServer->spawn(html => $HTML);
my $script_port = $script_server->port;
# Modify the generated Perl script to match the new? port
my $script = join "\n", $s->script;
s!\b$code_port\b!$script_port!smg for ($script, $code_output);
undef $s;
# Write the generated Perl script
my ($fh,$tempname) = tempfile();
print $fh $script;
close $fh;
my ($compile) = `$^X -c "$tempname" 2>&1`;
chomp $compile;
unless (is($compile,"$tempname syntax OK","$name compiles")) {
$script_server->stop;
diag $script;
ok(0, "Script $name didn't compile" );
ok(0, "Script $name didn't compile" );
} else {
my ($output);
my $command = qq($^X -Ilib "$tempname" 2>&1);
$output = `$command`;
$output =~ s!^Cookie:.*$!Cookie: !smg; # cookies get re-ordered, sometimes
$code_output =~ s!^Cookie:.*$!Cookie: !smg; # cookies get re-ordered, sometimes
is( $output, $code_output, "Output of $name is identical" )
or diag "Script:\n$script";
my $script_requests = $script_server->get_log;
$code_requests =~ s!\b$code_port\b!$script_port!smg;
$code_requests =~ s!^Cookie:.*$!Cookie: !smg; # cookies get re-ordered, sometimes
$script_requests =~ s!^Cookie:.*$!Cookie: !smg; # cookies get re-ordered, sometimes
is($code_requests,$script_requests,"$name produces identical queries")
or diag $script;
};
unlink $tempname
or diag "Couldn't remove tempfile '$name' : $!";
};
unlink $_ for (<*.save_log_server_test.tmp>);
};
__DATA__
- Gift Cards
Gift Card
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent
luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
WWW-Mechanize-Shell-0.56/README.mkdn 0000644 0001750 0001750 00000044245 13077733715 016300 0 ustar corion corion
[](https://github.com/Corion/WWW-Mechanize-Shell)
# NAME
WWW::Mechanize::Shell - An interactive shell for WWW::Mechanize
# SYNOPSIS
From the command line as
perl -MWWW::Mechanize::Shell -eshell
or alternatively as a custom shell program via :
#!/usr/bin/perl -w
use strict;
use WWW::Mechanize::Shell;
my $shell = WWW::Mechanize::Shell->new("shell");
if (@ARGV) {
$shell->source_file( @ARGV );
} else {
$shell->cmdloop;
};
# DESCRIPTION
This module implements a www-like shell above WWW::Mechanize
and also has the capability to output crude Perl code that recreates
the recorded session. Its main use is as an interactive starting point
for automating a session through WWW::Mechanize.
The cookie support is there, but no cookies are read from your existing
browser sessions. See [HTTP::Cookies](https://metacpan.org/pod/HTTP::Cookies) on how to implement reading/writing
your current browsers cookies.
## `WWW::Mechanize::Shell->new %ARGS`
This is the constructor for a new shell instance. Some of the options
can be passed to the constructor as parameters.
By default, a file `.mechanizerc` (respectively `mechanizerc` under Windows)
in the users home directory is executed before the interactive shell loop is
entered. This can be used to set some defaults. If you want to supply a different
filename for the rcfile, the `rcfile` parameter can be passed to the constructor :
rcfile => '.myapprc',
## `$shell->release_agent`
Since the shell stores a reference back to itself within the
WWW::Mechanize instance, it is necessary to break this
circular reference. This method does this.
## `$shell->source_file FILENAME`
The `source_file` method executes the lines of FILENAME
as if they were typed in.
$shell->source_file( $filename );
## `$shell->display_user_warning`
All user warnings are routed through this routine
so they can be rerouted / disabled easily.
## `$shell->print_paged LIST`
Prints the text in LIST using `$ENV{PAGER}`. If `$ENV{PAGER}`
is empty, prints directly to `STDOUT`. Most of this routine
comes from the `perldoc` utility.
## `$shell->link_text LINK`
Returns a meaningful text from a WWW::Mechanize::Link object. This is (in order of
precedence) :
$link->text
$link->name
$link->url
## `$shell->history`
Returns the (relevant) shell history, that is, all commands
that were not solely for the information of the user. The
lines are returned as a list.
print join "\n", $shell->history;
## `$shell->script`
Returns the shell history as a Perl program. The
lines are returned as a list. The lines do not have
a one-by-one correspondence to the lines in the history.
print join "\n", $shell->script;
## `$shell->status`
`status` is called for status updates.
## `$shell->display FILENAME LINES`
`display` is called to output listings, currently from the
`history` and `script` commands. If the second parameter
is defined, it is the name of the file to be written,
otherwise the lines are displayed to the user.
# COMMANDS
The shell implements various commands :
## exit
Leaves the shell.
## restart
Restart the shell.
This is mostly useful when you are modifying the shell itself. It dosen't
work if you use the shell in oneliner mode with `-e`.
## get
Download a specific URL.
This is used as the entry point in all sessions
Syntax:
get URL
## save
Download a link into a file.
If more than one link matches the RE, all matching links are
saved. The filename is taken from the last part of the
URL. Alternatively, the number of a link may also be given.
Syntax:
save RE
## content
Display the content for the current page.
Syntax: content \[FILENAME\]
If the FILENAME argument is provided, save the content to the file.
A trailing "\\n" is added to the end of the content when using the
shell, so this might not be ideally suited to save binary files without
manual editing of the produced script.
## title
Display the current page title as found
in the `` tag.
## headers
Prints all `
` through `
` strings found in the content,
indented accordingly. With an argument, prints only those
levels; e.g., `headers 145` prints H1,H4,H5 strings only.
## ua
Get/set the current user agent
Syntax:
# fake Internet Explorer
ua "Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)"
# fake QuickTime v5
ua "QuickTime (qtver=5.0.2;os=Windows NT 5.0Service Pack 2)"
# fake Mozilla/Gecko based
ua "Mozilla/5.001 (windows; U; NT4.0; en-us) Gecko/25250101"
# set empty user agent :
ua ""
## links
Display all links on a page
The links numbers displayed can used by `open` to directly
select a link to follow.
## parse
Dump the output of HTML::TokeParser of the current content
## forms
Display all forms on the current page.
## form
Select the form named NAME
If NAME matches `/^\d+$/`, it is assumed to be the (1-based) index
of the form to select. There is no way of selecting a numerically
named form by its name.
## dump
Dump the values of the current form
## value
Set a form value
Syntax:
value NAME [VALUE]
## tick
Set checkbox marks
Syntax:
tick NAME VALUE(s)
If no value is given, all boxes are checked.
## untick
Remove checkbox marks
Syntax:
untick NAME VALUE(s)
If no value is given, all marks are removed.
## submit
submits the form without clicking on any button
## click
Clicks on the button named NAME.
No regular expression expansion is done on NAME.
Syntax:
click NAME
If you have a button that has no name (displayed as NONAME),
use
click ""
to click on it.
## open
accepts one argument, which can be a regular expression or the number
of a link on the page, starting at zero. These numbers are displayed by the
`links` function. It goes directly to the page if a number is used
or if the RE has one match. Otherwise, a list of links matching
the regular expression is displayed.
The regular expression should start and end with "/".
Syntax:
open [ RE | # ]
## back
Go back one page in the browser page history.
## reload
Repeat the last request, thus reloading the current page.
Note that also POST requests are blindly repeated, as this command
is mostly intended to be used when testing server side code.
## browse
Open the web browser with the current page
Displays the current page in the browser.
## set
Set a shell option
Syntax:
set OPTION [value]
The command lists all valid options. Here is a short overview over
the different options available :
autosync - automatically synchronize the browser window
autorestart - restart the shell when any required module changes
This does not work with C<-e> oneliners.
watchfiles - watch all required modules for changes
cookiefile - the file where to store all cookies
dumprequests - dump all requests to STDOUT
dumpresponses - dump the headers of the responses to STDOUT
verbose - print commands to STDERR as they are run,
when sourcing from a file
## history
Display your current session history as the relevant commands.
Syntax:
history [FILENAME]
Commands that have no influence on the browser state are not added
to the history. If a parameter is given to the `history` command,
the history is saved to that file instead of displayed onscreen.
## script
Display your current session history as a Perl script using WWW::Mechanize.
Syntax:
script [FILENAME]
If a parameter is given to the `script` command, the script is saved to
that file instead of displayed on the console.
This command was formerly known as `history`.
## comment
Adds a comment to the script and the history. The comment
is prepended with a \\n to increase readability.
## fillout
Fill out the current form
Interactively asks the values hat have no preset
value via the autofill command.
## auth
Set basic authentication credentials.
Syntax:
auth user password
If you know the authority and the realm in advance, you can
presupply the credentials, for example at the start of the script :
>auth corion secret
>get http://www.example.com
Retrieving http://www.example.com(200)
http://www.example.com>
## table
Display a table described by the columns COLUMNS.
Syntax:
table COLUMNS
Example:
table Product Price Description
If there is a table on the current page that has in its first row the three
columns `Product`, `Price` and `Description` (not necessarily in that order),
the script will display these columns of the whole table.
The `HTML::TableExtract` module is needed for this feature.
## tables
Display a list of tables.
Syntax:
tables
This command will display the top row for every
table on the current page. This is convenient if you want
to find out what the exact spellings for each column are.
The command does not always work nice, for example if a
site uses tables for layout, it will be harder to guess
what tables are irrelevant and what tables are relevant.
[HTML::TableExtract](https://metacpan.org/pod/HTML::TableExtract) is needed for this feature.
## cookies
Set the cookie file name
Syntax:
cookies FILENAME
## autofill
Define an automatic value
Sets a form value to be filled automatically. The NAME parameter is
the WWW::Mechanize::FormFiller::Value subclass you want to use. For
session fields, `Keep` is a good candidate, for interactive stuff,
`Ask` is a value implemented by the shell.
A field name starting and ending with a slash (`/`) is taken to be
a regular expression and will be applied to all fields with their
name matching the expression. A field with a matching name still
takes precedence over the regular expression.
Syntax:
autofill NAME [PARAMETERS]
Examples:
autofill login Fixed corion
autofill password Ask
autofill selection Random red green orange
autofill session Keep
autofill "/date$/" Random::Date string "%m/%d/%Y"
## eval
Evaluate Perl code and print the result
Syntax:
eval CODE
For the generated scripts, anything matching the regular expression
`/\$self->agent\b/` is automatically
replaced by `$agent` in your eval code, to do the Right Thing.
Examples:
# Say hello
eval "Hello World"
# And take a look at the current content type
eval $self->agent->ct
## source
Execute a batch of commands from a file
Syntax:
source FILENAME
## versions
Print the version numbers of important modules
Syntax:
versions
## timeout
Set new timeout value for the agent. Effects all subsequent
requests. VALUE is in seconds.
Syntax:
timeout VALUE
## ct
prints the content type of the most current response.
Syntax:
ct
## referrer
set the value of the Referer: header
Syntax:
referer URL
referrer URL
## referer
Alias for referrer
## response
display the last server response
## `$shell->munge_code( CODE )`
Munges a coderef to become code fit for
output independent of WWW::Mechanize::Shell.
## `shell`
This subroutine is exported by default as a convenience method
so that the following oneliner invocation works:
perl -MWWW::Mechanize::Shell -eshell
You can pass constructor arguments to this
routine as well. Any scripts given in `@ARGV`
will be run. If `@ARGV` is empty,
an interactive loop will be started.
# SAMPLE SESSIONS
## Entering values
# Search for a term on Google
get http://www.google.com
value q "Corions Homepage"
click btnG
script
# (yes, this is a bad example of automating, as Google
# already has a Perl API. But other sites don't)
## Retrieving a table
get http://www.perlmonks.org
open "/Saints in/"
table User Experience Level
script
# now you have a program that gives you a csv file of
# that table.
## Uploading a file
get http://aliens:xxxxx/
value f path/to/file
click "upload"
## Batch download
# download prerelease versions of my modules
get http://www.corion.net/perl-dev
save /.tar.gz$/
# REGULAR EXPRESSION SYNTAX
Some commands take regular expressions as parameters. A regular
expression **must** be a single parameter matching `^/.*/([isxm]+)?$`, so
you have to use quotes around it if the expression contains spaces :
/link_foo/ # will match as (?-xims:link_foo)
"/link foo/" # will match as (?-xims:link foo)
Slashes do not need to be escaped, as the shell knows that a RE starts and
ends with a slash :
/link/foo/ # will match as (?-xims:link/foo)
"/link/ /foo/" # will match as (?-xims:link/\s/foo)
The `/i` modifier works as expected.
If you desire more power over the regular expressions, consider dropping
to Perl or recommend me a good parser module for regular expressions.
# DISPLAYING HTML
WWW::Mechanize::Shell now uses the module HTML::Display
to display the HTML of the current page in your browser.
Have a look at the documentation of HTML::Display how to
make it use your browser of choice in the case it does not
already guess it correctly.
# FILLING FORMS VIA CUSTOM CODE
If you want to stay within the confines of the shell, but still
want to fill out forms using custom Perl code, here is a recipe
how to achieve this :
Code passed to the `eval` command gets evalutated in the WWW::Mechanize::Shell
namespace. You can inject new subroutines there and these get picked
up by the Callback class of WWW::Mechanize::FormFiller :
# Fill in the "date" field with the current date/time as string
eval sub &::custom_today { scalar localtime };
autofill date Callback WWW::Mechanize::Shell::custom_today
fillout
This method can also be used to retrieve data from shell scripts :
# Fill in the "date" field with the current date/time as string
# works only if there is a program "date"
eval sub &::custom_today { chomp `date` };
autofill date Callback WWW::Mechanize::Shell::custom_today
fillout
As the namespace is different between the shell and the generated
script, make sure you always fully qualify your subroutine names,
either in your own namespace or in the main namespace.
# GENERATED SCRIPTS
The `script` command outputs a skeleton script that reproduces
your actions as done in the current session. It pulls in
`WWW::Mechanize::FormFiller`, which is possibly not needed. You
should add some error and connection checking afterwards.
# ADDING FIELDS TO HTML
If you are automating a JavaScript dependent site, you will encounter
JavaScript like this :
HTML::Form will not know about this and will not have provided a
submit button for you (understandably). If you want to create such
a submit button from within your automation script, use the following
code :
$agent->current_form->push_input( submit => { name => "submit", value =>"submit" } );
This also works for other dynamically generated input fields.
To fake an input field from within a shell session, use the `eval` command :
eval $self->agent->current_form->push_input(submit=>{name=>"submit",value=>"submit"});
And yes, the generated script should do the Right Thing for this eval as well.
# LOCAL FILES
If you want to use the shell on a local file without setting up a `http` server
to serve the file, you can use the `file:` URI scheme to load it into the "browser":
get file:local.html
forms
# PROXY SUPPORT
Currently, the proxy support is realized via a call to
the `env_proxy` method of the WWW::Mechanize object, which
loads the proxies from the environment. There is no provision made
to prevent using proxies (yet). The generated scripts also
load their proxies from the environment.
# ONLINE HELP
The online help feature is currently a bit broken in `Term::Shell`,
but a fix is in the works. Until then, you can re-enable the
dynamic online help by patching `Term::Shell` :
Remove the three lines
my $smry = exists $o->{handlers}{$h}{smry}
? $o->summary($h)
: "undocumented";
in `sub run_help` and replace them by
my $smry = $o->summary($h);
The shell works without this patch and the online help is still
available through `perldoc WWW::Mechanize::Shell`
# BUGS
Bug reports are very welcome - please use the RT interface at
https://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Mechanize-Shell or send a
descriptive mail to bug-WWW-Mechanize-Shell@rt.cpan.org . Please
try to include as much (relevant) information as possible - a test script
that replicates the undesired behaviour is welcome every time!
- The two parameter version of the `auth` command guesses the realm from
the last received response. Currently a RE is used to extract the realm,
but this fails with some servers resp. in some cases. Use the four
parameter version of `auth`, or if not possible, code the extraction
in Perl, either in the final script or through `eval` commands.
- The shell currently detects when you want to follow a JavaScript link and tells you
that this is not supported. It would be nicer if there was some callback mechanism
to (automatically?) extract URLs from JavaScript-infected links.
# TODO
- Add XPath expressions (by moving `WWW::Mechanize` from HTML::Parser to XML::XMLlib
or maybe easier, by tacking Class::XPath onto an HTML tree)
- Add `head` as a command ?
- Optionally silence the HTML::Parser / HTML::Forms warnings about invalid HTML.
# EXPORT
The routine `shell` is exported into the importing namespace. This
is mainly for convenience so you can use the following commandline
invocation of the shell like with CPAN :
perl -MWWW::Mechanize::Shell -e"shell"
# REPOSITORY
The public repository of this module is
[https://github.com/Corion/WWW-Mechanize-Shell](https://github.com/Corion/WWW-Mechanize-Shell).
# SUPPORT
The public support forum of this module is
[http://perlmonks.org/](http://perlmonks.org/).
# COPYRIGHT AND LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Copyright (C) 2002-2017 Max Maischein
# AUTHOR
Max Maischein,
Please contact me if you find bugs or otherwise improve the module. More tests are also very welcome !
# SEE ALSO
[WWW::Mechanize](https://metacpan.org/pod/WWW::Mechanize),[WWW::Mechanize::FormFiller](https://metacpan.org/pod/WWW::Mechanize::FormFiller),[WWW::Mechanize::Firefox](https://metacpan.org/pod/WWW::Mechanize::Firefox)
WWW-Mechanize-Shell-0.56/.gitignore 0000644 0001750 0001750 00000000223 13077733715 016444 0 ustar corion corion Makefile
Makefile.old
*.tar.gz
*.bak
pm_to_blib
blib/
WWW-Mechanize-Shell-*
WWW-Mechanize-Shell-*/
.releaserc
.lwpcookies
CVS
MYMETA.*
WWW-Mechanize-Shell-0.56/META.yml 0000644 0001750 0001750 00000001067 13077733716 015735 0 ustar corion corion ---
abstract: 'An interactive shell for WWW::Mechanize'
author:
- 'Max Maischein '
build_requires: {}
dynamic_config: 0
generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.150005'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: WWW-Mechanize-Shell
no_index:
directory:
- t
- inc
resources:
repository: git://github.com/Corion/WWW-Mechanize-Shell.git
version: '0.56'
x_serialization_backend: 'CPAN::Meta::YAML version 0.018'
x_static_install: 1
WWW-Mechanize-Shell-0.56/lib/ 0000755 0001750 0001750 00000000000 13077733716 015226 5 ustar corion corion WWW-Mechanize-Shell-0.56/lib/WWW/ 0000755 0001750 0001750 00000000000 13077733716 015712 5 ustar corion corion WWW-Mechanize-Shell-0.56/lib/WWW/Mechanize/ 0000755 0001750 0001750 00000000000 13077733716 017615 5 ustar corion corion WWW-Mechanize-Shell-0.56/lib/WWW/Mechanize/Shell.pm 0000644 0001750 0001750 00000140547 13077733715 021234 0 ustar corion corion package WWW::Mechanize::Shell;
use strict;
use Carp;
use WWW::Mechanize;
use WWW::Mechanize::FormFiller;
use HTTP::Cookies;
use parent qw( Term::Shell );
use Exporter 'import';
use FindBin;
use File::Temp qw(tempfile);
use URI::URL;
use Hook::LexWrap;
use HTML::Display qw();
use HTML::TokeParser::Simple;
use B::Deparse;
use vars qw( $VERSION @EXPORT %munge_map );
$VERSION = '0.56';
@EXPORT = qw( &shell );
=head1 NAME
WWW::Mechanize::Shell - An interactive shell for WWW::Mechanize
=head1 SYNOPSIS
From the command line as
perl -MWWW::Mechanize::Shell -eshell
or alternatively as a custom shell program via :
=for example begin
#!/usr/bin/perl -w
use strict;
use WWW::Mechanize::Shell;
my $shell = WWW::Mechanize::Shell->new("shell");
if (@ARGV) {
$shell->source_file( @ARGV );
} else {
$shell->cmdloop;
};
=for example end
=for example_testing
BEGIN {
require WWW::Mechanize::Shell;
$ENV{PERL_RL} = 0;
$ENV{COLUMNS} = '80';
$ENV{LINES} = '24';
};
BEGIN {
no warnings 'once';
no warnings 'redefine';
*WWW::Mechanize::Shell::cmdloop = sub {};
*WWW::Mechanize::Shell::display_user_warning = sub {};
*WWW::Mechanize::Shell::source_file = sub {};
};
isa_ok( $shell, "WWW::Mechanize::Shell" );
=head1 DESCRIPTION
This module implements a www-like shell above WWW::Mechanize
and also has the capability to output crude Perl code that recreates
the recorded session. Its main use is as an interactive starting point
for automating a session through WWW::Mechanize.
The cookie support is there, but no cookies are read from your existing
browser sessions. See L on how to implement reading/writing
your current browsers cookies.
=head2 Cnew %ARGS>
This is the constructor for a new shell instance. Some of the options
can be passed to the constructor as parameters.
By default, a file C<.mechanizerc> (respectively C under Windows)
in the users home directory is executed before the interactive shell loop is
entered. This can be used to set some defaults. If you want to supply a different
filename for the rcfile, the C parameter can be passed to the constructor :
rcfile => '.myapprc',
=cut
sub init {
my ($self) = @_;
my ($name,%args) = @{$self->{API}{args}};
$self->{agent} = WWW::Mechanize->new();
$self->{formfiller} = WWW::Mechanize::FormFiller->new(default => [ Ask => $self ]);
$self->{history} = [];
$self->{options} = {
autosync => 0,
warnings => (exists $args{warnings} ? $args{warnings} : 1),
autorestart => 0,
watchfiles => (exists $args{watchfiles} ? $args{watchfiles} : 1),
cookiefile => 'cookies.txt',
dumprequests => 0,
dumpresponses => 0,
verbose => 0,
};
# Install the request dumper :
$self->{request_wrapper} = wrap 'LWP::UserAgent::request',
#pre => sub { printf STDERR "Dumping? %s\n",$self->option("dumprequests"); $self->request_dumper($_[1]) if $self->option("dumprequests"); },
pre => sub { $self->request_dumper($_[1]) if $self->option("dumprequests"); },
post => sub {
$self->response_dumper($_[-1]) if $self->option("dumpresponses");
};
$self->{redirect_ok_wrapper} = wrap 'WWW::Mechanize::redirect_ok',
post => sub {
return unless $_[1];
$self->status( "\nRedirecting to ".$_[1]->uri."\n" );
$_[-1]
};
# Load the proxy settings from the environment
$self->agent->env_proxy();
# Read our .rc file :
# I could use File::Homedir, but the docs claim it dosen't work on Win32. Maybe
# I should just release a patch for File::Homedir then... Not now.
my $sourcefile;
if (exists $args{rcfile}) {
$sourcefile = delete $args{rcfile};
} else {
my $userhome = $^O =~ /win32/i ? $ENV{'USERPROFILE'} || $ENV{'HOME'} : ((getpwuid($<))[7]);
$sourcefile = "$userhome/.mechanizerc"
if -f "$userhome/.mechanizerc";
};
$self->option('cookiefile', $args{cookiefile}) if (exists $args{cookiefile});
$self->source_file($sourcefile) if defined $sourcefile;
$self->{browser} = undef;
# Keep track of the files we consist of, to enable automatic reloading
$self->{files} = undef;
if ($self->option('watchfiles')) {
eval {
my @files = grep { -f && -r && $_ ne '-e' } values %INC;
local $, = ",";
require File::Modified;
$self->{files} = File::Modified->new(files=>[@files]);
};
$self->display_user_warning( "Module File::Modified not found. Automatic reloading disabled.\n" )
if ($@);
};
};
=head2 C<$shell-Erelease_agent>
Since the shell stores a reference back to itself within the
WWW::Mechanize instance, it is necessary to break this
circular reference. This method does this.
=cut
sub release_agent {
my ($self) = @_;
use Data::Dumper;
warn Dumper $self;
undef $self->{request_wrapper};
undef $self->{redirect_ok_wrapper};
$self->{agent} = undef;
};
=head2 C<$shell-Esource_file FILENAME>
The C method executes the lines of FILENAME
as if they were typed in.
$shell->source_file( $filename );
=cut
sub source_file {
my ($self,$filename) = @_;
local $_; # just to be on the safe side that we don't clobber outside users of $_
local *F;
open F, "< $filename"
or die "Couldn't open '$filename' : $!\n";
while () {
$self->cmd($_);
warn "cmd: $_"
if $self->{options}->{verbose};
};
close F;
};
sub add_history {
my ($self,@code) = @_;
push @{$self->{history}},[$self->line,join "",@code];
};
=head2 C<$shell-Edisplay_user_warning>
All user warnings are routed through this routine
so they can be rerouted / disabled easily.
=cut
sub display_user_warning {
my ($self,@message) = @_;
warn @message
if $self->option('warnings');
};
=head2 C<$shell-Eprint_paged LIST>
Prints the text in LIST using C<$ENV{PAGER}>. If C<$ENV{PAGER}>
is empty, prints directly to C. Most of this routine
comes from the C utility.
=cut
sub print_paged {
my $self = shift;
if ($ENV{PAGER} and -t STDOUT) {
my ($fh,$filename) = tempfile();
print $fh $_ for @_;
close $fh;
my @pagers = ($ENV{PAGER},qq{"$^X" -p});
foreach my $pager (@pagers) {
if ($^O eq 'VMS') {
last if system("$pager $filename") == 0; # quoting prevents logical expansion
} else {
last if system(qq{$pager "$filename"}) == 0;
}
};
unlink $filename
or $self->display_user_warning("Couldn't unlink tempfile $filename : $!\n");
} else {
print $_ for @_;
};
};
sub agent { $_[0]->{agent}; };
sub option {
my ($self,$option,$value) = @_;
if (exists $self->{options}->{$option}) {
my $result = $self->{options}->{$option};
if (scalar @_ == 3) {
$self->{options}->{$option} = $value;
};
$result;
} else {
Carp::carp "Unknown option '$option'";
undef;
};
};
sub restart_shell {
if ($0 ne '-e') {
print "Restarting $0\n";
exec $^X, $0, @ARGV;
};
};
sub precmd {
my $self = shift @_;
# We want to restart when any module was changed
if ($self->{files} and $self->{files}->changed()) {
print "One or more of the base files were changed\n";
$self->restart_shell if ($self->option('autorestart'));
};
$self->SUPER::precmd(@_);
};
sub browser {
my ($self) = @_;
$self->{browser} ||= HTML::Display->new();
$self->{browser};
};
sub sync_browser {
my ($self) = @_;
# We only can display html if we have any :
return unless $self->agent->res;
# Prepare the HTML for local display :
my $unclean = $self->agent->content;
my $html = '';
# ugly fix:
# strip all target='_blank' attributes from the HTML:
my $p = HTML::TokeParser::Simple->new(\$unclean);
while (my $token = $p->get_token) {
$token->delete_attr('target')
if $token->is_start_tag;
$html .= $token->as_is;
};
my $location = $self->agent->{uri};
my $browser = $self->browser;
$browser->display( html => $html, location => $location );
};
sub prompt_str {
my $self = shift;
if ($self->agent->response) {
return ($self->agent->uri || "") . ">"
} else {
return "(no url)>"
};
};
sub request_dumper { print $_[1]->as_string };
sub response_dumper {
if (ref $_[1] eq 'ARRAY') {
print $_[1]->[0]->as_string;
} else {
print $_[1]->as_string;
}
};
sub re_or_string {
my ($self,$arg) = @_;
if ($arg =~ m!^/(.*)/([imsx]*)$!) {
my ($re,$mode) = ($1,$2);
$re =~ s!([^\\])/!$1\\/!g;
$arg = eval "qr/$re/$mode";
};
$arg;
};
=head2 C<< $shell->link_text LINK >>
Returns a meaningful text from a WWW::Mechanize::Link object. This is (in order of
precedence) :
$link->text
$link->name
$link->url
=cut
sub link_text {
my ($self,$link) = @_;
my $result;
for (qw( text name url )) {
$result = $link->$_ and last;
};
$result;
};
=head2 C<$shell-Ehistory>
Returns the (relevant) shell history, that is, all commands
that were not solely for the information of the user. The
lines are returned as a list.
print join "\n", $shell->history;
=cut
sub history {
my ($self) = @_;
map { $_->[0] } @{$self->{history}}
};
=head2 C<$shell-Escript>
Returns the shell history as a Perl program. The
lines are returned as a list. The lines do not have
a one-by-one correspondence to the lines in the history.
print join "\n", $shell->script;
=cut
sub script {
my ($self,$prefix) = @_;
$prefix ||= "";
my @result = sprintf <<'HEADER', $^X;
#!%s -w
use strict;
use WWW::Mechanize;
use WWW::Mechanize::FormFiller;
use URI::URL;
my $agent = WWW::Mechanize->new( autocheck => 1 );
my $formfiller = WWW::Mechanize::FormFiller->new();
$agent->env_proxy();
HEADER
push @result, map { my $x = $_->[1]; $x =~ s/^/$prefix/mg; $x } @{$self->{history}};
@result;
};
=head2 C<$shell-Estatus>
C is called for status updates.
=cut
sub status {
my $self = shift;
print join "", @_;
};
=head2 C<$shell-Edisplay FILENAME LINES>
C is called to output listings, currently from the
C and C
HTML::Form will not know about this and will not have provided a
submit button for you (understandably). If you want to create such
a submit button from within your automation script, use the following
code :
$agent->current_form->push_input( submit => { name => "submit", value =>"submit" } );
This also works for other dynamically generated input fields.
To fake an input field from within a shell session, use the C command :
eval $self->agent->current_form->push_input(submit=>{name=>"submit",value=>"submit"});
And yes, the generated script should do the Right Thing for this eval as well.
=head1 LOCAL FILES
If you want to use the shell on a local file without setting up a C server
to serve the file, you can use the C URI scheme to load it into the "browser":
get file:local.html
forms
=head1 PROXY SUPPORT
Currently, the proxy support is realized via a call to
the C method of the WWW::Mechanize object, which
loads the proxies from the environment. There is no provision made
to prevent using proxies (yet). The generated scripts also
load their proxies from the environment.
=head1 ONLINE HELP
The online help feature is currently a bit broken in C,
but a fix is in the works. Until then, you can re-enable the
dynamic online help by patching C :
Remove the three lines
my $smry = exists $o->{handlers}{$h}{smry}
? $o->summary($h)
: "undocumented";
in C and replace them by
my $smry = $o->summary($h);
The shell works without this patch and the online help is still
available through C
=head1 BUGS
Bug reports are very welcome - please use the RT interface at
https://rt.cpan.org/NoAuth/Bugs.html?Dist=WWW-Mechanize-Shell or send a
descriptive mail to bug-WWW-Mechanize-Shell@rt.cpan.org . Please
try to include as much (relevant) information as possible - a test script
that replicates the undesired behaviour is welcome every time!
=over 4
=item *
The two parameter version of the C command guesses the realm from
the last received response. Currently a RE is used to extract the realm,
but this fails with some servers resp. in some cases. Use the four
parameter version of C, or if not possible, code the extraction
in Perl, either in the final script or through C commands.
=item *
The shell currently detects when you want to follow a JavaScript link and tells you
that this is not supported. It would be nicer if there was some callback mechanism
to (automatically?) extract URLs from JavaScript-infected links.
=back
=head1 TODO
=over 4
=item *
Add XPath expressions (by moving C from HTML::Parser to XML::XMLlib
or maybe easier, by tacking Class::XPath onto an HTML tree)
=item *
Add C as a command ?
=item *
Optionally silence the HTML::Parser / HTML::Forms warnings about invalid HTML.
=back
=head1 EXPORT
The routine C is exported into the importing namespace. This
is mainly for convenience so you can use the following commandline
invocation of the shell like with CPAN :
perl -MWWW::Mechanize::Shell -e"shell"
=head1 REPOSITORY
The public repository of this module is
L.
=head1 SUPPORT
The public support forum of this module is
L.
=head1 COPYRIGHT AND LICENSE
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Copyright (C) 2002-2017 Max Maischein
=head1 AUTHOR
Max Maischein, Ecorion@cpan.orgE
Please contact me if you find bugs or otherwise improve the module. More tests are also very welcome !
=head1 SEE ALSO
L,L,L
=cut
WWW-Mechanize-Shell-0.56/META.json 0000644 0001750 0001750 00000001544 13077733716 016105 0 ustar corion corion {
"abstract" : "An interactive shell for WWW::Mechanize",
"author" : [
"Max Maischein "
],
"dynamic_config" : 0,
"generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.150005",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : "2"
},
"name" : "WWW-Mechanize-Shell",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"release_status" : "stable",
"resources" : {
"repository" : {
"type" : "git",
"url" : "git://github.com/Corion/WWW-Mechanize-Shell.git",
"web" : "https://github.com/Corion/WWW-Mechanize-Shell"
}
},
"version" : "0.56",
"x_serialization_backend" : "JSON::PP version 2.27202",
"x_static_install" : 1
}
WWW-Mechanize-Shell-0.56/Changes 0000644 0001750 0001750 00000040554 13077733715 015762 0 ustar corion corion Revision history for Perl extension WWW::Mechanize::Shell.
Todo:
+ Think about HTML::FillInForm for displaying changed form values interactively
+ Check how the new WWW::Mechanize JavaScript handling interacts with the
shells own JS blocking (badly, I guess)
+ Use Scalar::Util::weaken if available
+ Think how to add other (Xpath) extractions to conveniently
display stuff via CSS selectors or XPath selectors. Steal
from Web::Scraper.
+ There is a memory leak between ::FormFiller and ::Shell
+ Ditch Hook::LexWrap now that LWP::UserAgent has progress callbacks
+ Add set-cookie and delete-cookie commands
+ Add (optional) HTTP::Cookies::Find support
0.56 20170425
+ Send uncompressed output to the browser
(contributed by weltonrodrigo)
+ Fix some warnings caused by links without a text
. Fix test suite due to newer version of Test::Without::Module
. Upgrade the test HTTP server to work in absence of CGI.pm
0.55 20150426
. Fix one more test against new sprintf() warnings in 5.21+
0.54 20150426
. Fix test suite against new sprintf() warnings in 5.21+
. Fix test suite against calling CGI::param in list context
Both analyzed and contributed by Slaven Rezic
0.53 20130810
. Add links to repository, contributed by D. Steinbrunner
0.52 20110106
. Fix stupid thinko in test (only affects tests on 5.13+)
0.51 20110105
. Make a test more robust against 5.14
. Streamlined Exporter.pm usage
. Rely on parent.pm instead of base.pm
. No need to upgrade
0.50 20100821
. Remove test file that was just testing LWP functionality and that
failed for some weird setups where nonexistent hosts still
result in a successful HTTP request.
. Added links to repositories
0.49 20100817
+ Apply [rt.cpan.org #59246] ,
thanks to Ansgar Burchardt
This fixes another case where API changes in LWP weren't mirrored
by this module.
+ Fix t/14-command-identity.t to not make an external request anymore
Addresses [rt.cpan.org #59883]
0.48 20081109
+ More test fixes for incompatibilities between LWP and Mechanize 1.34+
+ Removed way to set up authentication for more than one site
. WWW::Mechanize monkeypatches LWP::UserAgent and thus you can only ever
have one set of user/password in your script.
0.47 20081102
+ Fix tests to work with libwww 5.815+ which automatically retries
with empty user/password
+ WWW::Mechanize 1.34+ breaks Basic authentication with LWP 5.815+
so all auth tests are skipped until Andy Lester and Gisle Aas
work out who has to fix their stuff.
. Hook::LexWrap is subject to bug [perl #46217], this might
cause problems if you're running Perl 5.10.0. All tests pass.
0.46 20071003
+ Bump version because of borked CPAN upload, retrying
* No need to upgrade
0.45 20071003
* No library code changes, no need to upgrade
- Removed HTML::Display from the distribution
as that now lives its own life on CPAN
- Fix failing tests if HTTP_PROXY was set. This fixes
Debian bug #444634, http://bugs.debian.org/444634
and CPAN RT #29455, thanks to Niko Tyni
0.44 20070707
+ Added C and C commands that print out
the title and headers of the page. Suggested by Ed Halley.
+ Added and documented arguments to the C<< shell >> subroutine
+ Quieted up some test warnings
+ IO::Catch now understands C
+ Upgrade to Term::Shell v0.02 which now displays the help
summary better.
0.43 20070511
- fix failures on 5.6.2 with a B::Deparse version that doesn't
support ->ambient_pragmas() - they get ignored there now.
0.42 200704..
- Test fixes only, no need to upgrade
- Patches submitted by MAREKR (RT #26397) and somebody else whose
name I cannot find, sorry.
- Delete some more proxy settings for the test runs
0.41 20070414
- Codeacrobat release
- Restore compatibility with WWW::Mechanize 1.22
Thanks to Jörg Meltzer who sent in the patch
0.40 20070117
- Fixed showstopper bug in prompt method that was hidden
by all tests disabling interactive prompts
Thanks to all reporters
0.39
- Bumped module version
- Fix for RT 22121 - shell does not start
0.38 20061214
- Bumped module version
- Added a test for HTML::TableExtract functionality
which went untested so far
- Fixed HTML::TableExtract functionality
This functionality now requires
HTML::TableExtract 2.0 or higher, sorry
- This release now needs WWW::Mechanize 1.20, for the update_html
method which is used in the tests. Sorry.
- Reworked code generation and code execution
- ! Think about plugins for other extractions:
* Template::Extract
* XML::XPath extractions
- Think about using a different shell framework provider
0.37
- Fixed bug that created invalid code for the C command
0.36
- Fixed the actual bug too.
0.35
- Fixed documentation in HTML::Display::Debian about C.
0.34
- Fixed a bug where C