Windows操作系统上的Perl IO :: Stringy和IO :: InnerFile安装测试失败(以及如何解决)

问题描述 投票:-1回答:2

在Windows 8.1 PC上干净安装Active Perl(64位版本,版本5.24.3)后,我需要添加Spreadsheet :: Read Perl模块。但是,其CPAN安装失败。

对控制台报告的分析表明,失败的根本原因是IO :: InnerFile模块,它未安装。或者 - 更好地说 - 该模块的所有七个自动测试都失败了。测试脚本名为IO_InnerFile.t(在我的例子中)它位于C:\ Perl64 \ cpan \ build \ IO-stringy-2.111-0 \ t目录中。

perl
2个回答
1
投票

jmasa的方法对我不起作用,但是这样做了:

在IO_InnerFile.t中,将# Create a test file后面的块更改为:

# Create a test file
do {
    open(OUT, '>t/dummy-test-file') || die("Cannot write t/dummy-test-file: $!");
    local $\ = "\n";    ## Use `print` vs. `say` to avoid extra blank lines.
    binmode OUT, ':raw';    ## Force output of UNIX line terminators.
    print OUT <<'EOF';
Here is some dummy content.
Here is some more dummy content
Here is yet more dummy content.
And finally another line.
EOF
    close(OUT);
};

这将更改本地化为$/(更改为UNIX单字符行终止符)并使用它将测试文本输出到虚拟文件。

然后跑

dmake test

dmake install


-1
投票

很快我意识到(因为寻找)测试脚本IO_InnerFile.t只能用于行终止符是单字节的平台上。在M $ Windows的情况下,行终止符由两个字节\ r \ n序列组成,寻求绝对位置不起作用 - 只是测试本身不可移植。

可能的解决方法是添加PerlIO层“:crlf”:

  1. 打开文件IO_InnerFile.t并找到读取的行: my $fh = IO::File->new('<t/dummy-test-file'); 并将其更改为: my $fh = IO::File->new('<:crlf t/dummy-test-file'); 注意“<:crlf”和“t / dummy-test-file”之间的空格
  2. 打开控制台窗口并切换到模块构建目录(在我的情况下为C:\ Perl64 \ cpan \ build \ IO-stringy-2.111-0)
  3. 手动运行: dmake test dmake install

注意:我不打扰正确的PATH设置和绝对文件位置,这可能会有所不同。

© www.soinside.com 2019 - 2024. All rights reserved.