[Distr-commits] r929 - in branches/distr-2.6/pkg/distr: . inst tests tests/unitTests
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Dec 4 12:02:11 CET 2013
Author: kroisand
Date: 2013-12-04 12:02:11 +0100 (Wed, 04 Dec 2013)
New Revision: 929
Added:
branches/distr-2.6/pkg/distr/inst/unitTests/
branches/distr-2.6/pkg/distr/tests/doSvUnit.R
branches/distr-2.6/pkg/distr/tests/unitTests/
branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunMinimum.R
branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunMinimum.save
branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunOperatorsMethods.R
branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunOperatorsMethods.save
branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot.R
branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot1.save
branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot2.save
branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot3.save
Modified:
branches/distr-2.6/pkg/distr/DESCRIPTION
Log:
long-running tests with large pre-calculated results successfully implemented
Modified: branches/distr-2.6/pkg/distr/DESCRIPTION
===================================================================
--- branches/distr-2.6/pkg/distr/DESCRIPTION 2013-09-18 11:25:52 UTC (rev 928)
+++ branches/distr-2.6/pkg/distr/DESCRIPTION 2013-12-04 11:02:11 UTC (rev 929)
@@ -9,7 +9,7 @@
"cph")), person("R Core Team", role = c("ctb", "cph"), comment="for source file ks.c/
routines 'pKS2' and 'pKolmogorov2x'"))
Depends: R(>= 2.14.0), methods, graphics, startupmsg, sfsmisc, SweaveListingUtils
-Suggests: distrEx
+Suggests: distrEx, svUnit (>= 0.7-11)
Imports: stats
ByteCompile: yes
Encoding: latin1
Added: branches/distr-2.6/pkg/distr/tests/doSvUnit.R
===================================================================
--- branches/distr-2.6/pkg/distr/tests/doSvUnit.R (rev 0)
+++ branches/distr-2.6/pkg/distr/tests/doSvUnit.R 2013-12-04 11:02:11 UTC (rev 929)
@@ -0,0 +1,73 @@
+# we only run the tests, if svUnit is available
+if (require(svUnit, quietly=TRUE)) {
+ pkg <- "distr"
+ require("distr")
+
+ # we must investigate whether R CMD check is running or not
+ # and if the check is running, whether a time limit exists
+ RCMDCHECK <- FALSE
+ RCMDCHECKCRAN <- FALSE
+
+ for (actual.name in names(Sys.getenv())) {
+ if (substr(actual.name, 1, 9) == "_R_CHECK_") {
+ RCMDCHECK <- TRUE
+
+ if (actual.name == "_R_CHECK_TIMINGS_") {
+ RCMDCHECKCRAN <- (as.numeric(Sys.getenv("_R_CHECK_TIMINGS_")) > 0)
+ }
+ }
+ }
+
+ # we must determine the path for tests in the installation and outside installation
+ if (RCMDCHECK) {
+ ## Path to unit tests for R CMD check
+ ## PKG.Rcheck/tests/../PKG/unitTests
+ ## PKG.Rcheck/tests/unitTests
+
+ # we determine the two paths
+ pathTestsInInstallation <- system.file(package=pkg, "unitTests")
+ pathTestsOutsideInstallation <- file.path(getwd(), "unitTests")
+ } else {
+ ## Path to unit tests for standalone running as script with "PKG/tests" as working directory
+ ## PKG/tests/../inst/unitTests
+ ## PKG/tests/unitTests
+
+ # we determine the two paths
+ pathTestsInInstallation <- file.path(getwd(), "..", "inst", "unitTests")
+ pathTestsOutsideInstallation <- file.path(getwd(), "unitTests")
+ }
+
+ print(pathTestsInInstallation)
+ print(pathTestsOutsideInstallation)
+
+ # it depends whether we want to skip the long running tests or not
+ if (RCMDCHECKCRAN) {
+ mypkgSuite <- svSuiteList(packages=pkg, dirs=pathTestsInInstallation)
+ } else {
+ mypkgSuite <- svSuiteList(packages=pkg, dirs=c(pathTestsInInstallation, pathTestsOutsideInstallation))
+ }
+
+ unlink("report.txt") # Make sure we generate a new report
+
+ print(svSuiteList(packages=FALSE, dirs=c(pathTestsInInstallation, pathTestsOutsideInstallation)))
+
+ runTest(mypkgSuite, name = pkg) # Run them...
+
+ ## makeTestListFromExamples is in svUnit 0.7.8 or more
+ #doRunExamples <- TRUE
+ #svUnitVersion = as.integer(strsplit(installed.packages()[which(installed.packages()[, 'Package'] == "svUnit"), "Version"], "[\\.-]")[[1]])
+ #if (svUnitVersion[1] == 0) {
+ # if (svUnitVersion[2] < 7) {
+ # doRunExamples <- FALSE
+ # } else {
+ # if (svUnitVersion[2] == 7)
+ # doRunExamples <- svUnitVersion[3] >= 8
+ # }
+ #}
+ #if(doRunExamples)
+ # runTest(tryCatch(makeTestListFromExamples(pkg, "../../pkg/man/"), error=function(e) NULL))
+
+
+ protocol(Log(), type = "text", file = "report.txt") # ... and write report
+}
+
Added: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunMinimum.R
===================================================================
--- branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunMinimum.R (rev 0)
+++ branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunMinimum.R 2013-12-04 11:02:11 UTC (rev 929)
@@ -0,0 +1,19 @@
+# test for equality of the saved result and the actual result of a dontrun example
+test.minimum <- function() {
+ # we compute the actual object
+ runit.dontrunMinimum.actual <- Minimum(Norm(), Pois())
+
+ # we load the saved object for comparison
+ # we assume that this test is called from within the script in the upper directory
+ load("unitTests/runit.dontrunMinimum.save")
+
+ # we compare the stored result with the calculated one
+ # (a comparison with identical (ignoring the environment) gives FALSE...
+ result <- all.equal(runit.dontrunMinimum.actual,
+ runit.dontrunMinimum.save)
+
+ # we check whether the result is TRUE and if not, we write the message
+ # coming from the result
+ checkEquals(is.logical(result) && result, TRUE, msg=paste(result, sep="", collapse="\n"))
+}
+
Added: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunMinimum.save
===================================================================
(Binary files differ)
Property changes on: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunMinimum.save
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunOperatorsMethods.R
===================================================================
--- branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunOperatorsMethods.R (rev 0)
+++ branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunOperatorsMethods.R 2013-12-04 11:02:11 UTC (rev 929)
@@ -0,0 +1,21 @@
+# test for equality of the saved result and the actual result of a dontrun example
+test.operatorsMethods <- function() {
+ # we compute the actual result
+ N <- Norm(0,3)
+ P <- Pois(4)
+ runit.dontrunOperatorsMethods.actual <- N ^ P
+
+ # we load the stored result
+ # we assume that this test is called from within the script in the upper directory
+ load("unitTests/runit.dontrunOperatorsMethods.save")
+
+ # we compare the stored result with the calculated one
+ # (a comparison with identical (ignoring the environment) gives FALSE...
+ result <- all.equal(runit.dontrunOperatorsMethods.actual,
+ runit.dontrunOperatorsMethods.save)
+
+ # we check whether the result is TRUE and if not, we write the message
+ # coming from the result
+ checkEquals(is.logical(result) && result, TRUE, msg=paste(result, sep="", collapse="\n"))
+}
+
Added: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunOperatorsMethods.save
===================================================================
(Binary files differ)
Property changes on: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunOperatorsMethods.save
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot.R
===================================================================
--- branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot.R (rev 0)
+++ branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot.R 2013-12-04 11:02:11 UTC (rev 929)
@@ -0,0 +1,68 @@
+# test for equality of the saved result and the actual result of a dontrun example
+test.qqplot1 <- function() {
+ # we compute the actual result
+ P <- Pois(5)
+ B <- Binom(size=2000,prob=5/2000)
+ runit.dontrunQQPlot1.actual <- qqplot(B,P, nosym.pCI=TRUE)
+
+ # we load the stored result
+ # we assume that this test is called from within the script in the upper directory
+ load("unitTests/runit.dontrunQQPlot1.save")
+
+ # we compare the stored result with the calculated one
+ # (a comparison with identical (ignoring the environment) gives FALSE...
+ result <- all.equal(runit.dontrunQQPlot1.actual,
+ runit.dontrunQQPlot1.save)
+
+ # we check whether the result is TRUE and if not, we write the message
+ # coming from the result
+ checkEquals(is.logical(result) && result, TRUE, msg=paste(result, sep="", collapse="\n"))
+}
+
+
+# test for equality of the saved result and the actual result of a dontrun example
+test.qqplot2 <- function() {
+ # we compute the actual result
+ mylist <- UnivarLebDecDistribution(discretePart=Binom(3,.3), acPart=Norm(2,2),
+ acWeight=11/20)
+ mylist2 <- mylist+0.1
+
+ runit.dontrunQQPlot2.actual <- qqplot(mylist,mylist2,nosym.pCI=TRUE)
+
+ # we load the stored result
+ # we assume that this test is called from within the script in the upper directory
+ load("unitTests/runit.dontrunQQPlot2.save")
+
+ # we compare the stored result with the calculated one
+ # (a comparison with identical (ignoring the environment) gives FALSE...
+ result <- all.equal(runit.dontrunQQPlot2.actual,
+ runit.dontrunQQPlot2.save)
+
+ # we check whether the result is TRUE and if not, we write the message
+ # coming from the result
+ checkEquals(is.logical(result) && result, TRUE, msg=paste(result, sep="", collapse="\n"))
+}
+
+
+# test for equality of the saved result and the actual result of a dontrun example
+test.qqplot3 <- function() {
+ # we compute the actual result
+ mylist3 <- UnivarMixingDistribution(Unif(0,0.3),Unif(0.6,1),mixCoeff=c(0.8,0.2))
+ mylist4 <- UnivarMixingDistribution(Unif(0,0.3),Unif(0.6,1),mixCoeff=c(0.6,0.4))
+
+ runit.dontrunQQPlot3.actual <- qqplot(mylist3,mylist4,nosym.pCI=TRUE)
+
+ # we load the stored result
+ # we assume that this test is called from within the script in the upper directory
+ load("unitTests/runit.dontrunQQPlot3.save")
+
+ # we compare the stored result with the calculated one
+ # (a comparison with identical (ignoring the environment) gives FALSE...
+ result <- all.equal(runit.dontrunQQPlot3.actual,
+ runit.dontrunQQPlot3.save)
+
+ # we check whether the result is TRUE and if not, we write the message
+ # coming from the result
+ checkEquals(is.logical(result) && result, TRUE, msg=paste(result, sep="", collapse="\n"))
+}
+
Added: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot1.save
===================================================================
(Binary files differ)
Property changes on: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot1.save
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot2.save
===================================================================
(Binary files differ)
Property changes on: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot2.save
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Added: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot3.save
===================================================================
(Binary files differ)
Property changes on: branches/distr-2.6/pkg/distr/tests/unitTests/runit.dontrunQQPlot3.save
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
More information about the Distr-commits
mailing list