diff --git a/R/test-compiled-code.R b/R/test-compiled-code.R index d175a956f..bd83f0f26 100644 --- a/R/test-compiled-code.R +++ b/R/test-compiled-code.R @@ -253,6 +253,28 @@ run_cpp_tests <- function(package) { #' run_testthat_tests #' } #' +#' Assuming you have `useDynLib(, .registration = TRUE)` in your package's +#' `NAMESPACE` file, this implies having routine registration code of the form: +#' +#' ``` +#' // The definition for this function comes from the file 'src/test-runner.cpp', +#' // which is generated via `testthat::use_catch()`. +#' extern SEXP run_testthat_tests(); +#' +#' static const R_CallMethodDef callMethods[] = { +#' // other .Call method definitions, +#' {"run_testthat_tests", (DL_FUNC) &run_testthat_tests, 0}, +#' {NULL, NULL, 0} +#' }; +#' +#' void R_init_(DllInfo* dllInfo) { +#' R_registerRoutines(dllInfo, NULL, callMethods, NULL, NULL); +#' R_useDynamicSymbols(dllInfo, FALSE); +#' } +#' ``` +#' +#' replacing `` above with the name of your package, as appropriate. +#' #' See [Controlling Visibility](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Controlling-visibility) #' and [Registering Symbols](https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Registering-symbols) #' in the **Writing R Extensions** manual for more information. diff --git a/man/use_catch.Rd b/man/use_catch.Rd index 6b51243df..005f965f7 100644 --- a/man/use_catch.Rd +++ b/man/use_catch.Rd @@ -98,6 +98,27 @@ tests. \code{testthat} will look for a routine with one of the names: run_testthat_tests } +Assuming you have \verb{useDynLib(, .registration = TRUE)} in your package's +\code{NAMESPACE} file, this implies having routine registration code of the form: + +\if{html}{\out{
}}\preformatted{// The definition for this function comes from the file 'src/test-runner.cpp', +// which is generated via `testthat::use_catch()`. +extern SEXP run_testthat_tests(); + +static const R_CallMethodDef callMethods[] = \{ + // other .Call method definitions, + \{"run_testthat_tests", (DL_FUNC) &run_testthat_tests, 0\}, + \{NULL, NULL, 0\} +\}; + +void R_init_(DllInfo* dllInfo) \{ + R_registerRoutines(dllInfo, NULL, callMethods, NULL, NULL); + R_useDynamicSymbols(dllInfo, FALSE); +\} +}\if{html}{\out{
}} + +replacing \verb{} above with the name of your package, as appropriate. + See \href{https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Controlling-visibility}{Controlling Visibility} and \href{https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Registering-symbols}{Registering Symbols} in the \strong{Writing R Extensions} manual for more information.