From f588d854f6cb8dafbd5841476076393d2242eafd Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Tue, 14 Jan 2025 14:16:52 +0100 Subject: [PATCH 01/20] fix: initial cran comments --- cran-comments.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/cran-comments.md b/cran-comments.md index b0623f6..62c010f 100644 --- a/cran-comments.md +++ b/cran-comments.md @@ -1,15 +1,5 @@ -## Overview -* This is a new lightweight package that provide a wrapper around the cli package as a useful way of providing messages for both users and developers when developing new functions - -* The messages can be turned on/off by utilizing environmental options which is a convenient way of controlling the level of messages for both users and developers. - -## Test Environment -* Ubuntu 18.04 LTS (on github actions), devel, release, oldrel-1 -* Windows Server 2019 (on github actions), release -* macOS (on github actions), release - - ## R CMD check results -0 errors | 0 warnings | 1 note -* This is the first submission. +0 errors | 0 warnings | 0 note + +* This is a new release. From c4da51c9d79c67181e0933f339a9a7d6c3ab9f56 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Tue, 14 Jan 2025 14:17:04 +0100 Subject: [PATCH 02/20] fix: add installation information --- README.Rmd | 9 +++++++++ README.md | 9 +++++++++ 2 files changed, 18 insertions(+) diff --git a/README.Rmd b/README.Rmd index 0cec96d..f3b73d9 100644 --- a/README.Rmd +++ b/README.Rmd @@ -39,6 +39,15 @@ For packages outside our ecosystem, we recommend using the [options](https://cran.r-project.org/package=options) package instead for a more complete implementation of package options. +## Installation + +```{r, eval=FALSE} +# Install the released version from CRAN: +install.packages("zephyr") +# Install the development version from GitHub: +pak::pak("NovoNordisk-OpenSource/zephyr") +``` + ## Use zephyr The easiest way to use zephyr in your package is to set it up with the diff --git a/README.md b/README.md index 938aafb..1cd1ec8 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,15 @@ For packages outside our ecosystem, we recommend using the [options](https://cran.r-project.org/package=options) package instead for a more complete implementation of package options. +## Installation + +``` r +# Install the released version from CRAN: +install.packages("zephyr") +# Install the development version from GitHub: +pak::pak("NovoNordisk-OpenSource/zephyr") +``` + ## Use zephyr The easiest way to use zephyr in your package is to set it up with the From d7841d727785bcf664730d712d8ddea7b03da3a5 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Tue, 14 Jan 2025 14:46:01 +0100 Subject: [PATCH 03/20] fix: more precise Title and Description --- DESCRIPTION | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index eae05a1..2bb2d06 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,5 +1,5 @@ Package: zephyr -Title: Tools for Informing Users and Control Options +Title: Structured Messages and Options Version: 0.0.4.9000 Authors@R: c( person("Aksel", "Thomsen", , "oath@novonordisk.com", role = c("aut", "cre")), @@ -11,9 +11,8 @@ Authors@R: c( person("Vladimir", "Obucina", , "vlob@novonordisk.com", role = "aut"), person("Novo Nordisk A/S", role = "cph") ) -Description: Tools for helping developers of R packages to create consistent - messages for their users and enables a streamlined control of options - in their packages. +Description: Provides a structured framework for consistent user communication and + configuration management for package developers. License: Apache License (>= 2) URL: https://novonordisk-opensource.github.io/zephyr/, https://github.com/NovoNordisk-OpenSource/zephyr From 621c90109c7871257bc182a2abd98a1c3b18f057 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Tue, 14 Jan 2025 15:24:42 +0100 Subject: [PATCH 04/20] fix: returns and examples for all functions --- R/checkmate.R | 1 + R/msg.R | 2 +- R/options.R | 1 + R/use_zephyr.R | 4 ++++ man/list_options.Rd | 3 +++ man/report_checkmate_assertions.Rd | 3 +++ man/use_zephyr.Rd | 8 ++++++++ man/zephyr-package.Rd | 4 ++-- 8 files changed, 23 insertions(+), 3 deletions(-) diff --git a/R/checkmate.R b/R/checkmate.R index e5ab770..fae5062 100644 --- a/R/checkmate.R +++ b/R/checkmate.R @@ -13,6 +13,7 @@ #' if any assertions failed #' @param .envir The `[environment]` to use for the error message. #' Default `parent.frame()` will be sufficient for most use cases. +#' @returns `invisible(TRUE)` #' @examples #' add_numbers <- function(a, b) { #' collection <- checkmate::makeAssertCollection() diff --git a/R/msg.R b/R/msg.R index ce93ae2..c30d4c0 100644 --- a/R/msg.R +++ b/R/msg.R @@ -36,7 +36,7 @@ #' Default `parent.frame()` will be sufficient for most use cases. Parsed on to #' `msg_fun()`. #' -#' @return Return from `msg_fun()` +#' @returns Return from `msg_fun()` #' #' @examples #' msg("General message") diff --git a/R/options.R b/R/options.R index 0f9675d..7d0fc26 100644 --- a/R/options.R +++ b/R/options.R @@ -144,6 +144,7 @@ get_option <- function(name, .envir = sys.function(which = -1)) { #' each option. #' @param .envir Environment in which the options are defined. #' Default is suitable for use inside your package. +#' @returns `list` or `character` depending on `as` #' @examples #' # List all options in zephyr #' x <- list_options(.envir = "zephyr") diff --git a/R/use_zephyr.R b/R/use_zephyr.R index 9d4c7f0..c0b9a4b 100644 --- a/R/use_zephyr.R +++ b/R/use_zephyr.R @@ -9,6 +9,10 @@ #' This code also creates an package specific `verbosity_level` option, #' enabling you to control the verbosity of your package functions using #' the [msg] functions. +#' @returns `invisible(TRUE)` +#' @examplesIf FALSE +#' use_zephyr() +#' #' @export use_zephyr <- function() { cli::cli_h1("Setting up {.pkg zephyr}") diff --git a/man/list_options.Rd b/man/list_options.Rd index 6cfefdf..bce14d2 100644 --- a/man/list_options.Rd +++ b/man/list_options.Rd @@ -23,6 +23,9 @@ each option. \item{.envir}{Environment in which the options are defined. Default is suitable for use inside your package.} } +\value{ +\code{list} or \code{character} depending on \code{as} +} \description{ List all \code{zephyr_options} specified in a package. Either as an \code{list} or as as \code{character} vector formatted for use in your package documentation. diff --git a/man/report_checkmate_assertions.Rd b/man/report_checkmate_assertions.Rd index 8c20e3d..7719223 100644 --- a/man/report_checkmate_assertions.Rd +++ b/man/report_checkmate_assertions.Rd @@ -20,6 +20,9 @@ if any assertions failed} \item{.envir}{The \verb{[environment]} to use for the error message. Default \code{parent.frame()} will be sufficient for most use cases.} } +\value{ +\code{invisible(TRUE)} +} \description{ Improved reporting of an \code{AssertCollection} created with the \code{\link[checkmate:AssertCollection]{checkmate::makeAssertCollection()}} using \code{\link[cli:cli_abort]{cli::cli_abort()}} instead of diff --git a/man/use_zephyr.Rd b/man/use_zephyr.Rd index 0c3ca36..9b79ce3 100644 --- a/man/use_zephyr.Rd +++ b/man/use_zephyr.Rd @@ -6,6 +6,9 @@ \usage{ use_zephyr() } +\value{ +\code{invisible(TRUE)} +} \description{ Utility function to set up the use of zephyr options and \link{verbosity_level} in your package. @@ -17,3 +20,8 @@ This code also creates an package specific \code{verbosity_level} option, enabling you to control the verbosity of your package functions using the \link{msg} functions. } +\examples{ +\dontshow{if (FALSE) (if (getRversion() >= "3.4") withAutoprint else force)(\{ # examplesIf} +use_zephyr() +\dontshow{\}) # examplesIf} +} diff --git a/man/zephyr-package.Rd b/man/zephyr-package.Rd index 6283060..ddfe225 100644 --- a/man/zephyr-package.Rd +++ b/man/zephyr-package.Rd @@ -4,11 +4,11 @@ \name{zephyr-package} \alias{zephyr} \alias{zephyr-package} -\title{zephyr: Tools for Informing Users and Control Options} +\title{zephyr: Structured Messages and Options} \description{ \if{html}{\figure{logo.png}{options: style='float: right' alt='logo' width='120'}} -Tools for helping developers of R packages to create consistent messages for their users and enables a streamlined control of options in their packages. +Provides a structured framework for consistent user communication and configuration management for package developers. } \seealso{ Useful links: From 4952c91f58a4dcdaf840ca0b84d139d2663df848 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Tue, 14 Jan 2025 16:16:29 +0100 Subject: [PATCH 05/20] fix: update licence year --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 2d17ef8..9816f63 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -179,7 +179,7 @@ recommend that a file or class name and description of purpose be included on the same “printed page” as the copyright notice for easier identification within third-party archives. - Copyright 2024 Novo Nordisk A/S, Danish company registration no. 24256790 + Copyright 2025 Novo Nordisk A/S, Danish company registration no. 24256790 Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. From 5cddde8361b2ba6c5783b043e8d7dd5e8ad8e7a9 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Tue, 14 Jan 2025 16:22:44 +0100 Subject: [PATCH 06/20] fix: add BugReports to DESCRIPTION --- DESCRIPTION | 7 ++++--- inst/WORDLIST | 1 + man/zephyr-package.Rd | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index bb84133..60eb288 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -11,11 +11,12 @@ Authors@R: c( person("Vladimir", "Obucina", , "vlob@novonordisk.com", role = "aut"), person("Novo Nordisk A/S", role = "cph") ) -Description: Provides a structured framework for consistent user communication and - configuration management for package developers. +Description: Provides a structured framework for consistent user + communication and configuration management for package developers. License: Apache License (>= 2) URL: https://novonordisk-opensource.github.io/zephyr/, - https://github.com/NovoNordisk-OpenSource/zephyr + https://github.com/novonordisk-opensource/zephyr +BugReports: https://github.com/novonordisk-opensource/zephyr/issues Imports: cli, glue, diff --git a/inst/WORDLIST b/inst/WORDLIST index cb18d8d..49a1a55 100644 --- a/inst/WORDLIST +++ b/inst/WORDLIST @@ -1,4 +1,5 @@ Aksel +BugReports CMD Cervan Compats diff --git a/man/zephyr-package.Rd b/man/zephyr-package.Rd index ddfe225..daeb3ec 100644 --- a/man/zephyr-package.Rd +++ b/man/zephyr-package.Rd @@ -14,7 +14,8 @@ Provides a structured framework for consistent user communication and configurat Useful links: \itemize{ \item \url{https://novonordisk-opensource.github.io/zephyr/} - \item \url{https://github.com/NovoNordisk-OpenSource/zephyr} + \item \url{https://github.com/novonordisk-opensource/zephyr} + \item Report bugs at \url{https://github.com/novonordisk-opensource/zephyr/issues} } } From 0540e5430c9df81d6d3acf5a3d08c885d8d62b39 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 13:53:35 +0100 Subject: [PATCH 07/20] fix: make sure R CMD check run with bno suggested packages --- tests/testthat/test-checkmate.R | 2 ++ tests/testthat/test-integration.R | 7 +++++++ tests/testthat/test-msg.R | 2 ++ tests/testthat/test-options.R | 2 ++ tests/testthat/test-use_zephyr.R | 3 +++ tests/testthat/test-utils.R | 2 ++ tests/testthat/test-verbosity_level.R | 6 ++++++ 7 files changed, 24 insertions(+) diff --git a/tests/testthat/test-checkmate.R b/tests/testthat/test-checkmate.R index 6142d46..2bc4c45 100644 --- a/tests/testthat/test-checkmate.R +++ b/tests/testthat/test-checkmate.R @@ -1,4 +1,6 @@ test_that("report assertions", { + skip_if_not_installed("checkmate") + add_numbers <- function(a, b) { collection <- checkmate::makeAssertCollection() checkmate::assert_numeric(x = a, add = collection) diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index f89f7da..eff946d 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -21,6 +21,9 @@ libpath <- withr::local_tempdir() test_that("integration in new package", { skip_on_cran() skip_on_covr() + skip_if_not_installed("withr") + skip_if_not_installed("usethis") + skip_if_not_installed("devtools") # Settings @@ -69,6 +72,10 @@ test_that("integration in new package", { test_that("use in new package", { skip_on_cran() skip_on_covr() + skip_if_not_installed("withr") + skip_if_not_installed("usethis") + skip_if_not_installed("devtools") + skip_if_not_installed("callr") run_output(\() testpkg::greet("there"), libpath) |> expect_output("hello there") diff --git a/tests/testthat/test-msg.R b/tests/testthat/test-msg.R index d880abe..a95dae7 100644 --- a/tests/testthat/test-msg.R +++ b/tests/testthat/test-msg.R @@ -22,6 +22,7 @@ test_that("Default verbosity work as intended", { }) test_that("Minimal verbosity has the expected behavior", { + skip_if_not_installed("withr") withr::local_options(list(zephyr.verbosity_level = "minimal")) msg("This gives a message for everything except quiet") |> @@ -47,6 +48,7 @@ test_that("Minimal verbosity has the expected behavior", { }) test_that("Quiet gives no messages", { + skip_if_not_installed("withr") withr::local_options(list(zephyr.verbosity_level = "quiet")) msg("This gives a message for everything except quiet") |> diff --git a/tests/testthat/test-options.R b/tests/testthat/test-options.R index 297b3f4..7f9e00f 100644 --- a/tests/testthat/test-options.R +++ b/tests/testthat/test-options.R @@ -29,6 +29,8 @@ test_that("get_option", { get_option("test_option", .envir = testenv) |> expect_equal(42, info = "Should return default when no option is set") + skip_if_not_installed("withr") + withr::local_envvar(list(R_TESTENV_TEST_OPTION = "200")) get_option("test_option", .envir = testenv) |> diff --git a/tests/testthat/test-use_zephyr.R b/tests/testthat/test-use_zephyr.R index 53209e0..dc74d56 100644 --- a/tests/testthat/test-use_zephyr.R +++ b/tests/testthat/test-use_zephyr.R @@ -1,4 +1,7 @@ test_that("use_zephyr", { + skip_if_not_installed("withr") + skip_if_not_installed("usethis") + rlang::local_interactive(FALSE) withr::local_options(usethis.quiet = TRUE) diff --git a/tests/testthat/test-utils.R b/tests/testthat/test-utils.R index 8be67e3..4aa5549 100644 --- a/tests/testthat/test-utils.R +++ b/tests/testthat/test-utils.R @@ -10,6 +10,8 @@ test_that("sys_getenv", { sys_getenv("fake_env") |> expect_null() + skip_if_not_installed("withr") + withr::with_envvar( new = list(myenv = "myvalue"), code = { diff --git a/tests/testthat/test-verbosity_level.R b/tests/testthat/test-verbosity_level.R index 4e6e9de..45e4e74 100644 --- a/tests/testthat/test-verbosity_level.R +++ b/tests/testthat/test-verbosity_level.R @@ -2,6 +2,8 @@ test_that("simple verbosity level", { get_verbosity_level() |> expect_equal("verbose") + skip_if_not_installed("withr") + withr::with_options( list(zephyr.verbosity_level = "invalid"), { @@ -49,6 +51,8 @@ test_that("verbosity level respects priority hierarchy when used in package", { expect_equal(get_verbosity_level(test_env), "verbose") # Test 2: Package-specific option (highest priority) + skip_if_not_installed("withr") + withr::with_options(list(testpkg.verbosity_level = "debug"), { expect_equal(get_verbosity_level(test_env), "debug") }) @@ -112,6 +116,8 @@ test_that("get_all_verbosity_levels", { get_all_verbosity_levels() |> expect_equal(c(zephyr = "verbose")) + skip_if_not_installed("withr") + withr::with_namespace(c("cli", "glue"), { withr::local_options(list( zephyr.verbosity_level = "quiet", From a43cabf831e1902046c89f968d4abec117c0c191 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 14:39:09 +0100 Subject: [PATCH 08/20] fix: integration tests works with devtools::check() --- tests/testthat/test-integration.R | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index eff946d..26f4155 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -1,6 +1,6 @@ -run_output <- function(func, extra_lib) { +run_output <- function(func, extra_lib, args = list()) { libpath <- c(extra_lib, .libPaths()) - callr::r(func = func, show = TRUE, libpath = libpath, spinner = FALSE) + callr::r(func = func, args = args, show = TRUE, libpath = libpath, spinner = FALSE) } run_output_project <- function(func, extra_lib, project) { @@ -45,8 +45,20 @@ test_that("integration in new package", { ) # Install zephyr in tmp libpath - - run_output(\() devtools::install(quiet = TRUE), libpath) |> + pkg <- normalizePath(test_path(), winslash = "/") + pkg <- gsub("/tests/testthat$", "", pkg) + if (grepl("\\.Rcheck$", pkg)) pkg <- file.path(pkg, "zephyr") + cat("\n",pkg, "\n") + + run_output( # nolint: brace_linter + \(p) devtools::install( + pkg = p, + quiet = TRUE, + quick = TRUE + ), + libpath, + list(p = pkg) + ) |> expect_true() # Use in new package From c5b63e27ebcbd7a3e7dc949f9136b7c1736d97d3 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 14:44:45 +0100 Subject: [PATCH 09/20] fix: remove cat() used in debug --- tests/testthat/test-integration.R | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index 26f4155..9462e9b 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -48,7 +48,6 @@ test_that("integration in new package", { pkg <- normalizePath(test_path(), winslash = "/") pkg <- gsub("/tests/testthat$", "", pkg) if (grepl("\\.Rcheck$", pkg)) pkg <- file.path(pkg, "zephyr") - cat("\n",pkg, "\n") run_output( # nolint: brace_linter \(p) devtools::install( From 627cc50d166e8dc326206f72c9dd54a5b38b3f7b Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 14:58:49 +0100 Subject: [PATCH 10/20] fix: bump version --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 60eb288..5759ac4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: zephyr Title: Structured Messages and Options -Version: 0.0.4.9001 +Version: 0.0.4.9002 Authors@R: c( person("Aksel", "Thomsen", , "oath@novonordisk.com", role = c("aut", "cre")), person("Mathias Lerbech", "Jeppesen", , "nmlj@novonordisk.com", role = "aut"), From fdebba8c7eba22d808aebb7b18bb6ba06d9bed0b Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 15:08:17 +0100 Subject: [PATCH 11/20] test: normalizePath to handle windows install errors --- tests/testthat/test-integration.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index 9462e9b..5e3f180 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -56,7 +56,7 @@ test_that("integration in new package", { quick = TRUE ), libpath, - list(p = pkg) + list(p = normalizePath(pkg)) ) |> expect_true() From 220c47cdc07060fc13c7f3a1c4bac981612fa8c8 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 15:22:11 +0100 Subject: [PATCH 12/20] test: pkg folder works on windows --- tests/testthat/test-integration.R | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index 5e3f180..30bdb76 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -45,9 +45,10 @@ test_that("integration in new package", { ) # Install zephyr in tmp libpath - pkg <- normalizePath(test_path(), winslash = "/") - pkg <- gsub("/tests/testthat$", "", pkg) - if (grepl("\\.Rcheck$", pkg)) pkg <- file.path(pkg, "zephyr") + pkg <- file.path(test_path(), "../..") + if (!file.exists(file.path(pkg, "DESCRIPTION"))) { + pkg <- file.path(pkg, "zephyr") + } run_output( # nolint: brace_linter \(p) devtools::install( From e2fa0ce1efea92b45ac1a0b7ae06f2ee8545f020 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 15:33:47 +0100 Subject: [PATCH 13/20] fix: skip integration test on windows due to file paths giving trouble in CLI calls to R from callr --- tests/testthat/test-integration.R | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index 30bdb76..1050e51 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -24,6 +24,7 @@ test_that("integration in new package", { skip_if_not_installed("withr") skip_if_not_installed("usethis") skip_if_not_installed("devtools") + skip_on_os("windows") # Settings @@ -50,8 +51,8 @@ test_that("integration in new package", { pkg <- file.path(pkg, "zephyr") } - run_output( # nolint: brace_linter - \(p) devtools::install( + run_output( + \(p) devtools::install( # nolint: brace_linter pkg = p, quiet = TRUE, quick = TRUE @@ -88,6 +89,7 @@ test_that("use in new package", { skip_if_not_installed("usethis") skip_if_not_installed("devtools") skip_if_not_installed("callr") + skip_on_os("windows") run_output(\() testpkg::greet("there"), libpath) |> expect_output("hello there") From 0790ef5e758216d1dd4543e74441c5c240f50817 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 15:42:52 +0100 Subject: [PATCH 14/20] fix: only skip on windows when run with devtools::check() --- tests/testthat/test-integration.R | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index 1050e51..c2dbe61 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -24,7 +24,6 @@ test_that("integration in new package", { skip_if_not_installed("withr") skip_if_not_installed("usethis") skip_if_not_installed("devtools") - skip_on_os("windows") # Settings @@ -47,8 +46,12 @@ test_that("integration in new package", { # Install zephyr in tmp libpath pkg <- file.path(test_path(), "../..") - if (!file.exists(file.path(pkg, "DESCRIPTION"))) { - pkg <- file.path(pkg, "zephyr") + if (file.exists(file.path(pkg, "DESCRIPTION"))) { + pkg = "." + } else { + skip_on_os("windows") + pkg <- file.path(pkg, "zephyr") |> + normalizePath() } run_output( @@ -58,7 +61,7 @@ test_that("integration in new package", { quick = TRUE ), libpath, - list(p = normalizePath(pkg)) + list(p = pkg) ) |> expect_true() From 81cd26315689b793b466cfe5cc02317a65d1e06c Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 15:54:41 +0100 Subject: [PATCH 15/20] fix: better skipping on windows --- tests/testthat/test-integration.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index c2dbe61..f021006 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -92,7 +92,7 @@ test_that("use in new package", { skip_if_not_installed("usethis") skip_if_not_installed("devtools") skip_if_not_installed("callr") - skip_on_os("windows") + skip_if(file.exists(file.path(libpath, "testpkg")), "testpkg not installed") run_output(\() testpkg::greet("there"), libpath) |> expect_output("hello there") From 79408df63bf9ef3f6e1f0817b0d547c8878b31df Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 15:56:12 +0100 Subject: [PATCH 16/20] fix: linting error --- tests/testthat/test-integration.R | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index f021006..9bd90ab 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -47,7 +47,7 @@ test_that("integration in new package", { # Install zephyr in tmp libpath pkg <- file.path(test_path(), "../..") if (file.exists(file.path(pkg, "DESCRIPTION"))) { - pkg = "." + pkg <- "." } else { skip_on_os("windows") pkg <- file.path(pkg, "zephyr") |> From f92d5ab114f6a1adcbd8e158337de8e15ccbf5ef Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 15:56:53 +0100 Subject: [PATCH 17/20] feat: bump version to 0.0.5 for internal pre-release --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 5759ac4..9965af0 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: zephyr Title: Structured Messages and Options -Version: 0.0.4.9002 +Version: 0.0.5 Authors@R: c( person("Aksel", "Thomsen", , "oath@novonordisk.com", role = c("aut", "cre")), person("Mathias Lerbech", "Jeppesen", , "nmlj@novonordisk.com", role = "aut"), From be5cd06e5142decf22ccc33afe86366655fc14c0 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 16:26:56 +0100 Subject: [PATCH 18/20] fix: typo --- tests/testthat/test-integration.R | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test-integration.R b/tests/testthat/test-integration.R index 9bd90ab..4d19c78 100644 --- a/tests/testthat/test-integration.R +++ b/tests/testthat/test-integration.R @@ -1,6 +1,12 @@ run_output <- function(func, extra_lib, args = list()) { libpath <- c(extra_lib, .libPaths()) - callr::r(func = func, args = args, show = TRUE, libpath = libpath, spinner = FALSE) + callr::r( + func = func, + args = args, + show = TRUE, + libpath = libpath, + spinner = FALSE + ) } run_output_project <- function(func, extra_lib, project) { @@ -92,7 +98,10 @@ test_that("use in new package", { skip_if_not_installed("usethis") skip_if_not_installed("devtools") skip_if_not_installed("callr") - skip_if(file.exists(file.path(libpath, "testpkg")), "testpkg not installed") + skip_if( + condition = !file.exists(file.path(libpath, "testpkg")), + message = "testpkg not installed - expected if test above has been skipped" + ) run_output(\() testpkg::greet("there"), libpath) |> expect_output("hello there") From 77d5421871dc1bbc9bd698757b346e68db499d31 Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 17:25:33 +0100 Subject: [PATCH 19/20] fix: minimum R and rlang versions --- DESCRIPTION | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 9965af0..d607f61 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -17,10 +17,12 @@ License: Apache License (>= 2) URL: https://novonordisk-opensource.github.io/zephyr/, https://github.com/novonordisk-opensource/zephyr BugReports: https://github.com/novonordisk-opensource/zephyr/issues +Depends: + R (>= 4.1) Imports: cli, glue, - rlang + rlang (>= 1.0.0) Suggests: callr, checkmate, From 39bfcbc0f708a1b2891972d6af346f67fd4d2f8f Mon Sep 17 00:00:00 2001 From: akselthomsen Date: Wed, 15 Jan 2025 17:43:48 +0100 Subject: [PATCH 20/20] fix: increase minimum testthat version to have expect_no_message() and expect_no_condition() --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index d607f61..5741cd8 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -29,7 +29,7 @@ Suggests: devtools, knitr, rmarkdown, - testthat (>= 3.0.0), + testthat (>= 3.1.5), usethis, withr Config/testthat/edition: 3