From: Peter Rabbitson Date: Sat, 12 Jan 2013 17:35:36 +0000 (+0100) Subject: Reign in (a little bit) the sprawling CRLF insanity on Win32 X-Git-Tag: v0.08205~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=dbsrgits%2FDBIx-Class.git;a=commitdiff_plain;h=ffce4b65b2c49bbb04919766c376625d426542f7 Reign in (a little bit) the sprawling CRLF insanity on Win32 In the process join the notabs/eol tests into one file, and tighten the WS checks even more --- diff --git a/Makefile.PL b/Makefile.PL index 1975940..fd0c7f0 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -152,6 +152,16 @@ if ($Module::Install::AUTHOR and ! $ENV{MAKELEVEL}) { NAME => Meta->name || die 'The Module::Install metadata must be available at this point but is not - did you rearrange the Makefile.PL...?', }); + # Crutch for DISTBUILDING_IN_HELL + # Spits back a working dos2unix snippet to be used on the supplied path(s) + # Ironically EUMM's dos2unix is broken on win32 itself - it does + # not take into account the CRLF layer present on win32 + my $crlf_fixup = sub { + return '' unless ($^O eq 'MSWin32' or $^O eq 'cygwin'); + my $targets = join ', ', map { "q($_)" } @_; + "\t" . $mm_proto->oneliner( qq(\$ENV{PERLIO}='unix' and system( \$^X, qw( -MExtUtils::Command -e dos2unix -- ), $targets ) ) ); + }; + # we are in the process of (re)writing the makefile - some things we # call below very well may fail local $ENV{DBICTEST_NO_MAKEFILE_VERIFICATION} = 1; diff --git a/examples/Schema/db/example.sql b/examples/Schema/db/example.sql index 13d9b39..4bc6cb6 100644 --- a/examples/Schema/db/example.sql +++ b/examples/Schema/db/example.sql @@ -1,6 +1,6 @@ CREATE TABLE artist ( artistid INTEGER PRIMARY KEY, - name TEXT NOT NULL + name TEXT NOT NULL ); CREATE TABLE cd ( @@ -13,4 +13,4 @@ CREATE TABLE track ( trackid INTEGER PRIMARY KEY, cd INTEGER NOT NULL REFERENCES cd(cdid), title TEXT NOT NULL -); \ No newline at end of file +); diff --git a/lib/DBIx/Class/Optional/Dependencies.pm b/lib/DBIx/Class/Optional/Dependencies.pm index a6cbb49..a21e99b 100644 --- a/lib/DBIx/Class/Optional/Dependencies.pm +++ b/lib/DBIx/Class/Optional/Dependencies.pm @@ -182,15 +182,10 @@ my $reqs = { }, }, - test_notabs => { - req => { - 'Test::NoTabs' => '0.9', - }, - }, - - test_eol => { + test_whitespace => { req => { 'Test::EOL' => '1.0', + 'Test::NoTabs' => '0.9', }, }, diff --git a/maint/Makefile.PL.inc/11_authortests.pl b/maint/Makefile.PL.inc/11_authortests.pl index c9ff881..e29b542 100644 --- a/maint/Makefile.PL.inc/11_authortests.pl +++ b/maint/Makefile.PL.inc/11_authortests.pl @@ -16,6 +16,9 @@ Meta->tests(join (' ', map { $_ || () } Meta->tests, @xt_tests ) ); # inject an explicit xt test run, mainly to check the contents of # lib and the generated POD's *before* anything is copied around +# +# at the end rerun the whitespace test in the distdir, to make sure everything +# is pristine postamble <<"EOP"; dbic_clonedir_copy_generated_pod : test_xt @@ -31,8 +34,7 @@ test_xt : pm_to_blib # perl cmd join( ' ', '$(ABSPERLRUN)', - # $'s need to be escaped (doubled) before inserting into the Makefile - map { $mm_proto->quote_literal($_) } qw(-e $$ENV{RELEASE_TESTING}=1;) + map { $mm_proto->quote_literal($_) } qw(-e $ENV{RELEASE_TESTING}=1;) ), # test list join( ' ', @@ -41,6 +43,23 @@ test_xt : pm_to_blib ) ]} +create_distdir : dbic_distdir_retest_whitespace + +dbic_distdir_retest_whitespace : +\t@{[ + $mm_proto->cd ( + '$(DISTVNAME)', + $mm_proto->test_via_harness( + # perl cmd + join( ' ', + '$(ABSPERLRUN)', + map { $mm_proto->quote_literal($_) } qw(-Ilib -e $ENV{RELEASE_TESTING}=1;$ENV{DBICTEST_NO_MAKEFILE_VERIFICATION}=1;) + ), + 'xt/whitespace.t' + ) + ) +]} + EOP # keep the Makefile.PL eval happy diff --git a/maint/Makefile.PL.inc/53_autogen_pod.pl b/maint/Makefile.PL.inc/53_autogen_pod.pl index e3592e5..2496a47 100644 --- a/maint/Makefile.PL.inc/53_autogen_pod.pl +++ b/maint/Makefile.PL.inc/53_autogen_pod.pl @@ -85,12 +85,7 @@ EOP # on some OSes generated files may have an incorrect \n - fix it # so that the xt tests pass on a fresh checkout (also shipping a # dist with CRLFs is beyond obnoxious) -# -# Ironically EUMM's dos2unix is broken on win32 itself - it does -# not take into account the CRLF layer present on win32 -# do the ENV trick again if ($^O eq 'MSWin32' or $^O eq 'cygwin') { - { local $ENV{PERLIO} = 'unix'; system( $^X, qw( -MExtUtils::Command -e dos2unix -- ), $pod_dir ); @@ -98,17 +93,14 @@ if ($^O eq 'MSWin32' or $^O eq 'cygwin') { postamble <<"EOP"; -test_xt : dbic_fixup_generated_pod +clonedir_post_generate_files : pod_crlf_fixup -dbic_fixup_generated_pod : -\t@{[ $mm_proto->oneliner( qq(\$\$ENV{PERLIO}='unix' and system( \$\$^X, qw( -MExtUtils::Command -e dos2unix -- ), q($pod_dir) ) ) ) ]} +pod_crlf_fixup : +@{[ $crlf_fixup->($pod_dir) ]} EOP } - -# copy the contents of $pod_dir over to the workdir -# (yes, overwriting is fine, though nothing should reside there) { postamble <<"EOP"; @@ -119,6 +111,7 @@ dbic_clonedir_copy_generated_pod : \t@{[ $mm_proto->oneliner("install([ from_to => {q($pod_dir) => File::Spec->curdir(), write => q($pod_dir.packlist)}, verbose => 0, uninstall_shadows => 0, skip => [] ])", ['-MExtUtils::Install']) ]} + EOP } diff --git a/maint/Makefile.PL.inc/56_autogen_testddl.pl b/maint/Makefile.PL.inc/56_autogen_testddl.pl index d86cae5..c383708 100644 --- a/maint/Makefile.PL.inc/56_autogen_testddl.pl +++ b/maint/Makefile.PL.inc/56_autogen_testddl.pl @@ -18,8 +18,10 @@ clonedir_generate_files : dbic_clonedir_regen_test_ddl dbic_clonedir_regen_test_ddl : \t\$(ABSPERLRUN) -Ilib -- maint/gen_schema > @{[ $mm_proto->quote_literal($ddl_fn) ]} - +@{[ $crlf_fixup->($ddl_fn) ]} EOP + + # keep the Makefile.PL eval happy 1; diff --git a/maint/Makefile.PL.inc/61_inject_dbicadmin_pod.pl b/maint/Makefile.PL.inc/61_inject_dbicadmin_pod.pl index 46cd783..218527f 100644 --- a/maint/Makefile.PL.inc/61_inject_dbicadmin_pod.pl +++ b/maint/Makefile.PL.inc/61_inject_dbicadmin_pod.pl @@ -5,13 +5,6 @@ # make sure we delete and re-create the file - just an append # will not do what one expects, because on unixy systems the # target is symlinked to the original - -# FIXME also on win32 EU::Command::cat() adds crlf even if the -# source files do not contain any :( -my $crlf_fixup = ($^O eq 'MSWin32' or $^O eq 'cygwin') - ? "\t@{[ $mm_proto->oneliner( qq(\$\$ENV{PERLIO}='unix' and system( \$\$^X, qw( -MExtUtils::Command -e dos2unix -- ), q(\$(DISTVNAME)/script/dbicadmin) ) ) ) ]}" - : '' -; postamble <<"EOP"; create_distdir : dbic_distdir_dbicadmin_pod_inject @@ -19,7 +12,10 @@ create_distdir : dbic_distdir_dbicadmin_pod_inject dbic_distdir_dbicadmin_pod_inject : \t\$(RM_F) \$(DISTVNAME)/script/dbicadmin \t@{[ $mm_proto->oneliner('cat', ['-MExtUtils::Command']) ]} script/dbicadmin maint/.Generated_Pod/dbicadmin.pod > \$(DISTVNAME)/script/dbicadmin -$crlf_fixup + +# FIXME also on win32 EU::Command::cat() adds crlf even if the +# source files do not contain any :( +@{[ $crlf_fixup->('$(DISTVNAME)/script/dbicadmin') ]} EOP # keep the Makefile.PL eval happy diff --git a/xt/notabs.t b/xt/notabs.t deleted file mode 100644 index d11bd4a..0000000 --- a/xt/notabs.t +++ /dev/null @@ -1,52 +0,0 @@ -use warnings; -use strict; - -use Test::More; -use File::Glob 'bsd_glob'; -use lib 't/lib'; -use DBICTest; - -require DBIx::Class; -unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_notabs') ) { - my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_notabs'); - $ENV{RELEASE_TESTING} - ? die ("Failed to load release-testing module requirements: $missing") - : plan skip_all => "Test needs: $missing" -} - -# FIXME - temporary workaround for RT#82033 -# also add all scripts (no extension) and some extra extensions -# we want to check -{ - no warnings 'redefine'; - - *Test::EOL::_is_perl_module = sub { - $_[0] !~ /\./ || $_[0] =~ /\.(?:pm|pod|skip|json|proto)$/i || $_[0] =~ /::/; - } -} - -Test::NoTabs::all_perl_files_ok( - qw/t xt lib script examples maint/, -); - -# check some non-"perl files" in the root separately -# use .gitignore as a guide of what to skip -# (or do not test at all if no .gitignore is found) -if (open(my $gi, '<', '.gitignore')) { - my $skipnames; - while (my $ln = <$gi>) { - next if $ln =~ /^\s*$/; - chomp $ln; - $skipnames->{$_}++ for bsd_glob($ln); - } - - for my $fn (bsd_glob('*')) { - next if $skipnames->{$fn}; - next unless -f $fn; - Test::NoTabs::notabs_ok($fn); - } -} - -# FIXME - Test::NoTabs declares 'no_plan' which conflicts with done_testing -# https://github.com/schwern/test-more/issues/14 -#done_testing; diff --git a/xt/eol.t b/xt/whitespace.t similarity index 61% rename from xt/eol.t rename to xt/whitespace.t index da4ef10..0645aed 100644 --- a/xt/eol.t +++ b/xt/whitespace.t @@ -7,27 +7,29 @@ use lib 't/lib'; use DBICTest; require DBIx::Class; -unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_eol') ) { - my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_eol'); +unless ( DBIx::Class::Optional::Dependencies->req_ok_for ('test_whitespace') ) { + my $missing = DBIx::Class::Optional::Dependencies->req_missing_for ('test_whitespace'); $ENV{RELEASE_TESTING} ? die ("Failed to load release-testing module requirements: $missing") : plan skip_all => "Test needs: $missing" } -# FIXME - temporary workaround for RT#82032 +# FIXME - temporary workaround for RT#82032, RT#82033 # also add all scripts (no extension) and some extra extensions # we want to check { no warnings 'redefine'; + my $is_pm = sub { + $_[0] !~ /\./ || $_[0] =~ /\.(?:pm|pod|skip|sql|json|proto)$/i || $_[0] =~ /::/; + }; - *Test::EOL::_is_perl_module = sub { - $_[0] !~ /\./ || $_[0] =~ /\.(?:pm|pod|skip|json|proto)$/i || $_[0] =~ /::/; - } + *Test::EOL::_is_perl_module = $is_pm; + *Test::NoTabs::_is_perl_module = $is_pm; } -Test::EOL::all_perl_files_ok({ trailing_whitespace => 1 }, - qw/t xt lib script examples maint/, -); +my @pl_targets = qw/t xt lib script examples maint/; +Test::EOL::all_perl_files_ok({ trailing_whitespace => 1 }, @pl_targets); +Test::NoTabs::all_perl_files_ok(@pl_targets); # check some non-"perl files" in the root separately # use .gitignore as a guide of what to skip @@ -40,13 +42,17 @@ if (open(my $gi, '<', '.gitignore')) { $skipnames->{$_}++ for bsd_glob($ln); } + # that we want to check anyway + delete $skipnames->{'META.yml'}; + for my $fn (bsd_glob('*')) { next if $skipnames->{$fn}; next unless -f $fn; Test::EOL::eol_unix_ok($fn, { trailing_whitespace => 1 }); + Test::NoTabs::notabs_ok($fn); } } -# FIXME - Test::EOL declares 'no_plan' which conflicts with done_testing +# FIXME - Test::NoTabs and Test::EOL declare 'no_plan' which conflicts with done_testing # https://github.com/schwern/test-more/issues/14 #done_testing;