Unit tests
Since Eprints 3.2 unit tests have been included in the codebase and can be run by developer and non developer alike.
The tests are not changed very often, but there are quite a few of them covering the existing codebase.
Contents
Required packages
Exact requirements for running the tests aren't documented but at this writing, the used packages are these (available from a distribution package or CPAN).
$ grep -h '^use.*::' * |cut -d ' ' -f 2 |sort -u "EPrints::Test" "EPrints::Test::XML" Data::Compare; Data::Dumper; Digest::MD5; EPrints::SystemSettings; EPrints::Test::RepositoryLog; EPrints::Test; LWP::UserAgent; Test::MockObject::Extends; Test::MockObject; Test::More Test::More; XML::LibXML::XPathContext; XML::LibXML;
On RHEL these can be installed by:
yum install eprints perl-Data-Compare perl-libwww-perl perl-Test-Simple perl-Test-MockObject perl-XML-LibXML
Optional packages
There are also optional dependencies (checked with egrep 'require .*::' *):
- Test::Memory::Cycle
- XML::DOM
- XML::GDOME
yum install perl-Test-Memory-Cycle perl-XML-DOM
XML::GDOME is not available on RHEL6 repositories
Storage::LocalCompress is not available on RHEL6 repositories, but if installing it PerlIO::gzip (perl-PerlIO-gzip) is required.
EPrint generating script
EPrints ships testdata//bin/import_rand_data to generate a number of records ( By default creates 1000 prints, 100 publications, 10 publishers and 10 institutions). They don't appear to be required by existing tests but you may find them useful to have during testing anyway and they will be used if available.
This requires [ https://metacpan.org/pod/Text::Lorem Text::Lorem] which is not packaged but can be trivially vendored in to an eprints install.
wget https://st.aticpan.org/source/ADEOLA/Text-Lorem-0.3/lib/Text/Lorem.pm -O perl_lib/Text/Lorem.pm
Once installed it can be run with
./testdata/bin/import_rand_data REPOID
Other configuration
- A user named "admin" is required for some tests to run, said user does not have to be an admin
Dummy data
For test instances test data can be installed. Without this data set many dozen tests will fail.
Pre supplied data (from testdata/* can be installed with ``import_test_data`` - REPOID is required.
./testdata/bin/import_test_data REPOID
Expected output
Not everything is an error - these items look like problems but aren't.
# Undefined phrase: xxx_invalid (en) at line 24 in /usr/share/eprints/tests/55_phrases.pl
Old test runs
These are runs people have done, they'll be removed as the page is built out. Most OK results have been removed to shrink the page
STDOUT
/usr/share/eprints/tests/30_search.pl ............ Dubious, test returned 255 (wstat 65280, 0xff00) Failed 33/36 subtests /usr/share/eprints/tests/40_views.pl ............. Dubious, test returned 1 (wstat 256, 0x100) Failed 1/6 subtests
patrick:
/usr/share/eprints3/tests/30_search.pl ............ Dubious, test returned 1 (wstat 256, 0x100) Failed 1/35 subtests (less 2 skipped subtests: 32 okay) /usr/share/eprints3/tests/31_simple_search.pl ..... ok Bailout called. Further testing stopped: Failed to parse http://eprints-git.demo/sword-app/servicedocument :1: parser error : Space required after the Public Identifier
STDERR
# EPrints Version: 3.3.14 `1d reference at /usr/share/eprints/tests/05_bug_fixes.pl line 36. # Looks like you planned 15 tests but ran 11. # Looks like you failed 7 tests of 11 run. # Looks like your test exited with 255 just after 11. Can't call method "to_xml" on an undefined value at /usr/share/eprints/bin/../perl_lib/EPrints/Test/XML.pm line 50. # Looks like you planned 12 tests but ran 9. # Looks like your test exited with 2 just after 9. Can't call method "to_xml" on an undefined value at /usr/share/eprints/bin/../perl_lib/EPrints/Test/XML.pm line 50. # Looks like you planned 12 tests but ran 9. # Looks like your test exited with 255 just after 9. # Failed test 'blank found matches' # at /usr/share/eprints/tests/30_search.pl line 21. # Failed test 'search range eprintid' # at /usr/share/eprints/tests/30_search.pl line 33. # Failed test 'title IN + creators_name GREP # AND( # AND( # grep($eprint.creators_name,"%[maury]%-%[w%") ... eprint__index_grep, # index($eprint.creators_name,"maury") ... eprint__rindex # ), # AND( # grep($eprint.creators_name,"%[parkes]%-%[f%") ... eprint__index_grep, # index($eprint.creators_name,"parkes") ... eprint__rindex # ), # index($eprint.title,"eagle") ... eprint__rindex # )' # at /usr/share/eprints/tests/30_search.pl line 43. # Failed test 'SET match' # at /usr/share/eprints/tests/30_search.pl line 58. # Failed test 'subjects and divisions: AND( # in_subject($eprint.divisions,"sch_mat") ... eprint_divisions, # in_subject($eprint.subjects,"GR") ... eprint_subjects # )' # at /usr/share/eprints/tests/30_search.pl line 71. # Failed test 'match testdata article full text' # at /usr/share/eprints/tests/30_search.pl line 82. Can't call method "get_parent" on an undefined value at /usr/share/eprints/tests/30_search.pl line 86. # Looks like you planned 36 tests but ran 9. # Looks like you failed 6 tests of 9 run. # Looks like your test exited with 255 just after 9. # memory footprint Warning! No values were found for eprint.view._40_views_pl [date] - configuration may be wrong # /tmp/jrjiuqUzTc/en/view/_40_views_pl # Failed test 'browse_view_menu' # at /usr/share/eprints/tests/40_views.pl line 67. # update_view_by_path=-1B # update_browse_view_list=-1B # Looks like you failed 1 test of 6. # LOAD=-1B # Plugin Memory Usage # EPrints::Plugin::Screen::EPrint::Messages=-1B # EPrints::Plugin::Convert::Thumbnails=-1B # EPrints::Plugin::Search=-1B # EPrints::Plugin::Storage::EPM=-1B # EPrints::Plugin::Screen::Workflow::Destroy=-1B # EPrints::Plugin::Screen::Workflow::Destroy=-1B Use of uninitialized value in subroutine entry at /usr/share/eprints/bin/../perl_lib/EPrints/MetaField/Id.pm line 50. Can't call method "get_dataset" on an undefined value at /usr/share/eprints/bin/../perl_lib/EPrints/Workflow.pm line 145. # Looks like you planned 4 tests but ran 3. # Looks like your test exited with 255 just after 3. Argument "" isn't numeric in addition (+) at /usr/share/eprints/bin/../perl_lib/EPrints/Database.pm line 1500.
Patrick:
# EPrints Version: 3.3.14 SELECT `document`.`docid` FROM `document`, `document_relation_type` AS `document_relation_type`, `document_relation_uri` AS `document_relation_uri` WHERE `document`.`docid`=`document_relation_type`.`docid` AND `document`.`docid`=`document_relation_uri`.`docid` AND (`document_relation_type`.`relation_type` = 'http://eprints.org/relation/islightboxThumbnailVersionOf') AND (`document_relation_type`.`pos` = `document_relation_uri`.`pos`) AND (`document_relation_uri`.`relation_uri` = '/id/document/1') GROUP BY `document`.`docid` # Failed test 'compound type field query' # at /usr/share/eprints3/tests/30_search.pl line 358. # Looks like you failed 1 test of 35. # Plugin Memory Usage # EPrints::Plugin::Screen::Admin::Config::Edit::Perl=-1B # EPrints::Plugin::Export::ContextObject=-1B # EPrints::Plugin::Screen::Admin::Config::Edit::XPage=-1B # EPrints::Plugin::Export::MultilineCSV=-1B # EPrints::Plugin::Screen::Admin::UpdateDatabase=-1B EPScript error: Can't use string ("0") as an ARRAY ref while "strict refs" in use at /home/pm5/eprints-git/bin/../perl_lib/EPrints/Script/Compiled.pm line 633. EPScript error: Can't use string ("0") as an ARRAY ref while "strict refs" in use at /home/pm5/eprints-git/bin/../perl_lib/EPrints/Script/Compiled.pm line 633.