From e949bed143088a77ba89a56ff2a25609a1050159 Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Mon, 31 Aug 2015 13:32:13 -0700 Subject: [PATCH] change test utils to run from the source tree, #37340 --- FS-Test/Makefile.PL | 34 ---------------------------------- FS-Test/bin/freeside-test-fetch | 8 +++++++- FS-Test/bin/freeside-test-run | 14 ++++++++------ FS-Test/bin/freeside-test-start | 7 +++++-- FS-Test/bin/freeside-test-stop | 3 --- FS-Test/lib/FS/Test.pm | 11 ++++++++--- FS-Test/share/ui_tests | 4 ++-- 7 files changed, 30 insertions(+), 51 deletions(-) delete mode 100644 FS-Test/Makefile.PL mode change 100644 => 100755 FS-Test/bin/freeside-test-run 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 }, - 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/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 old mode 100644 new mode 100755 index add1e9b25..853bdc9a8 --- 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 4f12e325b..ed8e131a9 100755 --- a/FS-Test/bin/freeside-test-start +++ b/FS-Test/bin/freeside-test-start @@ -4,12 +4,15 @@ VERSION='5.0.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 newtime=$(sudo -u freeside \ diff --git a/FS-Test/bin/freeside-test-stop b/FS-Test/bin/freeside-test-stop index 7c67f54ec..6ec505a1f 100755 --- a/FS-Test/bin/freeside-test-stop +++ b/FS-Test/bin/freeside-test-stop @@ -24,9 +24,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 aedf502b5..bc9797779 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 -- 2.11.0