Initial import (perl-Test-Mojibake-0.3-2)
Many modern text editors automatically save files using UTF-8 codification. However, the perl interpreter does not expect it by default. Whilst this does not represent a big deal on (most) backend-oriented programs, Web framework (Catalyst, Mojolicious) based applications will suffer so-called Mojibake (literally: "unintelligible sequence of characters"). Even worse: if an editor saves BOM (Byte Order Mark, U+FEFF character in Unicode) at the start of a script with the executable bit set (on Unix systems), it won't execute at all, due to shebang corruption. Avoiding codification problems is quite simple: * Always use utf8/use common::sense when saving source as UTF-8 * Always specify =encoding utf8 when saving POD as UTF-8 * Do neither of above when saving as ISO-8859-1 * Never save BOM (not that it's wrong; just avoid it as you'll barely notice its presence when in trouble) However, if you find yourself upgrading old code to use UTF-8 or trying to standardize a big project with many developers, each one using a different platform/editor, reviewing all files manually can be quite painful, especially in cases where some files have multiple encodings (note: it all started when I realized that gedit and derivatives are unable to open files with character conversion tables). Enter the Test::Mojibake ;)
This commit is contained in:
parent
93af7ff1af
commit
43d4f14ea4
|
@ -0,0 +1 @@
|
|||
/Test-Mojibake-[0-9.]*.tar.gz
|
|
@ -0,0 +1,51 @@
|
|||
--- Test-Mojibake-0.3/t/06-pp-vs-xs.t
|
||||
+++ Test-Mojibake-0.3/t/06-pp-vs-xs.t
|
||||
@@ -1,7 +1,7 @@
|
||||
#!perl -T
|
||||
use strict;
|
||||
|
||||
-use Test::More;
|
||||
+use Test::More 'no_plan';
|
||||
|
||||
BEGIN {
|
||||
use_ok('Benchmark', 'countit');
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
unless ($Test::Mojibake::use_xs) {
|
||||
diag('No XS module detected, will fallback to PP implementation!');
|
||||
- done_testing(2);
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -33,8 +32,6 @@
|
||||
|
||||
diag(sprintf('XS/PP speed ratio is %0.2f', $t0->iters / $t1->iters));
|
||||
|
||||
-done_testing(7);
|
||||
-
|
||||
sub run {
|
||||
my $i = 0;
|
||||
for (@buf) {
|
||||
--- Test-Mojibake-0.3/t/release-cpan-changes.t
|
||||
+++ Test-Mojibake-0.3/t/release-cpan-changes.t
|
||||
@@ -1,15 +1,11 @@
|
||||
#!perl
|
||||
|
||||
+use Test::More;
|
||||
+
|
||||
BEGIN {
|
||||
- unless ($ENV{RELEASE_TESTING}) {
|
||||
- require Test::More;
|
||||
- Test::More::plan(skip_all => 'these tests are for release candidate testing');
|
||||
- }
|
||||
+ plan skip_all => 'these tests are for release candidate testing' unless ($ENV{RELEASE_TESTING});
|
||||
+ eval 'use Test::CPAN::Changes';
|
||||
+ plan skip_all => 'Test::CPAN::Changes required for this test' if $@;
|
||||
}
|
||||
|
||||
-
|
||||
-use Test::More;
|
||||
-eval 'use Test::CPAN::Changes';
|
||||
-plan skip_all => 'Test::CPAN::Changes required for this test' if $@;
|
||||
changes_ok();
|
||||
-done_testing();
|
|
@ -0,0 +1,30 @@
|
|||
--- Test-Mojibake/Makefile.PL
|
||||
+++ Test-Mojibake/Makefile.PL
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
|
||||
|
||||
-use ExtUtils::MakeMaker 6.30;
|
||||
+use ExtUtils::MakeMaker;
|
||||
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
'AUTHOR' => 'Stanislaw Pusep <stas@sysd.org>',
|
||||
'BUILD_REQUIRES' => {},
|
||||
'CONFIGURE_REQUIRES' => {
|
||||
- 'ExtUtils::MakeMaker' => '6.30'
|
||||
+ 'ExtUtils::MakeMaker' => '0'
|
||||
},
|
||||
'DISTNAME' => 'Test-Mojibake',
|
||||
'EXE_FILES' => [],
|
||||
@@ -46,6 +46,9 @@
|
||||
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
|
||||
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
|
||||
|
||||
+delete $WriteMakefileArgs{LICENSE}
|
||||
+ unless eval { ExtUtils::MakeMaker->VERSION(6.31) };
|
||||
+
|
||||
WriteMakefile(%WriteMakefileArgs);
|
||||
|
||||
|
|
@ -0,0 +1,148 @@
|
|||
# We don't really need ExtUtils::MakeMaker ≥ 6.30
|
||||
%global old_eumm %(perl -MExtUtils::MakeMaker -e 'printf "%d\\n", $ExtUtils::MakeMaker::VERSION < 6.30 ? 1 : 0;' 2>/dev/null || echo 0)
|
||||
|
||||
# We need to patch the test suite if we have an old version of Test::More
|
||||
%global old_test_more %(perl -MTest::More -e 'printf "%d\\n", $Test::More::VERSION < 0.88 ? 1 : 0;' 2>/dev/null || echo 0)
|
||||
|
||||
# noarch, but to avoid debug* files interfering with manifest test:
|
||||
%global debug_package %{nil}
|
||||
|
||||
# TODO:
|
||||
#
|
||||
# BuildRequires: perl(Test::Pod::LinkCheck) when available
|
||||
#
|
||||
# Unicode::CheckUTF8 is an optional requirement that significantly speeds up
|
||||
# this module but its license is currently unclear (CPAN RT#70210)
|
||||
|
||||
Name: perl-Test-Mojibake
|
||||
Version: 0.3
|
||||
Release: 2%{?dist}
|
||||
Summary: Check your source for encoding misbehavior
|
||||
Group: Development/Libraries
|
||||
License: GPL+ or Artistic
|
||||
URL: http://search.cpan.org/dist/Test-Mojibake/
|
||||
Source0: http://search.cpan.org/CPAN/authors/id/S/SY/SYP/Test-Mojibake-%{version}.tar.gz
|
||||
Patch0: Test-Mojibake-0.3-old-eu::mm.patch
|
||||
Patch1: Test-Mojibake-0.3-old-Test::More.patch
|
||||
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(id -nu)
|
||||
BuildArch: noarch
|
||||
# ===================================================================
|
||||
# Module build requirements
|
||||
# ===================================================================
|
||||
BuildRequires: perl(ExtUtils::MakeMaker)
|
||||
# ===================================================================
|
||||
# Module requirements
|
||||
# ===================================================================
|
||||
BuildRequires: perl(File::Spec)
|
||||
BuildRequires: perl(Test::Builder)
|
||||
# ===================================================================
|
||||
# Regular test suite requirements
|
||||
# ===================================================================
|
||||
BuildRequires: perl(Test::Builder::Tester)
|
||||
BuildRequires: perl(Test::More)
|
||||
# ===================================================================
|
||||
# Author/Release test requirements
|
||||
#
|
||||
# Don't run these tests or include their requirements if we're
|
||||
# bootstrapping, as many of these modules require each other for
|
||||
# their author/release tests.
|
||||
# ===================================================================
|
||||
%if 0%{!?perl_bootstrap:1}
|
||||
BuildRequires: perl(Pod::Coverage::TrustPod)
|
||||
BuildRequires: perl(Test::CPAN::Meta)
|
||||
BuildRequires: perl(Test::DistManifest)
|
||||
BuildRequires: perl(Test::HasVersion)
|
||||
BuildRequires: perl(Test::NoTabs)
|
||||
BuildRequires: perl(Test::Pod::Coverage)
|
||||
BuildRequires: perl(Test::Pod)
|
||||
BuildRequires: perl(Test::Portability::Files)
|
||||
# Modules only available from EL-5
|
||||
%if 0%{?fedora} || 0%{?rhel} > 4
|
||||
BuildRequires: perl(Test::Perl::Critic)
|
||||
BuildRequires: perl(Test::Synopsis)
|
||||
%endif
|
||||
# Modules only available from EL-6
|
||||
%if 0%{?fedora} || 0%{?rhel} > 5
|
||||
BuildRequires: perl(Test::Kwalitee)
|
||||
BuildRequires: perl(Test::MinimumVersion)
|
||||
BuildRequires: perl(Test::Vars)
|
||||
%endif
|
||||
# Modules only available from EL-7
|
||||
%if 0%{?fedora} || 0%{?rhel} > 6
|
||||
BuildRequires: perl(Test::CPAN::Changes)
|
||||
%endif
|
||||
%endif
|
||||
# ===================================================================
|
||||
# Runtime requirements
|
||||
# ===================================================================
|
||||
Requires: perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
|
||||
|
||||
%description
|
||||
Many modern text editors automatically save files using UTF-8 codification.
|
||||
However, the perl interpreter does not expect it by default. Whilst this does
|
||||
not represent a big deal on (most) backend-oriented programs, Web framework
|
||||
(Catalyst, Mojolicious) based applications will suffer so-called Mojibake
|
||||
(literally: "unintelligible sequence of characters"). Even worse: if an editor
|
||||
saves BOM (Byte Order Mark, U+FEFF character in Unicode) at the start of a
|
||||
script with the executable bit set (on Unix systems), it won't execute at all,
|
||||
due to shebang corruption.
|
||||
|
||||
Avoiding codification problems is quite simple:
|
||||
|
||||
* Always use utf8/use common::sense when saving source as UTF-8
|
||||
* Always specify =encoding utf8 when saving POD as UTF-8
|
||||
* Do neither of above when saving as ISO-8859-1
|
||||
* Never save BOM (not that it's wrong; just avoid it as you'll barely
|
||||
notice its presence when in trouble)
|
||||
|
||||
However, if you find yourself upgrading old code to use UTF-8 or trying to
|
||||
standardize a big project with many developers, each one using a different
|
||||
platform/editor, reviewing all files manually can be quite painful, especially
|
||||
in cases where some files have multiple encodings (note: it all started when I
|
||||
realized that gedit and derivatives are unable to open files with character
|
||||
conversion tables).
|
||||
|
||||
Enter the Test::Mojibake ;)
|
||||
|
||||
%prep
|
||||
%setup -q -n Test-Mojibake-%{version}
|
||||
|
||||
# We don't really need ExtUtils::MakeMaker ≥ 6.30
|
||||
%if %{old_eumm}
|
||||
%patch0 -p1
|
||||
%endif
|
||||
|
||||
# We need to patch the test suite if we have an old version of Test::More
|
||||
%if %{old_test_more}
|
||||
%patch1 -p1
|
||||
%endif
|
||||
|
||||
%build
|
||||
perl Makefile.PL INSTALLDIRS=vendor
|
||||
make %{?_smp_mflags}
|
||||
|
||||
%install
|
||||
rm -rf %{buildroot}
|
||||
make pure_install PERL_INSTALL_ROOT=%{buildroot}
|
||||
find %{buildroot} -type f -name .packlist -exec rm -f {} \;
|
||||
find %{buildroot} -depth -type d -exec rmdir {} \; 2>/dev/null
|
||||
%{_fixperms} %{buildroot}
|
||||
|
||||
%check
|
||||
make test %{!?perl_bootstrap:AUTHOR_TESTING=1 RELEASE_TESTING=1}
|
||||
|
||||
%clean
|
||||
rm -rf %{buildroot}
|
||||
|
||||
%files
|
||||
%defattr(-,root,root,-)
|
||||
%doc Changes LICENSE README
|
||||
%{perl_vendorlib}/Test/
|
||||
%{_mandir}/man3/Test::Mojibake.3pm*
|
||||
|
||||
%changelog
|
||||
* Thu Aug 11 2011 Paul Howarth <paul@city-fan.org> - 0.3-2
|
||||
- Sanitize for Fedora/EPEL submission
|
||||
|
||||
* Thu Aug 11 2011 Paul Howarth <paul@city-fan.org> - 0.3-1
|
||||
- Initial RPM version
|
Loading…
Reference in New Issue