基于 meson构建的应用程序,可以借助 meson test来进行测试。meson test支持很多参数,如下所示:

$ meson test [-h] [--maxfail MAXFAIL] [--repeat REPEAT] [--no-rebuild][--gdb] [--gdb-path GDB_PATH] [--list] [--wrapper WRAPPER][-C WD] [--suite SUITE] [--no-suite SUITE] [--no-stdsplit][--print-errorlogs] [--benchmark] [--logbase LOGBASE][--num-processes NUM_PROCESSES] [-v] [-q][-t TIMEOUT_MULTIPLIER] [--setup SETUP][--test-args TEST_ARGS][args [args ...]]

各个参数的含义如下:

positional arguments:args                                  Optional list of test names to run."testname" to run all tests with thatname, "subprojname:testname" tospecifically run "testname" from"subprojname", "subprojname:" to run alltests defined by "subprojname".optional arguments:-h, --help                            show this help message and exit--maxfail MAXFAIL                     Number of failing tests before abortingthe test run. (default: 0, to disableaborting on failure)--repeat REPEAT                       Number of times to run the tests.--no-rebuild                          Do not rebuild before running tests.--gdb                                 Run test under gdb.--gdb-path GDB_PATH                   Path to the gdb binary (default: gdb).--list                                List available tests.--wrapper WRAPPER                     wrapper to run tests with (e.g.Valgrind)-C WD                                 directory to cd into before running--suite SUITE                         Only run tests belonging to the givensuite.--no-suite SUITE                      Do not run tests belonging to the givensuite.--no-stdsplit                         Do not split stderr and stdout in testlogs.--print-errorlogs                     Whether to print failing tests' logs.--benchmark                           Run benchmarks instead of tests.--logbase LOGBASE                     Base name for log file.--num-processes NUM_PROCESSES         How many parallel processes to use.-v, --verbose                         Do not redirect stdout and stderr-q, --quiet                           Produce less output to the terminal.-t TIMEOUT_MULTIPLIER, --timeout-multiplier TIMEOUT_MULTIPLIERDefine a multiplier for test timeout,for example when running tests inparticular conditions they might takemore time to execute. (<= 0 to disabletimeout)--setup SETUP                         Which test setup to use.--test-args TEST_ARGS                 Arguments to pass to the specifiedtest(s) or all tests

在这里,重点关注两个参数:--test-argsargs。如上述所引用的内容,args参数指定了需要运行的测试用例名称,并且可指定多次,即运行多个测试用例。--test-args参数会将其取值传给应用程序,作为应用程序的参数。下面借助一个简单的示例程序来使用一下这两个参数:
首先,定义执行程序的源码文件:main.c,内容如下所示:

#include <stdio.h>int main(int argc, char *argv[])
{int i = 0;for (i = 0; i < argc; ++i) {printf("arg-%d: %s\n", i, argv[i]);}return 0;
}

其次,定义构建脚本:meson.build,内容如下所示:

project('simple', 'c')
exe = executable('main', 'main.c')
test('test1', exe)
test('test2', exe)
test('test3', exe)

使用 meson test运行测试用例:

