From d408e9acdd1f2676958d569114d5c86c825e1cb3 Mon Sep 17 00:00:00 2001 From: Matthew Fidler Date: Sun, 23 Jun 2024 08:40:41 -0500 Subject: [PATCH] Error with wd specified and modName not specified --- NEWS.md | 4 ++++ R/rxode2.R | 4 ++++ tests/testthat/test-backward.R | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/NEWS.md b/NEWS.md index a725a4c8e..ebad31f98 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,5 +1,9 @@ # rxode2 (development version) +## Breaking Changes + +- Error when specifying `wd` without `modName` + # rxode2 2.1.3 ## Bug fixes diff --git a/R/rxode2.R b/R/rxode2.R index ab880b93a..646826db8 100644 --- a/R/rxode2.R +++ b/R/rxode2.R @@ -277,6 +277,10 @@ rxode2 <- # nolint verbose = FALSE, fullPrint=getOption("rxode2.fullPrint", FALSE), envir=parent.frame()) { + if (!missing(wd) && missing(modName)) { + stop("working directory specified, but modName not declared, need to specify modName to create rxode2 c-files as a sub-directory of `wd`", + call.=FALSE) + } rxode2parse::.udfEnvSet(envir) assignInMyNamespace(".rxFullPrint", fullPrint) rxSuppressMsg() diff --git a/tests/testthat/test-backward.R b/tests/testthat/test-backward.R index 0b1a0b774..c974f1db5 100644 --- a/tests/testthat/test-backward.R +++ b/tests/testthat/test-backward.R @@ -1,5 +1,11 @@ rxTest({ + test_that("error with wd specified but modName not specified", { + +expect_error(rxode2("cp<-cent/vc;d/dt(gutcp)<--ka*gutcp;d/dt(cent)<-(ka*gutcp)-q/vc*cent+q/vp*pericp-((vmax*cp)/vc)/(km+cp);d/dt(pericp)<-cent*q/vc-q/vp*pericp;f(gutcp)=bio;alag(gutcp)<-lag;gutcp(0)<-0;cent(0)<-0;pericp(0)<-0;", wd=getwd())) + + }) + ## Dynmodel routines ode <- " dose=200;