Skip to content

Commit 968c12b

Browse files
committed
Merge pull request #198 from RcppCore/feature/binary-build-tests
Feature/binary build tests
2 parents 3568d2b + 44dd19f commit 968c12b

29 files changed

+288
-62
lines changed

.Rinstignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
inst/doc/Makefile
22
inst/doc/jss.bst
33
inst/doc/RJournal.sty
4+
inst/unitTests/src

ChangeLog

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
2014-11-02 Dirk Eddelbuettel <edd@debian.org>
22

3+
* inst/unitTests/RcppTestA: Rename to inst/unitTests/testRcppPackage
4+
* inst/unitTests/testRcppPackage: Updated throughout
5+
36
* inst/include/Rcpp/Rmath.h: As suggested by Kevin, test for R_VERSION
47
via #define to conditon on R >= 3.1.2 -- this does not require a hard
58
constraint in DESCRIPTION yet on newer R will get R::[dpq]nbinom_mu()

inst/unitTests/RcppTestA/DESCRIPTION

Lines changed: 0 additions & 12 deletions
This file was deleted.

inst/unitTests/RcppTestA/NAMESPACE

Lines changed: 0 additions & 1 deletion
This file was deleted.

inst/unitTests/RcppTestA/R/rcpp_hello_world.R

Lines changed: 0 additions & 3 deletions
This file was deleted.

inst/unitTests/RcppTestA/src/rcpp_hello_world.cpp

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

2323
.runThisTest <- Sys.getenv("RunAllRcppTests") == "yes"
2424

25-
.client.package <- function( pkg = "RcppTestA" ){
25+
.client.package <- function(pkg = "testRcppPackage") {
2626
td <- tempfile()
2727
cwd <- getwd()
28-
dir.create( td )
29-
file.copy( system.file( "unitTests", pkg, package = "Rcpp" ) , td, recursive = TRUE)
30-
setwd( td )
31-
on.exit( { setwd( cwd) ; unlink( td, recursive = TRUE ) } )
32-
R <- shQuote( file.path( R.home( component = "bin" ), "R" ))
33-
cmd <- paste( R , "CMD build", pkg )
34-
system( cmd )
35-
dir.create( "templib" )
36-
install.packages( paste( pkg, "_1.0.tar.gz", sep = "" ), "templib", repos = NULL, type = "source" )
37-
require( pkg, "templib", character.only = TRUE )
28+
dir.create(td)
29+
file.copy(system.file("unitTests", pkg, package = "Rcpp"), td, recursive = TRUE)
30+
setwd(td)
31+
on.exit( { setwd(cwd); unlink(td, recursive = TRUE) } )
32+
R <- shQuote(file.path( R.home(component = "bin"), "R"))
33+
cmd <- paste(R, "CMD build", pkg)
34+
system(cmd)
35+
dir.create("templib")
36+
install.packages(paste0(pkg, "_0.1.0.tar.gz"), "templib", repos = NULL, type = "source")
37+
require(pkg, lib.loc = "templib", character.only = TRUE)
38+
hello_world <- get("rcpp_hello_world", asNamespace(pkg))
39+
checkEquals(hello_world(), list(c("foo", "bar"), c(0.0, 1.0)),
40+
msg = "code from client package")
3841

39-
hello_world <- get( "rcpp_hello_world", asNamespace( pkg ) )
40-
checkEquals( hello_world(), list( c("foo", "bar"), c(0.0, 1.0) ), msg = "code from client package" )
41-
42-
checkException( .Call("hello_world_ex", PACKAGE = pkg ), msg = "exception in client package" )
42+
checkException(.Call("hello_world_ex", PACKAGE = pkg), msg = "exception in client package")
4343
}
4444

45-
if ( .runThisTest && ! .onWindows ) {
46-
test.client.packageA <- function(){
47-
.client.package( "RcppTestA" )
45+
if (.runThisTest && ! .onWindows) {
46+
test.client.testRcppPackage <- function() {
47+
.client.package("testRcppPackage")
4848
}
4949
}

0 commit comments

Comments
 (0)