forked from Perl-Toolchain-Gang/ExtUtils-MakeMaker
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test and eliminate unicode warning Perl-Toolchain-Gang#22
- Loading branch information
Showing
3 changed files
with
96 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package MakeMaker::Test::Setup::Unicode; | ||
|
||
@ISA = qw(Exporter); | ||
require Exporter; | ||
@EXPORT = qw(setup_recurs teardown_recurs); | ||
|
||
use strict; | ||
use File::Path; | ||
use File::Basename; | ||
use MakeMaker::Test::Utils; | ||
use utf8; | ||
|
||
my %Files = ( | ||
'Problem-Module/Makefile.PL' => <<'END', | ||
use ExtUtils::MakeMaker; | ||
use utf8; | ||
WriteMakefile( | ||
NAME => 'Problem::Module', | ||
AUTHOR => q{Danijel Tašov}, | ||
); | ||
END | ||
|
||
); | ||
|
||
|
||
sub setup_recurs { | ||
while(my($file, $text) = each %Files) { | ||
# Convert to a relative, native file path. | ||
$file = File::Spec->catfile(File::Spec->curdir, split m{\/}, $file); | ||
|
||
my $dir = dirname($file); | ||
mkpath $dir; | ||
open(FILE, ">:utf8", $file) || die "Can't create $file: $!"; | ||
print FILE $text; | ||
close FILE; | ||
|
||
# ensure file at least 1 second old for makes that assume | ||
# files with the same time are out of date. | ||
my $time = calibrate_mtime(); | ||
utime $time, $time - 1, $file; | ||
} | ||
|
||
return 1; | ||
} | ||
|
||
sub teardown_recurs { | ||
foreach my $file (keys %Files) { | ||
my $dir = dirname($file); | ||
if( -e $dir ) { | ||
rmtree($dir) || return; | ||
} | ||
} | ||
return 1; | ||
} | ||
|
||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Test problems in Makefile.PL's and hint files. | ||
|
||
BEGIN { | ||
unshift @INC, 't/lib'; | ||
} | ||
chdir 't'; | ||
|
||
use strict; | ||
use Test::More tests => 5; | ||
use ExtUtils::MM; | ||
use MakeMaker::Test::Setup::Unicode; | ||
use TieOut; | ||
|
||
my $MM = bless { DIR => ['.'] }, 'MM'; | ||
|
||
ok( setup_recurs(), 'setup' ); | ||
END { | ||
ok( chdir File::Spec->updir ); | ||
ok( teardown_recurs(), 'teardown' ); | ||
} | ||
|
||
ok( chdir 'Problem-Module', "chdir'd to Problem-Module" ) || | ||
diag("chdir failed: $!"); | ||
|
||
|
||
# Make sure when Makefile.PL's break, they issue a warning. | ||
# Also make sure Makefile.PL's in subdirs still have '.' in @INC. | ||
{ | ||
my $stdout = tie *STDOUT, 'TieOut' or die; | ||
|
||
my $warning = ''; | ||
local $SIG{__WARN__} = sub { $warning = join '', @_ }; | ||
$MM->eval_in_subdirs; | ||
is $warning, '', 'no warning'; | ||
|
||
untie *STDOUT; | ||
} |