$ meson test -C build/ --test-args="-a 1 -b 2" test1 test2
ninja: Entering directory `/home/zhoumin/test/meson/build'
ninja: no work to do.
1/2 test1        OK              0.01s
2/2 test2        OK              0.01sOk:                 2
Expected Fail:      0
Fail:               0
Unexpected Pass:    0
Skipped:            0
Timeout:            0Full log written to /home/zhoumin/test/meson/build/meson-logs/testlog.txt

上述 test1test2作为 meson test的参数,指定了需要运行的测试用例名称。--test-args="-a 1 -b 2"作为 meson test的参数,指定了给应用程序传递的参数信息:"-a 1 -b 2",打开 build/meson-logs/testlog.txt文件,可以看到应用程序接收到的参数列表,如下所示:

==================================== 1/2 =====================================
test:         test1
start time:   10:36:27
duration:     0.01s
result:       exit status 0
command:      MALLOC_PERTURB_=237 /home/zhoumin/test/meson/build/main -a 1 -b 2
----------------------------------- stdout -----------------------------------
arg-0: /home/zhoumin/test/meson/build/main
arg-1: -a
arg-2: 1
arg-3: -b
arg-4: 2
==============================================================================

参考资料

  1. https://mesonbuild.com/Commands.html
  2. https://mesonbuild.com/Meson-sample.html

meson test 的 --test-args 参数相关推荐

  1. 【Groovy】Groovy 脚本调用 ( Groovy 类中调用 Groovy 脚本 | 参考 Script#evaluate 方法 | 创建 Binding 对象并设置 args 参数 )

    文章目录 一.Groovy 类中调用 Groovy 脚本 1.参考 Script#evaluate 方法分析 Groovy 类中调用 Groovy 脚本 2.创建 Binding 对象并设置 args ...

  2. Python编程基础:第二十五节 args参数*args

    第二十五节 args参数*args 前言 实践 前言 我们目前学习到的函数的参数个数都是固定的,那么我们是否可以指定任意多个参数呢?其实是可以的,这里就用到了args参数,它可以将用户指定的任意多个参 ...

  3. Python多任务(多线程执行带有参数的任务,利用threading创建线程时传入参数--args参数和kwargs参数)

    1.多线程执行带有参数的任务 以元组形式传参 以字典方式进行传参       (字典的key值和参数名要一致) 2.线程的注意点 线程之间执行是无序的 主线程会等待所有的子线程执行结束再结束 如果要主 ...

  4. vscode给java项目传递args[]参数

    文章目录 问题概览 改进办法 问题概览 笔者在学习设计模式的Java实现时,使用vscode工具. 最近遇到一个问题: 如何给Java的main方法传递args[]参数? 源代码: public cl ...

  5. 关于C#的Main(String[] args)参数输入问题

    指定相关的测试代码 首先,写一个用于测试的关于Main(String[] args)参数输入有关的代码类,如下: using System; public class Hello {     publ ...

  6. java中的object... args参数

    关于java方法中Object... args参数的含义 在阅读google发布的volley源码时,突然看到一个方法中存在这样的写法,如 :v(String format, Object... ar ...

  7. R语言ggpubr包的ggscatter函数可视化散点图(scatter plot)、cor.coef为散点图添加相关性系数及其显著性、cor.coeff.args参数指定相关性计算方法及显示格式

    R语言ggplot2可视化:使用ggpubr包的ggscatter函数可视化散点图(scatter plot).设置cor.coef参数为散点图添加相关性系数及其显著性.cor.coeff.args参 ...

  8. VScode、argparse库、lauch.json中args参数

    argparse库是用于接受从command-lines传来参数的库,即argparse库接受命令台终端中传入的参数,但在VScode中并不需要从command-lines来配置参数.VScode通过 ...

  9. java args用法_Java中args参数数组的用法说明代码

    本篇文章小编给大家分享一下Java中args参数数组的用法说明代码,文章代码介绍的很详细,小编觉得挺不错的,现在分享给大家供大家参考,有需要的小伙伴们可以来看看. main方法args参数用于接收用户 ...

  10. java args的用法_Java中args参数数组的用法说明

    main方法args参数用于接收用户输入的参数,参数以字符串形式存放在数组中. 这里将传递参数参数的形式分两种,一种是传递普通参数,另一种是传递含有空格的参数. 1.传递普通参数 public cla ...

最新文章

  1. etal斜体吗 参考文献_参考文献类有关论文范例,与日语文提纲2016年,日语文提纲科目相关本科毕业论文范文...
  2. Linux IPC实践(4) --System V消息队列(1)
  3. ANDROID 4.0 SDK R14 模拟器
  4. 学python语言有前途吗-学习python的前景怎么样?
  5. 各种翻页的效果! FILTER: revealTrans使用说明
  6. Android 动态生成布局 (多层嵌套)
  7. 计算机组成原理学习笔记-加法器
  8. Origin模板生成
  9. 贪心算法的数学证明 (更新中)
  10. iphone转android教程,王者荣耀ios转安卓教程攻略
  11. 当前系统缺少NTFS格式转换器(convert.exe)
  12. DMA方式的数据传送过程
  13. 前方高能!Netflix推出《怪奇物语》VR体验
  14. MySQL怎么打开explain_MySql性能加速分析以及PHPMYADMIN中explain用法
  15. 2021年西式面点师(中级)报名考试及西式面点师(中级)证考试
  16. GraphPad Prism 如何将行标签添加到数据集丨使用教程
  17. 苏雅欣课后作业四 个人总结
  18. 关于onKeyDown方法
  19. GRANT ALL PRIVILEGES
  20. linux使用curl进行接口测试

热门文章

  1. cdr安装一直卡在初始界面_win10关掉防火墙,cdr卡在用户界面初始化
  2. mySQL 2008安装MOF无法连接_SQL Server 2008安装失败,提示MOF编译器无法连接WMI服务器,该如何解决.谢谢!...
  3. halcon学习笔记4-字符识别(包括汉字识别)
  4. 如何配置Gitlab的双因子验证(Two-Factor Authentication)
  5. http://www.cnblogs.com/qianmojing/p/6142178.html
  6. 自媒体行业现在还能赚钱吗?
  7. 《尚书》全文、注释及译文(2)
  8. 双侧检验的p值和单侧检验_t检验的时候怎么区分是单侧检验还是双侧呢?
  9. pdf照片显示正常打印时被翻转_2020考研 | 准考证怎么打印你知道吗?
  10. android switch的使用方法,Android开关控件,ToggleButton和Switch使用大全