Bugzilla – Attachment 44559 Details for
Bug 15150
t/ tests should pass if Test::DBIx::Class is not available
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 15150: Make t/ tests skip if Test::DBIx::Class absent
Bug-15150-Make-t-tests-skip-if-TestDBIxClass-absen.patch (text/plain), 11.60 KB, created by
Tomás Cohen Arazi (tcohen)
on 2015-11-06 13:36:26 UTC
(
hide
)
Description:
Bug 15150: Make t/ tests skip if Test::DBIx::Class absent
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2015-11-06 13:36:26 UTC
Size:
11.60 KB
patch
obsolete
>From eec4c40292beda4cd9cd82cc0d7069b3c79ace3b Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 6 Nov 2015 10:29:21 -0300 >Subject: [PATCH] Bug 15150: Make t/ tests skip if Test::DBIx::Class absent > >Tests in t/ should always pass for building the Debian packages >for Koha. But we've started using Test::DBIx::Class for writing >mocked tests, and that lib is not (yet) packaged fro Debian 7+. > >This means build is failing. Devs and jenkins use the lib from CPAN. > >This patch makes the tests skip if the lib is absent. > >To test: >- Install Test::DBIx::Class > $ sudo cpanm Test::DBIx::Class >- Run the tests: > $ prove t/ >=> SUCCESS: Tests pass >- Uninstall Test::DBIx::Class > $ sudo cpan -U Test::DBIx::Class >- Run the tests: > $ prove t/ >=> SUCCESS: Tests still pass (those needing the lib are skipped) >- Sign off :-D >--- > t/Biblio.t | 12 ++++++++++-- > t/Calendar.t | 40 ++++++++++++++++++++++++++++++++-------- > t/Images.t | 30 ++++++++++++++++++++++++++++-- > t/ItemType.t | 30 +++++++++++++++++++++++++++++- > t/Koha.t | 12 +++++++++++- > t/Letters.t | 13 +++++++++++-- > t/Matcher.t | 33 ++++++++++++++++++++++++++++----- > t/Members_AttributeTypes.t | 28 +++++++++++++++++++++++++--- > t/SocialData.t | 30 ++++++++++++++++++++++++++++-- > 9 files changed, 202 insertions(+), 26 deletions(-) > >diff --git a/t/Biblio.t b/t/Biblio.t >index 8cf9c9d..0e709af 100755 >--- a/t/Biblio.t >+++ b/t/Biblio.t >@@ -17,14 +17,22 @@ > > use Modern::Perl; > >-use Test::More tests => 46; >+use Test::More; > use Test::MockModule; > use Test::Warn; > >+use Module::Load::Conditional qw/check_install/; >+ > BEGIN { >- use_ok('C4::Biblio'); >+ if ( check_install( module => 'Test::DBIx::Class' ) ) { >+ plan tests => 46; >+ } else { >+ plan skip_all => "Need Test::DBIx::Class" >+ } > } > >+use_ok('C4::Biblio'); >+ > use Test::DBIx::Class { > schema_class => 'Koha::Schema', > connect_info => ['dbi:SQLite:dbname=:memory:','',''], >diff --git a/t/Calendar.t b/t/Calendar.t >index 7fabe3a..37f11f4 100755 >--- a/t/Calendar.t >+++ b/t/Calendar.t >@@ -1,20 +1,42 @@ >-#!/usr/bin/env perl >+#!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+ >+use Test::More; >+use Test::MockModule; >+ > use DateTime; > use DateTime::Duration; >-use Test::More tests => 35; >-use Test::MockModule; > use Koha::Cache; > use Koha::DateUtils; > >-BEGIN { >- use_ok('Koha::Calendar'); >+use Module::Load::Conditional qw/check_install/; > >- # This was the only test C4 had >- # Remove when no longer used >- #use_ok('C4::Calendar'); # not used anymore? >+BEGIN { >+ if ( check_install( module => 'Test::DBIx::Class' ) ) { >+ plan tests => 35; >+ } else { >+ plan skip_all => "Need Test::DBIx::Class" >+ } > } >+ >+use_ok('Koha::Calendar'); >+ > use Test::DBIx::Class { > schema_class => 'Koha::Schema', > connect_info => ['dbi:SQLite:dbname=:memory:','',''], >@@ -298,3 +320,5 @@ my $day_after_christmas = DateTime->new( > '==', 40, 'Test parameter order not relevant (Days)' ); > > } >+ >+1; >diff --git a/t/Images.t b/t/Images.t >index 274766b..0ee5ce6 100644 >--- a/t/Images.t >+++ b/t/Images.t >@@ -1,11 +1,35 @@ > #!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. > # >-#Testing C4 Images >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 8; >+ >+use Test::More; > use Test::MockModule; > >+use Module::Load::Conditional qw/check_install/; >+ >+BEGIN { >+ if ( check_install( module => 'Test::DBIx::Class' ) ) { >+ plan tests => 8; >+ } else { >+ plan skip_all => "Need Test::DBIx::Class" >+ } >+} >+ > use_ok('C4::Images'); > > use Test::DBIx::Class { >@@ -49,3 +73,5 @@ is( $imagenumbers[0], 1, 'imagenumber is 1' ); > is( $imagenumbers[1], 3, 'imagenumber is 3' ); > > is( $imagenumbers[4], undef, 'imagenumber undef' ); >+ >+1; >diff --git a/t/ItemType.t b/t/ItemType.t >index b10efdd..2f05c74 100755 >--- a/t/ItemType.t >+++ b/t/ItemType.t >@@ -1,9 +1,35 @@ > #!/usr/bin/perl > >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ > use Modern::Perl; >-use Test::More tests => 25; >+ >+use Test::More; > use t::lib::Mocks; > >+use Module::Load::Conditional qw/check_install/; >+ >+BEGIN { >+ if ( check_install( module => 'Test::DBIx::Class' ) ) { >+ plan tests => 25; >+ } else { >+ plan skip_all => "Need Test::DBIx::Class" >+ } >+} >+ > use_ok('C4::ItemType'); > > use Test::DBIx::Class { >@@ -90,3 +116,5 @@ is( $itemtype->checkinmsg, 'foo', 'checkinmsg is foo' ); > > $itemtype = C4::ItemType->get; > is( $itemtype, undef, 'C4::ItemType->get should return unless if no parameter is given' ); >+ >+1; >diff --git a/t/Koha.t b/t/Koha.t >index e4d46f2..3593368 100755 >--- a/t/Koha.t >+++ b/t/Koha.t >@@ -18,9 +18,19 @@ > use Modern::Perl; > > use C4::Context; >-use Test::More tests => 30; >+use Test::More; > use Test::MockModule; > >+use Module::Load::Conditional qw/check_install/; >+ >+BEGIN { >+ if ( check_install( module => 'Test::DBIx::Class' ) ) { >+ plan tests => 30; >+ } else { >+ plan skip_all => "Need Test::DBIx::Class" >+ } >+} >+ > use_ok('C4::Koha'); > > use Test::DBIx::Class { >diff --git a/t/Letters.t b/t/Letters.t >index ad70026..a072044 100755 >--- a/t/Letters.t >+++ b/t/Letters.t >@@ -17,9 +17,18 @@ > > use Modern::Perl; > >-use DBI; > use Test::MockModule; >-use Test::More tests => 6; >+use Test::More; >+ >+use Module::Load::Conditional qw/check_install/; >+ >+BEGIN { >+ if ( check_install( module => 'Test::DBIx::Class' ) ) { >+ plan tests => 6; >+ } else { >+ plan skip_all => "Need Test::DBIx::Class" >+ } >+} > > use Test::DBIx::Class { > schema_class => 'Koha::Schema', >diff --git a/t/Matcher.t b/t/Matcher.t >index 2a4246c..652f061 100755 >--- a/t/Matcher.t >+++ b/t/Matcher.t >@@ -1,16 +1,37 @@ > #!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. > # >-#testing C4 matcher >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; > >-use strict; >-use warnings; >-use Test::More tests => 11; >+use Test::More; > use Test::MockModule; > >+use Module::Load::Conditional qw/check_install/; >+ > BEGIN { >- use_ok('C4::Matcher'); >+ if ( check_install( module => 'Test::DBIx::Class' ) ) { >+ plan tests => 11; >+ } else { >+ plan skip_all => "Need Test::DBIx::Class" >+ } > } > >+use_ok('C4::Matcher'); >+ > use Test::DBIx::Class { > schema_class => 'Koha::Schema', > connect_info => ['dbi:SQLite:dbname=:memory:','',''], >@@ -60,3 +81,5 @@ is( $testmatcher->code(), 'match on ISBN', 'testing code accessor' ); > $testmatcher->description('match on ISSN'); > > is( $testmatcher->description(), 'match on ISSN', 'testing code accessor' ); >+ >+1; >diff --git a/t/Members_AttributeTypes.t b/t/Members_AttributeTypes.t >index 055e767..6bb58ae 100755 >--- a/t/Members_AttributeTypes.t >+++ b/t/Members_AttributeTypes.t >@@ -1,15 +1,37 @@ > #!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. > # >-# Tests 'fetch', 'fake db data', and 'checks for existant attributes' >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >+ > use Test::MockModule; >-use Test::More tests => 10; >+use Test::More; >+ >+use Module::Load::Conditional qw/check_install/; > > BEGIN { >- use_ok('C4::Members::AttributeTypes'); >+ if ( check_install( module => 'Test::DBIx::Class' ) ) { >+ plan tests => 10; >+ } else { >+ plan skip_all => "Need Test::DBIx::Class" >+ } > } > >+use_ok('C4::Members::AttributeTypes'); >+ > use Test::DBIx::Class { > schema_class => 'Koha::Schema', > connect_info => ['dbi:SQLite:dbname=:memory:','',''], >diff --git a/t/SocialData.t b/t/SocialData.t >index 3d6cd1a..8b6a93b 100644 >--- a/t/SocialData.t >+++ b/t/SocialData.t >@@ -1,11 +1,35 @@ > #!/usr/bin/perl >+ >+# This file is part of Koha. >+# >+# Koha is free software; you can redistribute it and/or modify it >+# under the terms of the GNU General Public License as published by >+# the Free Software Foundation; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha is distributed in the hope that it will be useful, but >+# WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. > # >-#Testing C4 SocialData >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. > > use Modern::Perl; >-use Test::More tests => 6; >+ >+use Test::More; > use Test::MockModule; > >+use Module::Load::Conditional qw/check_install/; >+ >+BEGIN { >+ if ( check_install( module => 'Test::DBIx::Class' ) ) { >+ plan tests => 6; >+ } else { >+ plan skip_all => "Need Test::DBIx::Class" >+ } >+} >+ > BEGIN { > use_ok('C4::SocialData'); > } >@@ -51,3 +75,5 @@ is( $report->{'without'}->[0]->{'original'}, > > is( $report->{'without'}->[0]->{'isbn'}, '9780596526740', > 'testing get_report' ); >+ >+1; >-- >2.6.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 15150
:
44559
|
44575
|
44578