From 520d22bb0745db548a7bc70bb9d512bda386e3a0 Mon Sep 17 00:00:00 2001 From: hb Date: Mon, 11 Jul 2016 17:12:47 -0700 Subject: [PATCH] ROBUSTNESS: Now the digest DLL is unloaded when the package is unloaded --- DESCRIPTION | 4 ++-- R/zzz.R | 3 +++ tests/load-unload.R | 25 +++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 R/zzz.R create mode 100644 tests/load-unload.R diff --git a/DESCRIPTION b/DESCRIPTION index e27957e..aca0247 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -4,8 +4,8 @@ Author: Dirk Eddelbuettel with contributions Mario Frasca, Bryan Lewis, Murray Stokely, Hannes Muehleisen, Duncan Murdoch, Jim Hester, Wush Wu, Qiang Kou, Thierry Onkelinx, Michel Lang and Viliam Simko. -Version: 0.6.9.3 -Date: 2016-05-25 +Version: 0.6.9.4 +Date: 2016-07-11 Maintainer: Dirk Eddelbuettel Title: Create Compact Hash Digests of R Objects Description: Implementation of a function 'digest()' for the creation diff --git a/R/zzz.R b/R/zzz.R new file mode 100644 index 0000000..759c07f --- /dev/null +++ b/R/zzz.R @@ -0,0 +1,3 @@ +.onUnload <- function (libpath) { + library.dynam.unload("digest", libpath) +} diff --git a/tests/load-unload.R b/tests/load-unload.R new file mode 100644 index 0000000..c57553a --- /dev/null +++ b/tests/load-unload.R @@ -0,0 +1,25 @@ +## Test that package can be loaded and unloaded cleanly + +dlls0 <- getLoadedDLLs() +stopifnot(!is.element("digest", loadedNamespaces()), + !is.element("digest", names(dlls0))) + +loadNamespace("digest") +dlls1 <- getLoadedDLLs() +stopifnot(length(dlls1) == length(dlls0) + 1, + is.element("digest", names(dlls1))) + +unloadNamespace("digest") +dlls2 <- getLoadedDLLs() +stopifnot(length(dlls2) == length(dlls0), + !is.element("digest", names(dlls2))) + +library("digest") +dlls3 <- getLoadedDLLs() +stopifnot(length(dlls3) == length(dlls0) + 1, + is.element("digest", names(dlls3))) + +unloadNamespace("digest") +dlls4 <- getLoadedDLLs() +stopifnot(length(dlls4) == length(dlls0), + !is.element("digest", names(dlls4)))