【问题标题】:How to display testthat results in the travis log?如何在 travis 日志中显示测试结果?
【发布时间】:2017-08-24 15:25:23
【问题描述】:

我正在 travis 上测试一个名为 eutradeflows 的 R 包。该软件包包含用 testthat 编程的测试,我想在 travis 中查看devtools::test() 的输出。

主要的 travis 日志中有一行说:

Status: 4 NOTEs
See  ‘/home/travis/build/stix-global/eutradeflows/eutradeflows.Rcheck/00check.log’
for details

this answer,我了解到可以在 travis 日志中显示文件。在 .travis.yml 中,我要求 travis 在测试后打印该文件:

- cat /home/travis/build/stix-global/eutradeflows/eutradeflows.Rcheck/00check.log

但它不包含 testthat 测试的结果。

如何在 travis 中显示 testthat 的输出?

这点特别重要,因为我在测试中有skip 指令,我想知道哪些测试被跳过了。

【问题讨论】:

  • 这个.travis.yml 可能有答案。成功后添加- Rscript -e 'devtools::install();devtools::test()'

标签: r travis-ci testthat


【解决方案1】:

显示testthat 测试的结果, 将此添加到.travis.yml:

r_binary_packages:
  - devtools
  - roxygen2

after_success:
  - Rscript -e 'devtools::install();devtools::test()'

【讨论】:

    【解决方案2】:

    我使用了稍微重一点的重量来确保构建和测试只发生一次。在构建矩阵中,我将以下内容放入脚本中

       script: |
         R CMD build .
         R CMD INSTALL RMINC*.tar.gz
         R CMD check --as-cran --no-install RMINC*.tar.gz
         cat RMINC.Rcheck/00check.log         
         Rscript -e "\
         testr <- devtools::test(); \
         testr <- as.data.frame(testr); \
         if(any(testr\$error) || any(testr\$warning > 0)) \
           stop('Found failing tests') \
         "
         pass=$?
         if [[ $pass -ne 0 || $(grep -i "WARNING\|ERROR" RMINC.Rcheck/00check.log) != "" ]]; then
           (exit 1)
         else
           (exit 0)
         fi
    

    这会运行 R CMD 检查并正确显示构建输出,在检查或测试阶段出现警告或错误时失败。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-28
      • 1970-01-01
      • 1970-01-01
      • 2019-07-04
      • 2017-10-03
      • 2018-05-29
      相关资源
      最近更新 更多