使用 Devel-Cover 獲取覆蓋率報告 (Using Devel-Cover to get coverage reports)


問題描述

使用 Devel‑Cover 獲取覆蓋率報告 (Using Devel‑Cover to get coverage reports)

我是 Perl 新手,我正在嘗試為我擁有的 Perl 腳本生成覆蓋率報告。我按照此處提到的步驟安裝了 Devel‑Cover https://code.activestate.com/ ppm/Devel‑Cover/ 並運行

perl ‑MDevel::Cover script

我得到一些覆蓋率信息和該消息

    Pod coverage is unavailable.  Please install Pod::Coverage from CPAN.

然後運行命令cover生成報告我得到 cover: Command not found. 嘗試按輸出所述運行 cpan install Pod::Coverage 但它失敗了。我不確定我在這裡缺少什麼。我也嘗試使用 Devel::Coverage 使用

 perl ‑d:Coverage script

但我得到了輸出

Can't locate Devel/Coverage.pm in @INC (you may need to install the Devel::Coverage module) (@INC contains: /spiratech/tools/perllib /home/mmaher/.cache/activestate/02540130/lib/perl5/site_perl/5.32.0/x86_64‑linux /home/mmaher/.cache/activestate/02540130/lib/perl5/site_perl/5.32.0 /home/mmaher/.cache/activestate/02540130/lib/perl5/5.32.0/x86_64‑linux /home/mmaher/.cache/activestate/02540130/lib/perl5/5.32.0).
BEGIN failed‑‑compilation aborted.
%!s(<nil>)

我不能 找不到有關如何安裝它的任何說明。我正在使用 Perl v5.32.0


參考解法

方法 1:

Zeroth, ActiveState's PPM is old stuff. They have a new State Tool to handle all of that. Note that this is for using their Perl packages. If you aren't using ActiveState's perl, don't use their instructions.

First, you only need Pod::Coverage if you want to check that all of your public subroutines are documented. It's an optional feature.

Second, there's no install command to cpan. Just list the modules that you want or use the command line options. With no options, the ‑i (for install) is assumed:

$ cpan Pod::Coverage
$ cpan ‑i Pod::Coverage

Third, the ‑d switch for debugging assumes that you are loading a module under the Devel namespace. That's why ‑d:Coverage looks for Devel::Coverage, which it then cannot find.

To load any module that you like, you can use the ‑M switch. This takes the entire module name:

$ perl ‑MPod::Coverage

Lastly, once you install Devel::Cover, look where you installed cover and ensure that that directory is in your PATH.

(by Merollabrian d foy)

參考文件

  1. Using Devel‑Cover to get coverage reports (CC BY‑SA 2.5/3.0/4.0)

#perl #code-coverage #devel-cover






相關問題

保持特定位數的簡單 Perl 數學 (simple Perl math while keeping a specific number of digits)

如何在 Windows 批處理腳本或 Perl 中將文件移動到回收站? (How can I move files to the Recycle Bin in a Windows batch script or Perl?)

從子程序返回數組 (Return array from subroutine)

我可以以與操作系統無關的方式限制 Perl 進程使用的內存嗎? (Can I Iimit the memory used by a Perl process in an OS-agnostic way?)

$# 在 perl 中接受什麼作為輸入? (what does $# accept as input in perl?)

Perl Text::CSV_XS 從字符串中讀取 (Perl Text::CSV_XS read from string)

使用 excel 2010 更新批處理文件中的變量 (use excel 2010 to update variables in batch file)

在 perl 中為哈希添加值 (Adding value to an hash in perl)

為什麼 perl 會忽略我的正則表達式中的多餘字符? (Why does perl ignore extra characters in my regex?)

boost::regex - \bb? (boost::regex - \bb?)

如果小於 X 天,如何從磁盤讀取文件,如果舊,則重新獲取 html 文件 (How to read a file from the disk if less than X days old, if older, refetch the html file)

使用 Devel-Cover 獲取覆蓋率報告 (Using Devel-Cover to get coverage reports)







留言討論