Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 75f3df8

Browse files
committedJan 15, 2021
Use File::Slurp, instead of our own home-grown version.
Requires adjustments to several of the tests, to normalize "end-of-line at end-of-file", but we'll just `chomp()` those away.
1 parent 4a31c74 commit 75f3df8

17 files changed

+21
-39
lines changed
 

‎Build.PL

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ $build_pkg->new(
5757
'recommends' => {
5858
'JavaScript::Minifier::XS' => 0,
5959
},
60+
'test_requires' => {
61+
'File::Slurp' => 0,
62+
},
6063
# add configuration requirements both to build_requires and to META.yml,
6164
# until M::B supports "configure_requires" directly.
6265
'build_requires' => { %configure_requires },

‎MANIFEST

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ t/htdocs/test.js
2323
t/htdocs/test.txt
2424
t/htdocs/minified.txt
2525
t/htdocs/minified-xs.txt
26-
t/MY/slurp.pm
2726
t/MY/CharsetHandler.pm
2827
t/MY/JSHandler.pm
2928
t/MY/NoCTypeHandler.pm

‎t/MY/CharsetHandler.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Apache2::RequestRec qw();
77
use Apache2::RequestUtil qw();
88
use Apache2::Const -compile => qw(OK);
99
use File::Spec::Functions qw(catfile);
10-
use MY::slurp;
10+
use File::Slurp qw(slurp);
1111

1212
sub handler {
1313
my $r = shift;

‎t/MY/JSHandler.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Apache2::RequestRec qw();
77
use Apache2::RequestUtil qw();
88
use Apache2::Const -compile => qw(OK);
99
use File::Spec::Functions qw(catfile);
10-
use MY::slurp;
10+
use File::Slurp qw(slurp);
1111

1212
sub handler {
1313
my $r = shift;

‎t/MY/NoCTypeHandler.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Apache2::RequestRec qw();
77
use Apache2::RequestUtil qw();
88
use Apache2::Const -compile => qw(OK);
99
use File::Spec::Functions qw(catfile);
10-
use MY::slurp;
10+
use File::Slurp qw(slurp);
1111

1212
sub handler {
1313
my $r = shift;

‎t/MY/PlainHandler.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use Apache2::RequestRec qw();
77
use Apache2::RequestUtil qw();
88
use Apache2::Const -compile => qw(OK);
99
use File::Spec::Functions qw(catfile);
10-
use MY::slurp;
10+
use File::Slurp qw(slurp);
1111

1212
sub handler {
1313
my $r = shift;

‎t/MY/slurp.pm

Lines changed: 0 additions & 16 deletions
This file was deleted.

‎t/content-type.t

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Apache::Test;
44
use Apache::TestRequest;
55
use Apache::TestUtil qw(t_cmp);
66
use lib 't';
7-
use MY::slurp;
7+
use File::Slurp qw(slurp);
88

99
# Test "Content-Type" headers
1010
plan tests => 2, need_lwp;
@@ -13,7 +13,6 @@ plan tests => 2, need_lwp;
1313
charset_minified: {
1414
my $body = GET_BODY '/content-type/charset';
1515
my $min = slurp( 't/htdocs/minified.txt' );
16-
chomp($min);
1716

1817
ok( t_cmp($body, $min) );
1918
}

‎t/decline.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Apache::Test;
44
use Apache::TestRequest;
55
use Apache::TestUtil qw(t_cmp);
66
use lib 't';
7-
use MY::slurp;
7+
use File::Slurp qw(slurp);
88

99
# Test non-JS responses still have other filters applied
1010
plan tests => 1, need_lwp;

‎t/dynamic.t

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Apache::Test;
44
use Apache::TestRequest;
55
use Apache::TestUtil qw(t_cmp);
66
use lib 't';
7-
use MY::slurp;
7+
use File::Slurp qw(slurp);
88

99
# Test dynamically generated content
1010
plan tests => 2, need_lwp;
@@ -20,6 +20,5 @@ dynamic_unaltered: {
2020
dynamic_minified: {
2121
my $body = GET_BODY '/dynamic/js';
2222
my $min = slurp( 't/htdocs/minified.txt' );
23-
chomp($min);
2423
ok( t_cmp($body, $min) );
2524
}

‎t/mime-types.t

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Apache::Test;
44
use Apache::TestRequest;
55
use Apache::TestUtil qw(t_cmp);
66
use lib 't';
7-
use MY::slurp;
7+
use File::Slurp qw(slurp);
88

99
# Test non-JS responses when we've supplemented MIME-Types list
1010
plan tests => 2, need_lwp;
@@ -13,7 +13,6 @@ plan tests => 2, need_lwp;
1313
single_mimetype: {
1414
my $body = GET_BODY '/mimetypes/single';
1515
my $min = slurp('t/htdocs/minified.txt');
16-
chomp($min);
1716

1817
ok( t_cmp($body, $min) );
1918
}
@@ -22,7 +21,6 @@ single_mimetype: {
2221
multiple_mimetypes: {
2322
my $body = GET_BODY '/mimetypes/multiple';
2423
my $min = slurp('t/htdocs/minified.txt');
25-
chomp($min);
2624

2725
ok( t_cmp($body, $min) );
2826
}

‎t/minifiers.t

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Apache::Test;
44
use Apache::TestRequest;
55
use Apache::TestUtil qw(t_cmp);
66
use lib 't';
7-
use MY::slurp;
7+
use File::Slurp qw(slurp);
88

99
# Test minification with an explicitly specified minifier.
1010
plan tests => 2, need_lwp;
@@ -14,6 +14,7 @@ js_minifier: {
1414
my $body = GET_BODY '/explicit/pp';
1515
my $min = slurp('t/htdocs/minified.txt');
1616
chomp($min);
17+
chomp($body);
1718

1819
ok( t_cmp($body, $min) );
1920
}
@@ -28,6 +29,7 @@ js_minifier_xs: {
2829
my $body = GET_BODY '/explicit/xs';
2930
my $min = slurp('t/htdocs/minified-xs.txt');
3031
chomp($min);
32+
chomp($body);
3133

3234
ok( t_cmp($body, $min) );
3335
}

‎t/mod-cgi.t

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use Apache::TestRequest;
55
use Apache::TestUtil qw(t_cmp t_write_perl_script);
66
use File::Spec::Functions qw(catfile);
77
use lib 't';
8-
use MY::slurp;
8+
use File::Slurp qw(slurp);
99

1010
# Test filtered mod_cgi output
1111
plan tests => 4, (need_lwp && need_cgi);
@@ -21,7 +21,7 @@ cgi_unaltered: {
2121
t_write_perl_script(
2222
catfile($svrroot, qw(cgi-bin plain.cgi)),
2323
qq{ use lib "$svrroot";
24-
use MY::slurp;
24+
use File::Slurp qw(slurp);
2525
print "Content-Type: text/plain\\n\\n";
2626
print slurp("$docroot/test.js");
2727
} );
@@ -41,7 +41,7 @@ cgi_minified: {
4141
t_write_perl_script(
4242
catfile($svrroot, qw(cgi-bin js.cgi)),
4343
qq{ use lib "$svrroot";
44-
use MY::slurp;
44+
use File::Slurp qw(slurp);
4545
print "Content-Type: text/javascript\\n\\n";
4646
print slurp("$docroot/test.js");
4747
} );
@@ -50,7 +50,6 @@ cgi_minified: {
5050
my $res = GET '/cgi-bin/js.cgi';
5151
my $body = $res->content;
5252
my $min = slurp('t/htdocs/minified.txt');
53-
chomp($min);
5453

5554
ok( $res->content_type eq 'text/javascript' );
5655
ok( t_cmp($body, $min) );

‎t/non-js.t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Apache::Test;
44
use Apache::TestRequest;
55
use Apache::TestUtil qw(t_cmp);
66
use lib 't';
7-
use MY::slurp;
7+
use File::Slurp qw(slurp);
88

99
# Make sure that non-JS files get passed through unaltered
1010
plan tests => 1, need_lwp;

‎t/perl-bin/js.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use MY::slurp;
1+
use File::Slurp qw(slurp);
22
use File::Spec::Functions qw(catfile);
33
my $r = shift;
44
$r->content_type('text/javascript');

‎t/perl-bin/plain.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use MY::slurp;
1+
use File::Slurp qw(slurp);
22
use File::Spec::Functions qw(catfile);
33
my $r = shift;
44
$r->content_type('text/plain');

‎t/registry.t

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use Apache::Test;
44
use Apache::TestRequest;
55
use Apache::TestUtil qw(t_cmp);
66
use lib 't';
7-
use MY::slurp;
7+
use File::Slurp qw(slurp);
88

99
# Test filtered ModPerl::Registry output
1010
plan tests => 4, need_lwp;
@@ -24,7 +24,6 @@ registry_minified: {
2424
my $res = GET '/perl-bin/js.pl';
2525
my $body = $res->content;
2626
my $min = slurp('t/htdocs/minified.txt');
27-
chomp($min);
2827

2928
ok( $res->content_type eq 'text/javascript' );
3029
ok( t_cmp($body, $min) );

0 commit comments

Comments
 (0)
Please sign in to comment.