簡體   English   中英

在travis上進行測試的測試期間使用load()從.RData文件加載數據

[英]Using load() to load data from an .RData file during a testthat test on travis

我正在使用testthat包與正在開發的R包一起運行單元測試。 我遇到了一種奇怪的情況,我無法弄清楚自己在做什么錯。

我正在嘗試加載一些測試數據(存儲在數據幀中)和一些預先計算的答案(再次存儲在數據幀中)以測試某些功能並比較結果。 我已經將兩組數據另存為.Rdata文件(在tests / testthat /目錄中),並且在使用load(file.path('filename.RData'))運行測試之前將它們加載到其中。

當我在計算機上運行測試時,測試運行正常。 但是當他們在travis上運行時,我得到了錯誤:

> test_check("mocapGrip")
  Error in readChar(con, 5L, useBytes = TRUE) : cannot open the connection
  Calls: test_check ... force -> source_file -> eval -> eval -> load -> readChar
  In addition: Warning message:
  In readChar(con, 5L, useBytes = TRUE) :
    cannot open compressed file 'extractedMarkerData.Rdata', probable reason 'No such file or directory'

我肯定會錯過一些非常簡單的東西,但是我已經嘗試了所有顯而易見的事情(指定目錄開始處的相對路徑等)。是否有人對如何獲取travis能夠加載這些文件有任何想法? ?

以下是令人討厭的testthat文件的內容:

library(mocapGrip)
context("distance calculationss")

load(file.path('extractedMarkerData.Rdata')) # markerDataHead
load(file.path('dist57.RData')) # dist57head
load(file.path('meanData.Rdata')) # meanDataHead

test_that("calculateDistances returns the correct distances", {
  expect_equal(mocapGrip:::calculateDistances(markerDataHead, c(5,7)), dist57head)
})

test_that("meanOnAxis returns the correct distances", {
  expect_equal(mocapGrip:::meanOnAxis(markerDataHead, c(0, 1, 2, 3, 4), axis ="Y"), meanDataHead)
})

確實確實很簡單:不區分大小寫的OS X默默地忽略了我輸入的大小寫錯誤(.Rdata與.RData),而travis正在運行的ubuntu系統區分大小寫,因此在搜索extractedMarkerData.RData時,發現extractMarkerData.Rdata不起作用(鑒於ubuntu區分大小寫,因此不起作用)。 已修復,現在一切都很好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM