change test utils to run from the source tree, #37340
authorMark Wells <mark@freeside.biz>
Mon, 31 Aug 2015 20:32:13 +0000 (13:32 -0700)
committerMark Wells <mark@freeside.biz>
Mon, 31 Aug 2015 23:31:25 +0000 (16:31 -0700)
FS-Test/Makefile.PL [deleted file]
FS-Test/README
FS-Test/bin/freeside-test-fetch
FS-Test/bin/freeside-test-run [changed mode: 0644->0755]
FS-Test/bin/freeside-test-start
FS-Test/bin/freeside-test-stop
FS-Test/lib/FS/Test.pm
FS-Test/share/ui_tests

diff --git a/FS-Test/Makefile.PL b/FS-Test/Makefile.PL
deleted file mode 100644 (file)
index cea088a..0000000
+++ /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);
-
index b1518bd..8e9681c 100644 (file)
@@ -2,42 +2,36 @@ FS-Test
 
 INSTALLATION
 
 
 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
 
 
 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"
 
 - 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
 
 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
 
 
 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.
 
 (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.
index ccc8528..9530057 100755 (executable)
@@ -1,8 +1,14 @@
 #!/usr/bin/perl
 
 use strict;
 #!/usr/bin/perl
 
 use strict;
-use FS::Test;
 use Getopt::Std;
 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;
 
 
 my %opt;
 
old mode 100644 (file)
new mode 100755 (executable)
index add1e9b..853bdc9
@@ -2,18 +2,20 @@
 
 set -ae
 
 
 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."
 
 echo "Starting test mode."
-freeside-test-start
+$testroot/bin/freeside-test-start
 echo "Saving results to $tempdir."
 echo "Saving results to $tempdir."
-freeside-test-fetch -d $tempdir
+$testroot/bin/freeside-test-fetch -d $tempdir
 echo "Exiting test mode."
 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."
 
 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
 
 diffstat -C $diffname
 
index cfa1adb..3ab8221 100755 (executable)
@@ -4,12 +4,15 @@ VERSION='3.8.1'
 
 set -ae
 
 
 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`
 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)
 
 # 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
 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
 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."
 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' \
 
 newtime=$(sudo -u freeside \
   psql -tc 'SELECT to_timestamp(max(_date) + 86400) FROM cust_bill' \
index 08485f7..5e221a8 100755 (executable)
@@ -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"
 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."
 fi
 
 echo "Done."
index 8b15233..be58ce5 100644 (file)
@@ -4,14 +4,15 @@ use 5.006;
 use strict;
 use warnings FATAL => 'all';
 
 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 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
 
 
 =head1 NAME
 
@@ -29,7 +30,11 @@ database image, the test plan, and probably other stuff.
 =cut
 
 sub share_dir {
 =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
 }
 
 =item new OPTIONS
index 8292ae5..2370a1d 100644 (file)
@@ -1,7 +1,7 @@
 # reports menu items
 search/cust_main.cgi?browse=last
 # 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
 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