File: 0001-Make-the-test-suite-support-Debian-as-installed-test.patch

package info (click to toggle)
libbusiness-isbn-data-perl 20251024.001-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 500 kB
  • sloc: xml: 8,976; perl: 553; makefile: 8
file content (100 lines) | stat: -rw-r--r-- 3,597 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
From: Florian Schlichting <fsfs@debian.org>
Subject: [PATCH] Make the test suite support Debian as-installed testing
 ("autopkgtest")

When running as-installed tests, the module gets loaded from the system
paths. As-installed testing is detected by the existence of the AUTOPKGTEST_TMP
environment variable.

As we no longer ship a RangeMessage.xml in the package, disable the
included_range_message test. However env_range_message works well with
our smoke-files. Skip renaming files in blib, which are not present in
the testbed.

Extended similarly to new tests on 2024-03-09.

Bug-Debian: https://bugs.debian.org/765167
Forwarded: not-needed
Last-Update: 2024-03-09
---
 t/check_data_structure.t | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

--- a/t/check_data_structure.t
+++ b/t/check_data_structure.t
@@ -10,6 +10,7 @@
 	};
 
 subtest 'included_range_message' => sub {
+	plan skip_all => "Debian doesn't include a RangeMessage.xml that could be tested here" if $ENV{AUTOPKGTEST_TMP};
 	# Test with included RangeMessage.xml in the same spot as the module
 	like( $Business::ISBN::country_data{_source}, qr/RangeMessage\.xml/ );
 	like( $Business::ISBN::country_data{_source}, qr/blib/ );
@@ -55,14 +56,14 @@
 	my $file = catfile( qw(blib lib Business ISBN RangeMessage.xml) );
 	my $out_of_the_way = $file . '.hidden';
 
-	rename $file => $out_of_the_way;
+	rename $file => $out_of_the_way unless $ENV{AUTOPKGTEST_TMP};
 
 	ok( ! -e $file, 'RangeMessage.xml is out of the way' );
 	local %Business::ISBN::country_data = Business::ISBN::Data::_get_data();
 
 	like( $Business::ISBN::country_data{_source}, qr/\bData\.pm/, 'Data source is the default data structure' );
 
-	rename $out_of_the_way => $file;
+	rename $out_of_the_way => $file unless $ENV{AUTOPKGTEST_TMP};
 	};
 
 subtest 'default_data' => sub {
--- a/t/default_data.t
+++ b/t/default_data.t
@@ -29,7 +29,7 @@
 	my $file = catfile( qw(blib lib Business ISBN RangeMessage.xml) );
 	my $out_of_the_way = $file . '.hidden';
 
-	ok( rename($file => $out_of_the_way), 'Renamed file' );
+	ok( rename($file => $out_of_the_way), 'Renamed file' ) unless $ENV{AUTOPKGTEST_TMP};
 
 	subtest 'compile' => sub {
 		my @modules = qw( Business::ISBN::Data );
@@ -48,7 +48,7 @@
 			}
 		};
 
-	rename $out_of_the_way => $file;
+	rename $out_of_the_way => $file unless $ENV{AUTOPKGTEST_TMP};
 	}
 
 done_testing();
--- a/t/business-isbn.t
+++ b/t/business-isbn.t
@@ -13,7 +13,10 @@
 
 subtest 'source' => sub {
 	ok exists $Business::ISBN::country_data{'_source'}, 'country_data has _source';
+	SKIP: {
+	skip "No RangeMessage.xml in installed package", 1 if $ENV{AUTOPKGTEST_TMP};
 	like $Business::ISBN::country_data{'_source'}, qr/RangeMessage\.xml/, 'source is RangeMessage';
+	}
 	is Business::ISBN::isbn_data_source(), $Business::ISBN::country_data{'_source'}, 'isbn_data_source returns _source';
 
 	delete local $Business::ISBN::country_data{'_source'};
--- a/t/get_data.t
+++ b/t/get_data.t
@@ -17,11 +17,15 @@
 	local $ENV{ISBN_RANGE_MESSAGE} = $file;
 
 	my %data = Business::ISBN::Data->_get_data();
+	SKIP: {
+	skip "No RangeMessage.xml in installed package", 1 if $ENV{AUTOPKGTEST_TMP};
+	}
 	ok exists $data{'_source'}, '_source exists in hash';
 	is $data{'_source'}, $file, '_source is the file';
 	};
 
 subtest 'ISBN_RANGE_MESSAGE does not exist' => sub {
+	plan skip_all => "Debian doesn't include a RangeMessage.xml that could be tested here" if $ENV{AUTOPKGTEST_TMP};
 	my $file = 'lib/Business/ISBN/RangeMessage.yaml';
 	ok ! -e $file, "$file does not exist";
 	local $ENV{ISBN_RANGE_MESSAGE} = $file;