2017-12-29 19 views
0

私はctest設定を持っており、プロジェクト用に構築したすべての実行ファイルでうまく動作します。問題は、システムコマンドでいくつかのテストを追加したいということです。ソリューションのプログラムとは何の関係もなく、ctestで実行できません。その後ctestは単純なコマンドでは実行できません

add_test(NAME toto_test COMMAND echo bla bla bla) 

私はcTESTを実行したとき、私はエラー

Start 1: toto_test 
Could not find executable echo 
Looked in the following places: 
echo 
echo.exe 
Release/echo 
Release/echo.exe 
Release/echo 
Release/echo.exe 
Unable to find executable: echo 
1/10 Test #1: toto_test ........................***Not Run 0.00 sec 

The following tests FAILED: 
     1 - toto_test (Not Run) 
Errors while running CTest 

を持って、私が実行します。

は、私はそれだけで echoコマンドを実行し、以下のように簡単なテストを追加しました冗長オプションでctestを取得すると、

Constructing a list of tests 
Done constructing a list of tests 
Updating test list for fixtures 
Added 0 tests to meet fixture requirements 
Checking test dependency graph... 
Checking test dependency graph end 
test 1 
    Start 1: toto_test 
Could not find executable echo 
Looked in the following places: 
echo 
echo.exe 
Release/echo 
Release/echo.exe 
Release/echo 
Release/echo.exe 

1: Test command: "bla" "bla" "bla" 
Unable to find executable: echo 
1/1 Test #1: toto_test ........................***Not Run 0.00 sec 

0% tests passed, 1 tests failed out of 1 

Total Test time (real) = 0.02 sec 

The following tests FAILED: 
     1 - toto_test (Not Run) 
Errors while running CTest 

誰でもできるお願いします。 ありがとうございました

+0

あなたは 'FIND_PROGRAM()'や '$ {CMAKE_COMMANDを試してみてください} -E echo'それははるかに移植性が高くなります –

答えて

0

私はそれを行う方法を見つけました。その後、外部プログラムでテストを実行しているの一般的な目的、使用add_custom_target、テストを実行しているときに、この目標を構築するために$ {CMAKE_COMMAND}を使用するために:

add_custom_target(run_toto COMMAND echo bla bla bla) 
add_test(NAME test_toto COMMAND ${CMAKE_COMMAND} --build . --target run_toto) 
関連する問題