From 8d603a9695eeae338f8677611abb4551b8a31337 Mon Sep 17 00:00:00 2001 From: olivroy Date: Thu, 26 Oct 2023 08:39:27 -0400 Subject: [PATCH] Simplify dependencies and don't use testthat in code (as it is suggests, not Imports.) --- DESCRIPTION | 4 +- R/are_beast2_input_lines.R | 2 +- R/check_beast2_options.R | 6 +-- R/check_can_create_file.R | 4 +- R/check_can_create_screenlog_file.R | 6 +-- R/check_can_create_tracelog_file.R | 2 +- R/check_can_create_treelog_file.R | 2 +- R/check_rng_seed.R | 2 +- R/check_true_false.R | 43 +++++++++++++++++++ R/continue_beast2.R | 6 +-- R/create_beast2_continue_cmd_from_options.R | 12 +++--- R/create_beast2_screenlog_folder.R | 4 +- R/create_beast2_tracelog_folder.R | 4 +- R/create_beast2_treelog_folder.R | 4 +- R/create_beast2_validate_cmd.R | 10 ++--- R/create_beast2_version_cmd.R | 6 +-- R/create_mcbette_beast2_options.R | 2 +- R/create_random_fasta.R | 4 +- ...creenlog_filename_from_beast2_input_file.R | 4 +- ...tracelog_filename_from_beast2_input_file.R | 6 +-- ..._treelog_filename_from_beast2_input_file.R | 4 +- R/get_beast2_example_filenames.R | 4 +- R/get_beast2_version.R | 2 +- R/get_default_java_path.R | 4 +- R/is_beast2_input_file.R | 6 +-- R/is_beast2_installed.R | 2 +- R/remove_file_if_present.R | 4 +- R/run_beast2_from_options.R | 2 +- tests/testthat/test-get_beast2_version.R | 2 +- tests/testthat/test-gives_beast2_warning.R | 2 +- tests/testthat/test-is_beast2_input_file.R | 2 +- tests/testthat/test-remove_file_if_present.R | 8 ++-- tests/testthat/test-run_beast2.R | 8 ++-- tests/testthat/test-run_beast2_from_options.R | 2 +- 34 files changed, 113 insertions(+), 72 deletions(-) create mode 100644 R/check_true_false.R diff --git a/DESCRIPTION b/DESCRIPTION index 0f5be58..4d3d89a 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,17 +26,15 @@ Imports: rappdirs, readr, rJava, + rlang (>= 1.1.0), sessioninfo, stringr, tibble, xml2 Suggests: - hunspell, knitr, - markdown, rmarkdown, spelling, - testit, testthat (>= 2.1.0), tracerer (>= 2.2.3) URL: https://docs.ropensci.org/beastier/ (website) diff --git a/R/are_beast2_input_lines.R b/R/are_beast2_input_lines.R index 4cf0a2b..e962bb2 100644 --- a/R/are_beast2_input_lines.R +++ b/R/are_beast2_input_lines.R @@ -38,7 +38,7 @@ are_beast2_input_lines <- function( file.remove(filename) return(is_valid) } else { - testit::assert(method == "fast") + check_true(method == "fast") return( are_beast2_input_lines_fast(lines) # nolint internal function ) diff --git a/R/check_beast2_options.R b/R/check_beast2_options.R index 32b6a86..0baf732 100644 --- a/R/check_beast2_options.R +++ b/R/check_beast2_options.R @@ -67,8 +67,8 @@ check_beast2_options_names <- function( # nolint long function name indeed, whic check_beast2_options_data_types <- function( # nolint long function name indeed, which is fine for an internal function beast2_options ) { - testthat::expect_true(beautier::is_one_string(beast2_options$input_filename)) - testthat::expect_true(beautier::is_one_string(beast2_options$output_state_filename)) + check_true(beautier::is_one_string(beast2_options$input_filename)) + check_true(beautier::is_one_string(beast2_options$output_state_filename)) check_rng_seed(beast2_options$rng_seed) check_n_threads(beast2_options$n_threads) if (!beautier::is_one_bool(beast2_options$use_beagle)) { @@ -77,7 +77,7 @@ check_beast2_options_data_types <- function( # nolint long function name indeed, if (!beautier::is_one_bool(beast2_options$overwrite)) { stop("'overwrite' must be one boolean") } - testthat::expect_true(beautier::is_one_string(beast2_options$beast2_path)) + check_true(beautier::is_one_string(beast2_options$beast2_path)) if (!beautier::is_one_bool(beast2_options$verbose)) { stop("'verbose' must be one boolean") } diff --git a/R/check_can_create_file.R b/R/check_can_create_file.R index b75b369..06d3698 100644 --- a/R/check_can_create_file.R +++ b/R/check_can_create_file.R @@ -28,7 +28,7 @@ check_can_create_file <- function( } else { # Delete the file file.remove(filename) - testthat::expect_true( + check_true( !file.exists(filename), info = paste0( "Cannot delete the file already present at location ", filename @@ -58,7 +58,7 @@ check_can_create_file <- function( } - testthat::expect_true( + check_true( !file.exists(filename), info = paste0( "Cannot delete the temporary file created at location ", filename diff --git a/R/check_can_create_screenlog_file.R b/R/check_can_create_screenlog_file.R index 2ca17b6..1543409 100644 --- a/R/check_can_create_screenlog_file.R +++ b/R/check_can_create_screenlog_file.R @@ -11,18 +11,18 @@ check_can_create_screenlog_file <- function( # nolint indeed a long function nam beast2_options ) { # Extract the screenlog file - testthat::expect_true(file.exists(beast2_options$input_filename)) + check_true(file.exists(beast2_options$input_filename)) text <- readr::read_lines(beast2_options$input_filename, progress = FALSE) screenlog_line <- stringr::str_subset( string = text, pattern = "