Skip to content

Commit

Permalink
Don't blindly convert line endings
Browse files Browse the repository at this point in the history
Beause it could be reading binary files! Instead just convert the line
endings in the tests.
  • Loading branch information
theory committed Feb 17, 2024
1 parent 4b1bd15 commit 811fd8e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 10 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ jobs:
build:
strategy:
matrix:
os: [[🐧, ubuntu], [🍎, macos], [🪟, windows]]
perl: [ '5.38', '5.36', '5.34', '5.32', '5.30', '5.28', '5.26', '5.24', '5.22', '5.20', '5.18', '5.16', '5.14', '5.12', '5.10' ]
# os: [[🐧, ubuntu], [🍎, macos], [🪟, windows]]
# perl: [ '5.38', '5.36', '5.34', '5.32', '5.30', '5.28', '5.26', '5.24', '5.22', '5.20', '5.18', '5.16', '5.14', '5.12', '5.10' ]
os: [[🪟, windows]]
perl: [ '5.32' ]
name: 🧅 Perl ${{ matrix.perl }} on ${{ matrix.os[0] }} ${{ matrix.os[1] }}
runs-on: ${{ matrix.os[1] }}-latest
steps:
Expand All @@ -17,5 +19,6 @@ jobs:
with: { perl-version: "${{ matrix.perl }}" }
- name: Install Dependencies
run: cpanm -vn Module::Build && cpanm -vn --installdeps --with-recommends --with-develop .
- name: Run Tests
run: perl Build.PL ./Build && ./Build test
- run: prove -lv t/base.t t/dist.t
# - name: Run Tests
# run: perl Build.PL ./Build && ./Build test
2 changes: 1 addition & 1 deletion Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Revision history for Perl extension WWW-PGXN.

0.13.0 2024-02-17T19:54:17Z
- Added CI tests for Perls 5.10 - 5.38 on Linux, macOS, and Windows.
- Fixed issues that caused test failures on Windows.
- Fixed failures caused by line endings on Windows.
- Updated relevant URLs from http to https.

0.12.4 2013-11-06T05:56:15Z
Expand Down
2 changes: 1 addition & 1 deletion lib/WWW/PGXN.pm
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ sub get {
headers => {},
} unless -e $file;

open my $fh, '<:raw:crlf', $file or return {
open my $fh, '<:raw', $file or return {
success => 0,
status => 500,
reason => $!,
Expand Down
8 changes: 4 additions & 4 deletions t/base.t
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ is_deeply $res, {
}, 'Should have "not found" response';

my $f = catfile qw(t mirror index.json);
open my $fh, '<:raw:crlf', $f or die "Cannot open $f: $!\n";
open my $fh, '<:raw', $f or die "Cannot open $f: $!\n";
my $json = do {
local $/;
<$fh>;
Expand Down Expand Up @@ -146,11 +146,11 @@ is $pgxn->html_doc_path_for('pair', '0.1.2', 'doc/foo'),
##############################################################################
# Test spec fetching.
ok my $spec = $pgxn->spec, 'Get spec';
like $spec, qr{PGXN Meta Spec - The PGXN distribution metadatå specification$}m,
like $spec, qr{PGXN Meta Spec - The PGXN distribution metadatå specification\r?$}m,
'It should look like the text file';
ok $spec = $pgxn->spec('txt'), 'Get text spec';
like $spec, qr{PGXN Meta Spec - The PGXN distribution metadatå specification$}m,
like $spec, qr{PGXN Meta Spec - The PGXN distribution metadatå specification\r?$}m,
'It should look like the text file';
ok $spec = $pgxn->spec('html'), 'Get HTML spec';
like $spec, qr{<p>PGXN Meta Spec - The PGXN distribution metadatå specification</p>$}m,
like $spec, qr{<p>PGXN Meta Spec - The PGXN distribution metadatå specification</p>\r?$}m,
'It should look like the HTML file';
3 changes: 3 additions & 0 deletions t/dist.t
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ is_deeply $dist->docs, {

ok my $doc = $dist->body_for_html_doc('README'),
'Fetch the README body';
my $windows = $^O =~ /^MSWin/;
$doc =~ s/\r\n/\n/g if $windows;

# Contents should be the decoded HTML.
is $doc, do {
Expand All @@ -149,6 +151,7 @@ is $doc, do {
# Do the same for the doc.
ok $doc = $dist->body_for_html_doc('doc/pair'),
'Fetch the doc/pair body';
$doc =~ s/\r\n/\n/g if $windows;
is $doc, do {
my $fn = catfile qw(t mirror dist pair 0.1.1 doc pair.html);
open my $fh, '<:encoding(utf-8)', $fn or die "Cannot open $fn: $!\n";
Expand Down

0 comments on commit 811fd8e

Please sign in to comment.