プロジェクトのテストを開始するために CTest を使用しています。前回の実行で失敗したテストのみを起動したいと考えています。
CTest でそれを行う簡単な方法はありますか?
プロジェクトのテストを開始するために CTest を使用しています。前回の実行で失敗したテストのみを起動したいと考えています。
CTest でそれを行う簡単な方法はありますか?
この--rerun-failed
オプションは、CMake 3.0 で CTest に追加されました。
--rerun-failed
Run only the tests that failed previously
This option tells ctest to perform only the tests that failed
during its previous run. When this option is specified, ctest
ignores all other options intended to modify the list of tests
to run (-L, -R, -E, -LE, -I, etc). In the event that CTest runs
and no tests fail, subsequent calls to ctest with the
--rerun-failed option will run the set of tests that most
recently failed (if any).
参考文献:
短い答えはノーだと思います。
ただし、単純な CMake スクリプトを使用して、最後に失敗したテストのリストをCTest の-I
オプションに適した形式に変換できます。
CTest は、<your build dir>/Testing/Temporary/LastTestsFailed.log
失敗したテストのリストを含むようなファイルを作成します。後続の実行ですべてのテストに合格した場合、このリストはクリアされません。また、CTest が (dart クライアントとして) ダッシュボード モードで実行されている場合、ログ ファイル名には、ファイルに詳述されているタイムスタンプが含まれます<your build dir>/Testing/TAG
。
以下のスクリプトは、タイムスタンプを含むファイル名を考慮していませんが、これを行うように拡張するのは簡単なはずです。失敗したテストのリストを読み取り、FailedTests.log
現在のビルド ディレクトリに呼び出されるファイルを書き込みます。
set(FailedFileName FailedTests.log)
if(EXISTS "Testing/Temporary/LastTestsFailed.log")
file(STRINGS "Testing/Temporary/LastTestsFailed.log" FailedTests)
string(REGEX REPLACE "([0-9]+):[^;]*" "\\1" FailedTests "${FailedTests}")
list(SORT FailedTests)
list(GET FailedTests 0 FirstTest)
set(FailedTests "${FirstTest};${FirstTest};;${FailedTests};")
string(REPLACE ";" "," FailedTests "${FailedTests}")
file(WRITE ${FailedFileName} ${FailedTests})
else()
file(WRITE ${FailedFileName} "")
endif()
次に、次のようにして、失敗したテストだけを実行できるようにする必要があります。
cmake -P <path to this script>
ctest -I FailedTests.log
Fraserの回答に基づくLinuxワンライナー:
ctest -I ,0,,`awk -F: '{print $1;}' Testing/Temporary/LastTestsFailed.log | paste -d, -s`