From 60c7fdfe680401a3f2fad54e256d20712227961b Mon Sep 17 00:00:00 2001 From: Scott R Charlton Date: Tue, 15 Jul 2014 03:49:34 +0000 Subject: [PATCH] Use phrGetErrorStrings.valgrind-leak.R.in in place of phreeqc.R.in when executing 'make check' -> 'R CMD check --as-cran' which produces (cran/)phreeqc.Rcheck/phreeqc-Ex.R and is checked in as leak-Ex.R (only includes the phrGetErrorStrings example). run using: R -d "valgrind --tool=memcheck --leak-check=full" --vanilla < leak-Ex.R and running the full set of examples: R -d "valgrind --tool=memcheck --leak-check=full" --vanilla < (cran/)phreeqc.Rcheck/phreeqc-Ex.R git-svn-id: svn://136.177.114.72/svn_GW/IPhreeqc/trunk@8844 1feff8c3-07ed-0310-ac33-dd36852eb9cd --- R/leak-Ex.R | 51 + R/phrGetErrorStrings.valgrind-leak.R.in | 1503 +++++++++++++++++++++++ 2 files changed, 1554 insertions(+) create mode 100644 R/leak-Ex.R create mode 100644 R/phrGetErrorStrings.valgrind-leak.R.in diff --git a/R/leak-Ex.R b/R/leak-Ex.R new file mode 100644 index 00000000..8e8f172c --- /dev/null +++ b/R/leak-Ex.R @@ -0,0 +1,51 @@ +pkgname <- "phreeqc" +source(file.path(R.home("share"), "R", "examples-header.R")) +options(warn = 1) +base::assign(".ExTimings", "phreeqc-Ex.timings", pos = 'CheckExEnv') +base::cat("name\tuser\tsystem\telapsed\n", file=base::get(".ExTimings", pos = 'CheckExEnv')) +base::assign(".format_ptime", +function(x) { + if(!is.na(x[4L])) x[1L] <- x[1L] + x[4L] + if(!is.na(x[5L])) x[2L] <- x[2L] + x[5L] + options(OutDec = '.') + format(x[1L:3L], digits = 7L) +}, +pos = 'CheckExEnv') + +### * +library('phreeqc') + +base::assign(".oldSearch", base::search(), pos = 'CheckExEnv') +cleanEx() +nameEx("phrGetErrorStrings") +### * phrGetErrorStrings + +flush(stderr()); flush(stdout()) + +base::assign(".ptime", proc.time(), pos = "CheckExEnv") +### Name: phrGetErrorStrings +### Title: Retrieve error string messages. +### Aliases: phrGetErrorStrings + +### ** Examples + +# loaddatabase should fail +n <- try(phrLoadDatabase("missing.dat"), silent = TRUE) +# if n is non-NULL display error string +if (!is.null(n)) phrGetErrorStrings() + + + +base::assign(".dptime", (proc.time() - get(".ptime", pos = "CheckExEnv")), pos = "CheckExEnv") +base::cat("phrGetErrorStrings", base::get(".format_ptime", pos = 'CheckExEnv')(get(".dptime", pos = "CheckExEnv")), "\n", file=base::get(".ExTimings", pos = 'CheckExEnv'), append=TRUE, sep="\t") +### *