summaryrefslogtreecommitdiff
path: root/FS-Test
diff options
context:
space:
mode:
authorMark Wells <mark@freeside.biz>2015-08-31 13:32:13 -0700
committerMark Wells <mark@freeside.biz>2015-08-31 16:31:25 -0700
commitfd62e5c7a94361229febd28bf84cdd0e65a7028a (patch)
tree7eecb450b861c4dedc9f55ee95d8c7541367d2f9 /FS-Test
parent8cf56e1f1031f0a3bb1cebde402d14e98f204588 (diff)
change test utils to run from the source tree, #37340
Diffstat (limited to 'FS-Test')
-rw-r--r--FS-Test/Makefile.PL34
-rw-r--r--FS-Test/README38
-rwxr-xr-xFS-Test/bin/freeside-test-fetch8
-rwxr-xr-x[-rw-r--r--]FS-Test/bin/freeside-test-run14
-rwxr-xr-xFS-Test/bin/freeside-test-start9
-rwxr-xr-xFS-Test/bin/freeside-test-stop3
-rw-r--r--FS-Test/lib/FS/Test.pm11
-rw-r--r--FS-Test/share/ui_tests4
8 files changed, 47 insertions, 74 deletions
diff --git a/FS-Test/Makefile.PL b/FS-Test/Makefile.PL
deleted file mode 100644
index cea088a4c..000000000
--- a/FS-Test/Makefile.PL
+++ /dev/null
@@ -1,34 +0,0 @@
-use 5.006;
-use strict;
-use warnings FATAL => 'all';
-use ExtUtils::MakeMaker;
-use File::ShareDir::Install;
-
-install_share dist => 'share';
-
-WriteMakefile(
- NAME => 'FS::Test',
- AUTHOR => q{Mark Wells <mark@freeside.biz>},
- VERSION_FROM => 'lib/FS/Test.pm',
- ABSTRACT => 'Freeside test suite',
- LICENSE => 'agpl_3',
- PL_FILES => {},
- EXE_FILES => [ glob 'bin/*' ],
- MIN_PERL_VERSION => 5.006,
- CONFIGURE_REQUIRES => {
- 'ExtUtils::MakeMaker' => 0,
- 'File::ShareDir::Install' => 0,
- },
- BUILD_REQUIRES => {
- 'Test::More' => 0,
- },
- PREREQ_PM => {
- 'WWW::Mechanize' => 0,
- },
- dist => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
- clean => { FILES => 'FS-Test-*' },
-);
-
-package MY;
-use File::ShareDir::Install qw(postamble);
-
diff --git a/FS-Test/README b/FS-Test/README
index b1518bd6f..8e9681cef 100644
--- a/FS-Test/README
+++ b/FS-Test/README
@@ -2,42 +2,36 @@ FS-Test
INSTALLATION
-To install this module, install Freeside as usual. Then run the following
-commands:
-
- perl Makefile.PL
- make
- make install
-
-INITIALIZATION
-
-Run "freeside-test-start" from an account that can sudo to root. This will
-create a database with the test image and set the system clock to one day
-after the last bill. If there's an existing Freeside database, it will be
-renamed to "freeside_YYYYMMDD" (the current date).
-
-To restore the system clock and put the existing database back in place,
-run "freeside-test-stop".
+This module no longer needs to be installed. Run it directly from the source
+tree.
RUNNING TESTS
-"freeside-test-run" is the main test script. Currently there's only one
-test plan, "ui_tests". freeside-test-run will:
+"freeside-test-run" is the main test script. Currently there's only one test
+plan, "ui_tests". freeside-test-run will:
- download all the URLs listed in the test plan into a directory in /tmp
- compare them to the reference versions with "diff -ur"
- write the output to "freeside_test.YYYYMMDD.diff"
-- display the results of "diffstat" on that diff
The raw output directory will not be deleted, so you can examine the results
-yourself. This is recommended for files that don't diff nicely like Excel
-versions of reports and PDF invoices.
+yourself.
+
+If you want to do anything with the database besides compare the test results
+to reference, run "freeside-test-start" by hand first. This will create a
+database with the test image and start Apache with a fake time of one day after
+the last bill. If there's an existing Freeside database, it will be renamed to
+"freeside_YYYYMMDD" (the current date).
+
+To put the existing database back in place, run "freeside-test-stop", then
+restart Apache and any Freeside services.
UPDATING THE REFERENCE PAGES
The simplest way to update the reference copies of the test pages is
-freeside-test-fetch -d ./share/output
+bin/freeside-test-start
+bin/freeside-test-fetch -d ./share/output
(from the FS-Test source directory). If you're installing from a git repo,
this will overwrite the working tree with the newly downloaded test pages.
diff --git a/FS-Test/bin/freeside-test-fetch b/FS-Test/bin/freeside-test-fetch
index ccc8528ff..953005704 100755
--- a/FS-Test/bin/freeside-test-fetch
+++ b/FS-Test/bin/freeside-test-fetch
@@ -1,8 +1,14 @@
#!/usr/bin/perl
use strict;
-use FS::Test;
use Getopt::Std;
+use File::Spec;
+
+my @dirs = File::Spec->splitdir(File::Spec->rel2abs(__FILE__));
+splice @dirs, -2; # bin/freeside-test-run
+push @INC, File::Spec->catdir( @dirs, 'lib' );
+eval "use FS::Test;";
+die $@ if $@;
my %opt;
diff --git a/FS-Test/bin/freeside-test-run b/FS-Test/bin/freeside-test-run
index add1e9b25..853bdc9a8 100644..100755
--- a/FS-Test/bin/freeside-test-run
+++ b/FS-Test/bin/freeside-test-run
@@ -2,18 +2,20 @@
set -ae
-tempdir=$( mktemp -d freeside-test.XXXX )
-sharedir=$(perl -MFS::Test -e "print FS::Test::share_dir()")
+tempdir=$( mktemp -d --tmpdir freeside-test.XXXX )
+# get the parent directory of bin/(this script)
+testroot=$( dirname ${BASH_SOURCE[0]} )
+testroot=$( cd $testroot; cd ..; pwd )
echo "Starting test mode."
-freeside-test-start
+$testroot/bin/freeside-test-start
echo "Saving results to $tempdir."
-freeside-test-fetch -d $tempdir
+$testroot/bin/freeside-test-fetch -d $tempdir
echo "Exiting test mode."
-freeside-test-stop || true
+$testroot/bin/freeside-test-stop || true
diffname=freeside-test.`date +%Y%m%d`.diff
echo "Writing diff to $diffname."
-diff -urb "$sharedir/output" "$tempdir" > $diffname
+diff -urb "$testroot/share/output" "$tempdir" > $diffname
diffstat -C $diffname
diff --git a/FS-Test/bin/freeside-test-start b/FS-Test/bin/freeside-test-start
index cfa1adbc5..3ab8221b9 100755
--- a/FS-Test/bin/freeside-test-start
+++ b/FS-Test/bin/freeside-test-start
@@ -4,12 +4,15 @@ VERSION='3.8.1'
set -ae
+# get the parent directory of bin/(this script)
+testroot=$( dirname ${BASH_SOURCE[0]} )
+testroot=$( cd $testroot; cd ..; pwd )
+
echo "Stopping services."
sudo service freeside stop
sudo service apache2 stop
newname=freeside_`date +%Y%m%d`
-sharedir=$(perl -MFS::Test -e "print FS::Test::share_dir()")
# get company_name from existing DB, strip whitespace
# (if there is no existing DB, continue anyway)
@@ -34,7 +37,7 @@ fi
if [ $createdb = YES ]; then
echo "Creating new database from stock schema."
createdb --owner=freeside freeside
- sudo -u freeside psql freeside -q -f $sharedir/test.sql > /dev/null
+ sudo -u freeside psql freeside -q -f $testroot/share/test.sql > /dev/null
fi
if [ -f /usr/local/etc/freeside/htpasswd ]; then
@@ -44,7 +47,7 @@ if [ -f /usr/local/etc/freeside/htpasswd ]; then
fi
echo "Installing new htpasswd."
-sudo cp $sharedir/htpasswd /usr/local/etc/freeside/htpasswd
+sudo cp $testroot/share/htpasswd /usr/local/etc/freeside/htpasswd
newtime=$(sudo -u freeside \
psql -tc 'SELECT to_timestamp(max(_date) + 86400) FROM cust_bill' \
diff --git a/FS-Test/bin/freeside-test-stop b/FS-Test/bin/freeside-test-stop
index 08485f796..5e221a85b 100755
--- a/FS-Test/bin/freeside-test-stop
+++ b/FS-Test/bin/freeside-test-stop
@@ -38,9 +38,6 @@ oldname=$( psql -tl | \
if [ -n "$oldname" ]; then
echo "Renaming $oldname to freeside."
psql postgres -c "ALTER DATABASE $oldname RENAME TO freeside"
- echo "Restarting services."
- sudo service apache2 restart
- sudo service freeside restart
fi
echo "Done."
diff --git a/FS-Test/lib/FS/Test.pm b/FS-Test/lib/FS/Test.pm
index 8b1523388..be58ce573 100644
--- a/FS-Test/lib/FS/Test.pm
+++ b/FS-Test/lib/FS/Test.pm
@@ -4,14 +4,15 @@ use 5.006;
use strict;
use warnings FATAL => 'all';
-use File::ShareDir 'dist_dir';
+#use File::ShareDir 'dist_dir';
use WWW::Mechanize;
use File::chdir;
use URI;
use File::Slurp qw(write_file);
use Class::Accessor 'antlers';
+use File::Spec;
-our $VERSION = '0.01';
+our $VERSION = '0.02';
=head1 NAME
@@ -29,7 +30,11 @@ database image, the test plan, and probably other stuff.
=cut
sub share_dir {
- dist_dir('FS-Test')
+# dist_dir('FS-Test')
+# we no longer install this anywhere
+ my @dirs = File::Spec->splitdir(File::Spec->rel2abs(__FILE__));
+ splice @dirs, -3; # lib/FS/Test.pm
+ File::Spec->catdir( @dirs, 'share' );
}
=item new OPTIONS
diff --git a/FS-Test/share/ui_tests b/FS-Test/share/ui_tests
index 8292ae521..2370a1d9b 100644
--- a/FS-Test/share/ui_tests
+++ b/FS-Test/share/ui_tests
@@ -1,7 +1,7 @@
# reports menu items
search/cust_main.cgi?browse=last
-search/cust_bill.html?OPEN90_date
-search/cust_bill.html?date
+search/cust_bill.html?keywords=OPEN90_date:order_by=invnum
+search/cust_bill.html?keywords=date:order_by=invnum
search/cust_bill.html?magic=_date&agentnum=1&beginning=&ending=10%2F01%2F2015&charged_lt=&charged_gt=200.00&owed_lt=&owed_gt=&open=1
search/cust_bill_pkg.cgi?agentnum=1&status=&cust_classnum=&beginning=01%2F01%2F2016&ending=01%2F31%2F2016
search/cust_pay.html?magic=_date&unapplied=0&beginning=01%2F01%2F2016&agentnum=1&order_by=paynum