我对travis ci的运行测试有点问题。我写了Cmakelists.txt和.travis.yml文件,其中包含以下代码:
language: cpp
compiler:
- gcc
install:
- sudo apt-get install libgtest-dev
before_script:
- mkdir build
- cd build
- cmake --version
- cmake -DCMAKE_VERBOSE_MAKEFILE=ON ..
script: make && make test
和cmakelists.txt文件:
cmake_minimum_required( VERSION 2.6 )
project ( CodeProject )
project ( TestProject )
set( CMAKE_CXX_STANDARD 14 )
set( CMAKE_CXX_STANDARD_REQUIRED on )
include_directories ( ${CodeProject_SOURCE_DIR}/code_src/ )
include_directories ( ${TestProject_SOURCE_DIR}/test_src/ )
set ( CodeProject_SOURCES ${CodeProject_SOURCE_DIR}/code_src/main.cpp )
set ( TestProject_SOURCES ${TestProject_SOURCE_DIR}/test_src/mainTest.cpp )
set( CMAKE_EXECUTABLE_OUTPUT_PATH "build/${CodeProject}" )
add_executable( CodeProject ${CodeProject_SOURCES} )
add_executable( TestProject ${TestProject_SOURCES} )
当我尝试在travis ci上构建我的解决方案时,我收到了这样的消息:
make: *** No rule to make target `test'. Stop.
The command "make && make test" exited with 2.
有什么问题?
答案 0 :(得分:0)
首先必须enable testing enable_testing()
add_test()
。每个测试都由{{3}}添加(需要一个exe目标)。
# ...
# Enables 'test' target
enable_testing()
# Create your test executable
add_executable(TestProject ${TestProject_SOURCES})
# Register the test
add_test(NAME TestProject COMMAND TestProject)
# Add further tests ...