在cmake中集成bash测试脚本 [英] Integrate bash test scripts in cmake

查看:335
本文介绍了在cmake中集成bash测试脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个C ++ cmake项目,使用Boost测试进行单元测试。现在我想展示一系列bash脚本(用于集成测试)到cmake。假设每个此脚本在 PASS 的情况下返回0,或在 FAILURE 的情况下返回某个!= 0。我想要每当我运行 cmake test 时执行每个脚本。



获取最简单和最快的方法是什么这种行为

解决方案

基本上,你想从找到bash程序开始

  find_program(BASH_PROGRAM bash)

脚本到测试列表

  if(BASH_PROGRAM)
add_test(mytest $ {BASH_PROGRAM} $ {CMAKE_CURRENT_SOURCE_DIR} / script.sh)
endif(BASH_PROGRAM)

p>

I have a C++ cmake project that uses Boost Test for unit testing. Now I would like to expose a series of bash scripts (used for integration testing) to cmake. Suppose each of this script to return 0 in case of PASS or something != 0 in case of FAILURE. I would like each script to be executed whenever I run cmake test.

What's the simplest and quickest way to obtain such behavior

解决方案

Basically, you want to start by locating the bash program

find_program (BASH_PROGRAM bash)

Then just add your script to the list of tests

if (BASH_PROGRAM)
  add_test (mytest ${BASH_PROGRAM} ${CMAKE_CURRENT_SOURCE_DIR}/script.sh)
endif (BASH_PROGRAM)

And all of that should work.

这篇关于在cmake中集成bash测试脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