Skip to content

Commit

Permalink
Merge pull request #881 from pearsonca/master
Browse files Browse the repository at this point in the history
fix: #770, get_cmdstan_flags('STANCFLAGS') in recursive make extraneo…
  • Loading branch information
andrjohns authored Nov 29, 2023
2 parents 357a07e + df893bb commit bc60419
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ get_cmdstan_flags <- function(flag_name) {
cmdstan_path <- cmdstanr::cmdstan_path()
flags <- wsl_compatible_run(
command = "make",
args = c(paste0("print-", flag_name)),
args = c("-s", paste0("print-", flag_name)),
wd = cmdstan_path
)$stdout

Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,13 @@ test_that("as_mcmc.list() works", {
"Currently only CmdStanMCMC objects can be converted to mcmc.list"
)
})

test_that("get_cmdstan_flags() can be used recursively in `make`", {
mkfile <- normalizePath(test_path("testdata", "Makefile"))
nonrecursive_flags <- get_cmdstan_flags("STANCFLAGS")
stdo <- processx::run(
command = "make", args = sprintf("--file=%s", mkfile)
)$stdout
recursive_flags <- readLines(textConnection(stdo))
expect_equal(nonrecursive_flags, recursive_flags)
})
3 changes: 3 additions & 0 deletions tests/testthat/testdata/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

test:
@$(R_HOME)/bin/Rscript --vanilla -e 'cat(cmdstanr:::get_cmdstan_flags("STANCFLAGS"))'

0 comments on commit bc60419

Please sign in to comment.