首页 > 解决方案 > 如何从 lcov --summary 命令中仅读取行覆盖率并存储在某些 shell 脚本变量中?

问题描述

当我运行命令时lcov --summary coverage/lcov.info

我在控制台中得到如下输出

Summary coverage rate: lines......: 80.5% (4900 of 6090 lines) functions..: no data found branches...: no data found

我只想将线路覆盖率 80.5 保存在某个变量中。于是写了一个bash脚本UTreport.sh文件

#!/usr/bin/env bash report = "$(lcov --summary coverage/lcov.info)" echo The value of the report $report

但是这个脚本文件会引发错误。

UTreport.sh: line 2: report: command not found The value of the report

有没有办法获得这个值?

标签: bashshellshlcov

解决方案


推荐阅读