8 use File::Slurp qw(write_file);
11 getopts('d:h:u:p:', \%opt);
12 die usage() unless ($opt{d} and $opt{u} and $opt{p});
13 my $host = $opt{h} || 'http://localhost/freeside';
15 my $mech = WWW::Mechanize->new;
16 $mech->credentials($opt{u}, $opt{p}); # 3.x auth only
20 mkdir($opt{d}) unless -d $opt{d};
23 while (my $path = shift @tests) {
24 if ($path =~ /^#(.*)/) {
25 print "$1 - skipped\n";
28 my $uri = URI->new("$host/$path");
30 my $response = $mech->get($uri);
31 print " - " . $response->code . "\n";
32 if ($response->is_success) {
34 my @dirs = $uri->path_segments;
36 foreach my $dir (@dirs) {
37 mkdir $dir unless -d $dir;
40 write_file($file, {binmode => ':utf8'}, $response->decoded_content);
45 "Usage: fetch_pages -d directory -u username -p password [ -h hostname ]\n\n";
50 fetch_pages - a testing tool for UI changes
54 fetch_pages -d before_change -u myuser -p mypass list_of_tests
55 git checkout newbranch
56 make install; apache2ctl restart
57 fetch_pages -d after_change -u myuser -p mypass list_of_tests
58 diff -ur before_change/ after_change/ |diffstat
62 -d: the directory to put the files in. Required.
64 -u: the username to use with the Freeside web interface. Required.
66 -p: the password. Required.
68 -h: the URL prefix for the Freeside server. Defaults to
69 "http://localhost/freeside".
71 The list of tests can be in a file specified after all arguments, or passed