Encode :: Locale在Cygwin中失败了env.t的3/13测试

时间:2015-03-23 17:30:01

标签: perl cygwin

我在Cygwin(v1.7.35,64位版本)中安装Encode::Locale时遇到问题,并且在t/env.t中未能通过测试时遇到错误。

$ cpan install Encode::Locale
Going to read '/home/agrajag9/.cpan/Metadata'
  Database was generated on Mon, 23 Mar 2015 12:17:02 GMT
Running install for module 'Encode::Locale'
Running make for G/GA/GAAS/Encode-Locale-1.04.tar.gz
Checksum for /home/agrajag9/.cpan/sources/authors/id/G/GA/GAAS/Encode-Locale-1.04.tar.gz ok

  CPAN.pm: Going to build G/GA/GAAS/Encode-Locale-1.04.tar.gz

Checking if your kit is complete...
Looks good
Generating a Unix-style Makefile
Writing Makefile for Encode::Locale
Writing MYMETA.yml and MYMETA.json
cp lib/Encode/Locale.pm blib/lib/Encode/Locale.pm
Manifying 1 pod document
  GAAS/Encode-Locale-1.04.tar.gz
  make -- OK
Running make test
PERL_DL_NONLAZY=1 "/usr/bin/perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/alias.t ...... ok
t/arg.t ........ # ENCODING_LOCALE is UTF-8
t/arg.t ........ ok
t/env.t ........ Failed 3/13 subtests
t/tain.t ....... ok
t/warn_once.t .. ok

Test Summary Report
-------------------
t/arg.t      (Wstat: 0 Tests: 4 Failed: 0)
  TODO passed:   1-4
t/env.t      (Wstat: 0 Tests: 10 Failed: 0)
  Parse errors: Bad plan.  You planned 13 tests but ran 10.
Files=5, Tests=25,  2 wallclock secs ( 0.05 usr  0.19 sys +  0.29 cusr  0.68 csys =  1.21 CPU)
Result: FAIL
Failed 1/5 test programs. 0/25 subtests failed.
Makefile:856: recipe for target 'test_dynamic' failed
make: *** [test_dynamic] Error 255
  GAAS/Encode-Locale-1.04.tar.gz
  make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports GAAS/Encode-Locale-1.04.tar.gz
Running make install
  make test had returned bad status, won't install without force

将已编译的Encode/Locale.pm版本手动复制到/lib/perl5/5.14/并运行env.t

$ perl t/env.t
1..13
ok 1 - env read
ok 2 - env write retval old value
ok 3 - env write worked
ok 4 - env affected %ENV
ok 5 - env write retval old value
ok 6 - env write worked
ok 7 - env write undef deletes from %ENV
ok 8 - env write retval encoded
ok 9 - env write worked
ok 10 - env affected %ENV

以下测试似乎失败了:

is env("\x{20AC}", 1), undef, 'env write retval old value';
is env("\x{20AC}"), 1, 'env write worked';
is $ENV{"\x80"}, 1, 'env affected %ENV';

perl -v

的输出
This is perl 5, version 14, subversion 4 (v5.14.4) built for cygwin-thread-multi
(with 14 registered patches, see perl -V for more detail)

Copyright 1987-2013, Larry Wall

Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.

1 个答案:

答案 0 :(得分:2)

设置一个名称超出7位ASCII的Cygwin环境变量会导致我使用的每个perl版本出现分段错误,并且在python中也不允许这样做。

import os;
os.environ[chr(126)]="126"
print os.environ[chr(126)]
os.environ[chr(130)]="130"
print os.environ[chr(130)]

$ python env.py
126
Traceback (most recent call last):
  File "env.py", line 4, in <module>
    os.environ[chr(130)]="130"
  File "/usr/lib/python2.7/os.py", line 473, in __setitem__
    putenv(key, item)
OSError: [Errno 14] Bad address

强行安装(cpan -f Encode::Locale)并且不要惹恼它。如果你没有做任何黑魔法,你就不需要那些花哨的环境变量名。

(您仍然可以将环境变量设置为几乎任何东西。)