change test utils to run from the source tree, #37340
[freeside.git] / FS-Test / bin / freeside-test-fetch
1 #!/usr/bin/perl
2
3 use strict;
4 use Getopt::Std;
5 use File::Spec;
6
7 my @dirs = File::Spec->splitdir(File::Spec->rel2abs(__FILE__));
8 splice @dirs, -2; # bin/freeside-test-run
9 push @INC, File::Spec->catdir( @dirs, 'lib' );
10 eval "use FS::Test;";
11 die $@ if $@;
12
13 my %opt;
14
15 my $username = 'test';
16 my $password = 'test';
17
18 getopts('d:U:', \%opt);
19 die usage() unless $opt{d};
20 my $test = FS::Test->new( dir => $opt{d} );
21 $test->fsurl($opt{U}) if $opt{U};
22
23 my $testfile = $test->share_dir . '/ui_tests';
24 open my $fh, '<', $testfile
25   or die "Couldn't read tests from '$testfile': $!\n";
26 $test->fetch( <$fh> );
27
28 sub usage {
29   "Usage: $0 -d directory [ -U base_URI ]\n\n";
30 }
31
32 =head1 NAME
33
34 freeside-test-fetch - download a list of UI pages for testing
35
36 =head1 USAGE
37
38 freeside-test-fetch -d /tmp/outputdir [ -U http://myserver/freeside ]
39
40 =head1 ARGUMENTS
41
42 -d: the directory to put the files in. Required.
43
44 -U: the URL prefix for the Freeside server. Defaults to
45 "http://localhost/freeside".
46
47 The list of tests is in the 'ui_tests' file included with FS::Test.
48
49 =cut