Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2822

GoogleTest+カバレッジMemo

$
0
0
GoogleTestの実行ファイルを 1ケースごとフィルタかけてカバレッジ出力(lcov)するBashのメモ google_lcov.sh #!/bin/bash # 引数チェック if [ $# -ne 1 ]; then echo "引数を設定してください" exit fi # google test リスト取得 list_test=$(./"$1" --gtest_list_tests) count=1 for el in $list_test; do if [[ $el =~ .*\. ]]; then case_name=$el else # 検査実行 "./$1" --gtest_filter="$case_name$el" # フォルダ作成 mkdir_name=$(printf %02d $count)."$case_name$el" mkdir "$mkdir_name" find_path=$(find ./ -name "*.gcda") declare -A tmp_map # 一意の*gcda格納ディレクトリを取得 for el2 in $find_path; do tmp_map[$(dirname "$el2")]='' done # lcovオプション作成 uniq_dir_name=${!tmp_map[@]} for el2 in $uniq_dir_name; do lcov_d_options+="-d .""$el2"" " done # ディレクトリ移動 cd "./$mkdir_name" || exit # カバレッジ出力 lcov -c $lcov_d_options -o lcov.info genhtml lcov.info -o ./info # 元のディレクトリに戻る cd ../ # 前の出力の削除 # ちょっと微妙だけど find ./ -name "*.gcda" -exec rm {} \; ((count++)) || true fi done

Viewing all articles
Browse latest Browse all 2822

Latest Images

Trending Articles