1 2## Copyright (C) 2014 - 2019 Dirk Eddelbuettel 3## 4## This file is part of Rcpp. 5## 6## Rcpp is free software: you can redistribute it and/or modify it 7## under the terms of the GNU General Public License as published by 8## the Free Software Foundation, either version 2 of the License, or 9## (at your option) any later version. 10## 11## Rcpp is distributed in the hope that it will be useful, but 12## WITHOUT ANY WARRANTY; without even the implied warranty of 13## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14## GNU General Public License for more details. 15## 16## You should have received a copy of the GNU General Public License 17## along with Rcpp. If not, see <http://www.gnu.org/licenses/>. 18 19.onLinux <- .Platform$OS.type == "unix" && unname(Sys.info()["sysname"]) == "Linux" 20 21.onTravis <- Sys.getenv("TRAVIS") != "" 22 23.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes" && Sys.getenv("RunVerboseRcppTests") == "yes" 24 25##test.binary.testRcppPackage <- function() { 26 27if (! .runThisTest) exit_file("Set 'RunVerboseRcppTests' and 'RunAllRcppTests' to 'yes' to run.") 28if (! .onLinux) exit_file("Only running this on Linux.'") 29if (.onTravis) exit_file("Not running on Travis.") 30 31exit_file("Skipping for now as underlying binary needs to be updated.") 32 33debpkg <- "r-cran-testrcpppackage" 34rpkg <- "testRcppPackage" 35 36## R calls it i686 or x86_64; Debian/Ubuntu call it i386 or amd64 37arch <- switch(unname(Sys.info()["machine"]), "i686"="i386", "x86_64"="amd64") 38 39## filename of pre-built -- easier with tinytest as bin/ is a subdir of current dir 40debfile <- file.path("bin", arch, paste0(debpkg, "_0.1.0-1_", arch, ".deb")) 41 42if (! file.exists(debfile)) exit_file("Binary not found, skipping 'test_binary_package.R' tests") 43 44system(paste("sudo dpkg -i", debfile)) 45 46## R> testRcppPackage:::rcpp_hello_world() 47## [[1]] 48## [1] "foo" "bar" 49 50## [[2]] 51## [1] 0 1 52 53## R> 54 55require(rpkg, lib.loc = "/usr/lib/R/site-library", character.only = TRUE) 56hello_world <- get("rcpp_hello_world", asNamespace(rpkg)) 57 58expect_equal(hello_world(), list(c("foo", "bar"), c(0.0, 1.0)), 59 msg = "code from binary package") 60 61system(paste("sudo dpkg --purge", debpkg)) 62