【问题标题】:Skip a specific test file on travis in R在 R 中跳过 travis 上的特定测试文件
【发布时间】:2019-06-30 04:56:36
【问题描述】:

我的testing suite 由多个文件组成。我想在 travis 上跳过其中一个(与拟合贝叶斯模型有关的那个),因为它需要很多时间并且会失败。

我知道我可以使用testthat::skip_on_travis() 跳过特定测试。但是,这些在 test_that 块中工作。不幸的是,我希望跳过的部分(从herehere)主要在 test_that 块之外(并且模型拟合发生在测试之前)。

我尝试将模型拟合放在 test_that 块中,但随后其他块找不到模型。我也尝试了嵌套的 test_that 块,但这似乎不起作用......有什么想法吗?

【问题讨论】:

    标签: r travis-ci testthat rstan


    【解决方案1】:

    另一个似乎可行的选项是检查环境变量:

    if (Sys.getenv("USER") != "travis") {
      # tests to be executed...
    }
    

    另见此处: https://docs.travis-ci.com/user/environment-variables/#default-environment-variables

    【讨论】:

      【解决方案2】:

      在您的 testthat.R 文件中,您可以使用 filter 参数到 test_check 以便有条件地跳过整个文件。此机制可用于跳过 CRAN 或 Travis 上的长测试集合。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2018-04-30
        • 2015-01-04
        • 2014-04-24
        • 1970-01-01
        • 1970-01-01
        • 2021-12-23
        • 2022-01-05
        • 2018-06-15
        相关资源
        最近更新 更多