10

プロジェクトのテストを開始するために CTest を使用しています。前回の実行で失敗したテストのみを起動したいと考えています。

CTest でそれを行う簡単な方法はありますか?

4

3 に答える 3

22

この--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).

参考文献:

于 2016-05-11T22:08:22.990 に答える
2

短い答えはノーだと思います。

ただし、単純な 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
于 2012-12-06T00:18:28.690 に答える
0

Fraserの回答に基づくLinuxワンライナー:

ctest -I ,0,,`awk -F: '{print $1;}' Testing/Temporary/LastTestsFailed.log | paste -d, -s`
于 2014-10-01T12:28:10.473 に答える