simplecov:提取覆盖率
simplecov: extract coverage percentage
我运行喜欢这样的simplecov
# test/test_helper.rb
require 'simplecov'
SimpleCov.start do
add_filter "/test/"
coverage_dir "/tmp/coverage/"
end
代替,或者除了打印这个
Coverage report generated for Unit Tests to /tmp/coverage. 30 / 31 LOC (96.77%) covered.
如何告诉 ruby/simplecov 将数字 96.77 保存到环境变量或文件中。
到目前为止我想到了
SimpleCov.at_exit do
IO.write('/tmp/result_tests_coverage', 'work-in-progress')
end
这有点乱七八糟,但这对我有用。 (这个在bash,调用生成覆盖率的命令,在文件中有%符号...)
<command> | tee -a log/coverage.log
coverage_string="$(grep "Coverage report generated" log/coverage.log)"
[[ "$coverage_string" =~ ([[:digit:]]+\.[[:digit:]]+\%) ]] && echo ${BASH_REMATCH[1]} > percent.txt
我运行喜欢这样的simplecov
# test/test_helper.rb
require 'simplecov'
SimpleCov.start do
add_filter "/test/"
coverage_dir "/tmp/coverage/"
end
代替,或者除了打印这个
Coverage report generated for Unit Tests to /tmp/coverage. 30 / 31 LOC (96.77%) covered.
如何告诉 ruby/simplecov 将数字 96.77 保存到环境变量或文件中。
到目前为止我想到了
SimpleCov.at_exit do
IO.write('/tmp/result_tests_coverage', 'work-in-progress')
end
这有点乱七八糟,但这对我有用。 (这个在bash,调用生成覆盖率的命令,在文件中有%符号...)
<command> | tee -a log/coverage.log
coverage_string="$(grep "Coverage report generated" log/coverage.log)"
[[ "$coverage_string" =~ ([[:digit:]]+\.[[:digit:]]+\%) ]] && echo ${BASH_REMATCH[1]} > percent.txt