今日のお昼くらいに書いた1つ前の記事「妖精さん、小人さん、イヌネコ、自動テスト」において、全自動テストであるイヌネコテストのカバレッジが3割弱だと書きました。
その後、Kuwataさんが基本コマンド(スクリプトではありません)に手を加えてくれて、カバレッジはだいぶ改善しました。515個のコマンド中474個が実行可能(つまりテスト可能)だとイヌネコが言っています。カバレッジは9割超(92%)まで伸びました。
inu-nekoモジュールをそのまま貼り付けておきます。
/**
* イヌネコテスト
*/
module inu-neko;
/** コマンド */
type Command = reif:CommandSummary;
/** イヌネコでも実行可能なコマンドの特徴付け
* この型はフィルタリング条件として使う
*/
type InuNekoExecutable = {
/* 型パラメータは空 */
"typeParams": [],
/* 実装されている */
"implemented": ("python" | "catyscript"),
/* interactive ではない */
"annotations": {
"interactive": false?,
* : any?
}?,
*: any?
};
/** イヌネコでも実行可能かを調べる (述語コマンド) */
command can-exec :: Command -> (@OK Command | @NG Command) {
case {
InuNekoExecutable => @OK pass,
* => @NG pass,
}
};
/** アプリケーションに含まれるすべてのコマンドを列挙して、イヌネコでも実行可能かを調べる
*/
command list-and-check-commands [string appName] :: void -> [(@OK Command | @NG Command)*] {
%1 > appName;
sreif:list-modules /*--rec そのうち必要 */ %appName |
each {
$.name > modName;
[%appName, "::", %modName] | text:concat > modPath | dump/*確認用*/;
sreif:list-commands /*--rec そのうち必要 */ %modPath |
each {
can-exec
}
} | list:concat
};次のようにすると、[全コマンド数, テスト可能コマンド数] が表示されます。
caty:root> inu-neko:list-and-check-commands global | [list:length, take{pass}|list:length]
[
197,
173
]
caty:root>