I am adding a new test to a huge CMake based repo. I would like to update an inputfile to a new outputfile and then compare outputfile with golden copy to make sure outputfile is updated correctly. I have a cpp file to update, and during build process, it will generate a updater.tsk .This updater.tsk will take two parameters -- inputfile and outputfile. And I would like to run a test script to run the task with my test file.Here is the code:
In test.sh
./updater.tsk --input testInput --output outputFile
In CMakeLists.txt
add_executable (updater)
set_target_properties( update PROPERTIES OUTPUT_NAME updater.tsk)
install(TARGETS updater)
....
# copy my testInput to BINARY_DIR
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/testInput
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
#copy my test script to BINARY_DIR
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/test.sh
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
#generate update.tsk first, then run test script and generate output file
add_custom_command(TARGET updater POST_BUILD
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/test.sh
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
but problem is it failed due to "updater.tsk" does not exist when running my test script. So why is POST_BUILD not working? Is it supposed to generate executable first? Also, for the whole testing idea, is there a better way to do this testing? Thanks!
Aucun commentaire:
Enregistrer un commentaire