summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-07-01 16:52:16 -0700
committerMark Wells <mark@freeside.biz>2015-07-01 16:52:16 -0700
commitd1cdae31052a590b270145b34e57aa0156e73ea2 (patch)
treeaf432724044db9883c2359e968fb20b6ec87d0ab /bin
parent2bcf13f0f9da22f9afa134320943ea2bfc9c7dcb (diff)
another useful debugging tool
Diffstat (limited to 'bin')
-rwxr-xr-xbin/fetch_pages80
1 files changed, 80 insertions, 0 deletions
diff --git a/bin/fetch_pages b/bin/fetch_pages
new file mode 100755
index 000000000..5aeca56b3
--- /dev/null
+++ b/bin/fetch_pages
@@ -0,0 +1,80 @@
+#!/usr/bin/perl
+
+use strict;
+use WWW::Mechanize;
+use Getopt::Std;
+use File::chdir;
+use URI;
+use File::Slurp qw(write_file);
+
+my %opt;
+getopts('d:h:u:p:', \%opt);
+die usage() unless ($opt{d} and $opt{u} and $opt{p});
+my $host = $opt{h} || 'http://localhost/freeside';
+
+my $mech = WWW::Mechanize->new( autocheck => 0 );
+$mech->get("$host/index.html");
+$mech->submit_form(
+ with_fields => {
+ credential_0 => $opt{u},
+ credential_1 => $opt{p}
+ }
+);
+
+my @tests = <>;
+
+mkdir($opt{d}) unless -d $opt{d};
+push @CWD, $opt{d};
+
+while (my $path = shift @tests) {
+ if ($path =~ /^#(.*)/) {
+ print "$1 - skipped\n";
+ next;
+ }
+ my $uri = URI->new("$host/$path");
+ print $uri->path;
+ my $response = $mech->get($uri);
+ print " - " . $response->code . "\n";
+ if ($response->is_success) {
+ local $CWD;
+ my @dirs = $uri->path_segments;
+ my $file = pop @dirs;
+ foreach my $dir (@dirs) {
+ mkdir $dir unless -d $dir;
+ push @CWD, $dir;
+ }
+ write_file($file, {binmode => ':utf8'}, $response->decoded_content);
+ }
+}
+
+sub usage {
+ "Usage: fetch_pages -d directory -u username -p password [ -h hostname ]\n\n";
+}
+
+=head1 NAME
+
+fetch_pages - a testing tool for UI changes
+
+=head1 USAGE
+
+fetch_pages -d before_change -u myuser -p mypass list_of_tests
+git checkout newbranch
+make install; apache2ctl restart
+fetch_pages -d after_change -u myuser -p mypass list_of_tests
+diff -ur before_change/ after_change/ |diffstat
+
+=head1 ARGUMENTS
+
+-d: the directory to put the files in. Required.
+
+-u: the username to use with the Freeside web interface. Required.
+
+-p: the password. Required.
+
+-h: the URL prefix for the Freeside server. Defaults to
+"http://localhost/freeside".
+
+The list of tests can be in a file specified after all arguments, or passed
+to stdin.
+
+=cut