diff options
Diffstat (limited to 'tests/testthat')
-rw-r--r-- | tests/testthat/print_mmkin_sfo_sfo_dmta.txt | 0 | ||||
-rw-r--r-- | tests/testthat/setup_script.R | 12 | ||||
-rw-r--r-- | tests/testthat/test_compiled_symbols.R | 58 | ||||
-rw-r--r-- | tests/testthat/test_dmta.R | 11 |
4 files changed, 70 insertions, 11 deletions
diff --git a/tests/testthat/print_mmkin_sfo_sfo_dmta.txt b/tests/testthat/print_mmkin_sfo_sfo_dmta.txt new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/tests/testthat/print_mmkin_sfo_sfo_dmta.txt diff --git a/tests/testthat/setup_script.R b/tests/testthat/setup_script.R index 4e2f76ab..b2147fbe 100644 --- a/tests/testthat/setup_script.R +++ b/tests/testthat/setup_script.R @@ -110,3 +110,15 @@ dfop_saem_1 <- saem(mmkin_dfop_1, quiet = TRUE, transformations = "mkin", no_random_effect = c("parent_0", "g_qlogis")) parallel::stopCluster(cl) + +# Preprocess dimethenamid data +dmta_ds <- lapply(1:7, function(i) { + ds_i <- dimethenamid_2018$ds[[i]]$data + ds_i[ds_i$name == "DMTAP", "name"] <- "DMTA" + ds_i$time <- ds_i$time * dimethenamid_2018$f_time_norm[i] + ds_i +}) +names(dmta_ds) <- sapply(dimethenamid_2018$ds, function(ds) ds$title) +dmta_ds[["Elliot"]] <- rbind(dmta_ds[["Elliot 1"]], dmta_ds[["Elliot 2"]]) +dmta_ds[["Elliot 1"]] <- dmta_ds[["Elliot 2"]] <- NULL + diff --git a/tests/testthat/test_compiled_symbols.R b/tests/testthat/test_compiled_symbols.R new file mode 100644 index 00000000..2828951d --- /dev/null +++ b/tests/testthat/test_compiled_symbols.R @@ -0,0 +1,58 @@ +context("Use of precompiled symbols in mkinpredict") + +test_that("We can safely use compiled code", { + + # Generate temporary DLL + sfo_sfo_tmp <- mkinmod(DMTA = mkinsub("SFO", to = "M23"), + M23 = mkinsub("SFO")) + + # Generate temporary DLL and move to user specified location + if (!dir.exists("test_dlls")) dir.create("test_dlls") + sfo_sfo_dll <- mkinmod(DMTA = mkinsub("SFO", to = "M23"), + M23 = mkinsub("SFO"), + dll_dir = "test_dlls", + name = "sfo_sfo", + unload = TRUE, overwrite = TRUE + ) + + if (Sys.info()["sysname"] != "Windows") { + # mclapply using forks + expect_known_output( + mmkin(list(sfo_sfo_dll), dmta_ds, cores = n_cores, quiet = TRUE), + "print_mmkin_sfo_sfo_dmta.txt" + ) + + # cluster describing itself as socket cluster + cl_fork <- parallel::makeForkCluster(n_cores) + expect_known_output( + mmkin(list(sfo_sfo_tmp), dmta_ds, cluster = cl_fork, quiet = TRUE), + "print_mmkin_sfo_sfo_dmta.txt" + ) + expect_known_output( + mmkin(list(sfo_sfo_dll), dmta_ds, cluster = cl_fork, quiet = TRUE), + "print_mmkin_sfo_sfo_dmta.txt" + ) + parallel::stopCluster(cl_fork) + } + + # PSOCK cluster + cl_psock <- parallel::makePSOCKcluster(n_cores) + expect_known_output( + mmkin(list(sfo_sfo_tmp), dmta_ds, cluster = cl_psock, quiet = TRUE), + "print_mmkin_sfo_sfo_dmta.txt" + ) + expect_known_output( + mmkin(list(sfo_sfo_dll), dmta_ds, cluster = cl_psock, quiet = TRUE), + "print_mmkin_sfo_sfo_dmta.txt" + ) + parallel::stopCluster(cl_psock) + + # Clean up + if (Sys.info()["sysname"] != "Windows") { + expect_true(file.remove("test_dlls/sfo_sfo.dll")) + } else { + expect_true(file.remove("test_dlls/sfo_sfo.so")) + } + expect_true(file.remove("test_dlls")) +}) + diff --git a/tests/testthat/test_dmta.R b/tests/testthat/test_dmta.R index 825c6e80..cd6de341 100644 --- a/tests/testthat/test_dmta.R +++ b/tests/testthat/test_dmta.R @@ -1,16 +1,5 @@ context("Dimethenamid data from 2018") -# Data -dmta_ds <- lapply(1:7, function(i) { - ds_i <- dimethenamid_2018$ds[[i]]$data - ds_i[ds_i$name == "DMTAP", "name"] <- "DMTA" - ds_i$time <- ds_i$time * dimethenamid_2018$f_time_norm[i] - ds_i -}) -names(dmta_ds) <- sapply(dimethenamid_2018$ds, function(ds) ds$title) -dmta_ds[["Elliot"]] <- rbind(dmta_ds[["Elliot 1"]], dmta_ds[["Elliot 2"]]) -dmta_ds[["Elliot 1"]] <- dmta_ds[["Elliot 2"]] <- NULL - test_that("Different backends get consistent results for DFOP tc, dimethenamid data", { skip_on_cran() # Time constraints |