1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
|
context("Dependencies")
test_that("Warned about dependency versions", {
# Should give a warning about grid version
expect_warning(load_all("testImportVersion"), "Need grid >=")
unload("testImportVersion")
# TODO: Add check for NOT giving a warning about compiler version
# Not possible with testthat?
})
test_that("Error on missing dependencies", {
# Should give a warning about missing package
expect_error(regexp = "Dependency package[(]s[)] 'missingpackage' not available",
expect_warning(regexp = "missingpackage not available",
load_all("testImportMissing")))
# Loading process will be partially done; unload it
unload("testImportMissing")
})
test_that("Packages in depends are required", {
load_all("testDependMissing")
expect_true("package:bitops" %in% search())
unload("testDependMissing")
detach("package:bitops", unload = TRUE)
})
test_that("Parse dependencies", {
deps <- parse_deps("\nhttr (< 2.1),\nRCurl (>= 3),\nutils (== 2.12.1),\ntools,\nR (>= 2.10),\nmemoise")
expect_equal(nrow(deps), 5)
expect_false("R" %in% deps$name)
expect_equal(deps$compare, c("<", ">=", "==", NA, NA))
expect_equal(deps$version, c("2.1", "3", "2.12.1", NA, NA))
# Invalid version specifications
expect_error(parse_deps("\nhttr (< 2.1),\nRCurl (3.0)"))
expect_error(parse_deps("\nhttr (< 2.1),\nRCurl ( 3.0)"))
expect_error(parse_deps("\nhttr (< 2.1),\nRCurl (==3.0)"))
expect_error(parse_deps("\nhttr (< 2.1),\nRCurl (==3.0 )"))
expect_error(parse_deps("\nhttr (< 2.1),\nRCurl ( ==3.0)"))
# This should be OK (no error)
deps <- parse_deps("\nhttr (< 2.1),\nRCurl (== 3.0.1)")
expect_equal(deps$compare, c("<", "=="))
expect_equal(deps$version, c("2.1", "3.0.1"))
})
test_that("Declared dependencies are added to .Depends object", {
load_all("testDependsExists")
expect_equal(get(".Depends", "package:testDependsExists", inherits = FALSE),
"httr")
unload("testDependsExists")
})
|