Skip to content

Commit

Permalink
Merge pull request #107 from olivroy/cran
Browse files Browse the repository at this point in the history
Remove hard testthat dependency.
  • Loading branch information
richelbilderbeek authored Dec 26, 2023
2 parents a007e79 + 144acdf commit 54c1ccc
Show file tree
Hide file tree
Showing 27 changed files with 1,064 additions and 112 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,23 +68,23 @@ jobs:
shell: Rscript {0}

- name: Make sure that no files are created in the beautier .cache folder
run: testthat::expect_equal(0, length(list.files(rappdirs::user_cache_dir(appname = "beautier"))))
run: testthat::expect_length(list.files(rappdirs::user_cache_dir(appname = "beautier")), 0)
shell: Rscript {0}

- name: Make sure that no files are created in the tracerer .cache folder
run: testthat::expect_equal(0, length(list.files(rappdirs::user_cache_dir(appname = "tracerer"))))
run: testthat::expect_length(list.files(rappdirs::user_cache_dir(appname = "tracerer")), 0)
shell: Rscript {0}

- name: Make sure that no files are created in the beastier .cache folder
run: testthat::expect_equal(0, length(list.files(rappdirs::user_cache_dir(appname = "beastier"))))
run: testthat::expect_length(list.files(rappdirs::user_cache_dir(appname = "beastier")), 0)
shell: Rscript {0}

- name: Make sure that no files are created in the mauricer .cache folder
run: testthat::expect_equal(0, length(list.files(rappdirs::user_cache_dir(appname = "mauricer"))))
run: testthat::expect_length(list.files(rappdirs::user_cache_dir(appname = "mauricer")), 0)
shell: Rscript {0}

- name: Make sure that no files are created in the .cache folder
run: testthat::expect_equal(0, length(list.files(rappdirs::user_cache_dir(appname = "babette"))))
run: testthat::expect_length(list.files(rappdirs::user_cache_dir(appname = "babette")), 0)
shell: Rscript {0}

- name: Test coverage
Expand Down
10 changes: 3 additions & 7 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ Authors@R: c(
person("David", "Winter", role = "rev", comment = "David reviewed the package for rOpenSci, see https://github.com/richelbilderbeek/onboarding/issues/209"),
person("Jason", "Griffiths", role = "ctb", comment = c(ORCID = "0000-0002-1667-8233")),
person("Giovanni", "Laudanno", email = "glaudanno@gmail.com", role = "ctb"))
Maintainer: Richèl J.C. Bilderbeek <richel@richelbilderbeek.nl>
Description: 'BEAST2' (<https://www.beast2.org>) is a widely used
Bayesian phylogenetic tool, that uses DNA/RNA/protein data
and many model priors to create a posterior of jointly estimated
Expand All @@ -19,8 +18,8 @@ Description: 'BEAST2' (<https://www.beast2.org>) is a widely used
License: GPL-3
RoxygenNote: 7.2.3
VignetteBuilder: knitr
URL: https://docs.ropensci.org/babette/ (website)
https://github.com/ropensci/babette/
URL: https://docs.ropensci.org/babette/ (website),
https://github.com/ropensci/babette
BugReports: https://github.com/ropensci/babette/issues
Depends:
beautier (>= 2.6.11),
Expand All @@ -30,17 +29,14 @@ Depends:
tracerer
Imports:
phangorn,
remotes,
rlang (>= 1.1.0),
stringr,
xml2
Suggests:
ape,
curl,
ggplot2,
hunspell,
knitr,
lintr,
markdown,
nLTT,
rappdirs,
rmarkdown,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export(parse_beast2_output_to_ns)
export(plot_densitree)
export(prepare_file_creation)
export(update_babette)
import(rlang)
importFrom(beastier,add_quotes_if_has_spaces)
importFrom(beastier,are_beast2_input_lines)
importFrom(beastier,are_beast2_input_lines_deep)
Expand Down
5 changes: 3 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Newest versions at top.

### BUG FIXES

* None
* Removed unused dependencies, and testthat dependency outside tests.
* Import rlang for checking conditions.

### DEPRECATED AND DEFUNCT

Expand Down Expand Up @@ -359,7 +360,7 @@ create_lambda_param(value = 1.2, estimate = TRUE)

### MINOR IMPROVEMENTS

* Follow all [rOpenSci packaging guidelines](https://github.com/ropensci/onboarding/blob/master/packaging_guide.md)
* Follow all [rOpenSci packaging guidelines](https://github.com/ropensci/software-review/blob/master/packaging_guide.md)

### BUG FIXES

Expand Down
1 change: 1 addition & 0 deletions R/babette-package.R
Original file line number Diff line number Diff line change
Expand Up @@ -602,5 +602,6 @@
"_PACKAGE"

## usethis namespace: start
#' @import rlang
## usethis namespace: end
NULL
23 changes: 17 additions & 6 deletions R/bbt_continue.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bbt_continue <- function(
beast2_options$input_filename,
"beast2_options$input_filename"
)
testthat::expect_true(
check_true(

Check warning on line 117 in R/bbt_continue.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/bbt_continue.R,line=117,col=3,[object_usage_linter] no visible global function definition for 'check_true'
beastier::is_beast2_input_file(beast2_options$input_filename)
)
beautier::check_file_exists(
Expand All @@ -132,7 +132,12 @@ bbt_continue <- function(
beautier::get_alignment_id(fasta_filename), ".log"
)
}
testthat::expect_true(!is.na(inference_model$mcmc$tracelog$filename))

if (is.na(inference_model$mcmc$tracelog$filename)) {
stop(
"Expected inference_model$mcmc$tracelog$filename not to be missing."
)
}
if (!file.exists(normalizePath(inference_model$mcmc$tracelog$filename))) {
stop(
"'mcmc$tracelog$filename' not found. \n",
Expand All @@ -152,7 +157,7 @@ bbt_continue <- function(
pattern = "\\$\\(tree\\)",
replacement = beautier::get_alignment_id(fasta_filename)
)
testthat::expect_true(file.exists(inference_model$mcmc$treelog$filename) &&
check_true(file.exists(inference_model$mcmc$treelog$filename) &&

Check warning on line 160 in R/bbt_continue.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/bbt_continue.R,line=160,col=3,[object_usage_linter] no visible global function definition for 'check_true'
length(
paste0(
"'mcmc$treelog$filename' not found. \n",
Expand All @@ -162,7 +167,7 @@ bbt_continue <- function(
)
)
)
testthat::expect_true(file.exists(beast2_options$output_state_filename) &&
check_true(file.exists(beast2_options$output_state_filename) &&

Check warning on line 170 in R/bbt_continue.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/bbt_continue.R,line=170,col=3,[object_usage_linter] no visible global function definition for 'check_true'
length(
paste0(
"beast2_output_state_filename not found. \n",
Expand All @@ -189,9 +194,15 @@ bbt_continue <- function(
n_trees_in_file <- tracerer::count_trees_in_file(
inference_model$mcmc$treelog$filename
)
testthat::expect_true(inherits(out[[1]], "multiPhylo"))

if (!inherits(out[[1]], "multiPhylo")) {
stop("Expected out to be a multiPhylo object.")
}
n_trees_in_output <- length(out[[1]])
testthat::expect_equal(n_trees_in_file, n_trees_in_output)

if (n_trees_in_file != n_trees_in_output) {
stop("Expected n_trees_in_files to be equal to n_trees_in_output")
}

# Process the package specific output,
# for example, add an 'ns' atributed for Nested Sampling
Expand Down
17 changes: 12 additions & 5 deletions R/bbt_run_from_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,10 @@ bbt_run_from_model <- function(
beautier::get_alignment_id(fasta_filename), ".log"
)
}
testthat::expect_true(!is.na(inference_model$mcmc$tracelog$filename))
testthat::expect_true(
if (is.na(inference_model$mcmc$tracelog$filename)) {
stop("inference_model$mcmc$tracelog$filename should not be missing.")
}
check_true(

Check warning on line 133 in R/bbt_run_from_model.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/bbt_run_from_model.R,line=133,col=3,[object_usage_linter] no visible global function definition for 'check_true'
file.exists(normalizePath(inference_model$mcmc$tracelog$filename)) &&
length(

Check warning on line 135 in R/bbt_run_from_model.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/bbt_run_from_model.R,line=135,col=4,[indentation_linter] Indentation should be 6 spaces but is 4 spaces.
paste0(
Expand Down Expand Up @@ -156,7 +158,8 @@ bbt_run_from_model <- function(
)
)
)
testthat::expect_true(file.exists(beast2_options$output_state_filename) &&
# Should this be if (!file.exists) stop(paste0(...))?
check_true(file.exists(beast2_options$output_state_filename) &&

Check warning on line 162 in R/bbt_run_from_model.R

View workflow job for this annotation

GitHub Actions / R-CMD-check (false, ubuntu-latest)

file=R/bbt_run_from_model.R,line=162,col=3,[object_usage_linter] no visible global function definition for 'check_true'
length(
paste0(
"beast2_output_state_filename not found. \n",
Expand All @@ -183,9 +186,13 @@ bbt_run_from_model <- function(
n_trees_in_file <- tracerer::count_trees_in_file(
inference_model$mcmc$treelog$filename
)
testthat::expect_true(inherits(out[[1]], "multiPhylo"))
if (!inherits(out[[1]], "multiPhylo")) {
stop("out[[1]] should be multiPhylo.")
}
n_trees_in_output <- length(out[[1]])
testthat::expect_equal(n_trees_in_file, n_trees_in_output)
if (n_trees_in_file != n_trees_in_output) {
stop("n_trees_in_file should be equal to n_trees_in_output.")
}

# Process the package specific output,
# for example, add an 'ns' atributed for Nested Sampling
Expand Down
5 changes: 4 additions & 1 deletion R/bbt_self_test.R
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
bbt_self_test <- function(
beast2_options = beastier::create_beast2_options()
) {
testthat::expect_true(beastier::is_beast2_installed())

if (!beastier::is_beast2_installed()) {
stop("Beast2 must be installed for bbt_self_test.")
}
inference_model <- beautier::create_test_inference_model()
babette::bbt_run_from_model(
fasta_filename = beautier::get_fasta_filename(),
Expand Down
43 changes: 43 additions & 0 deletions R/check_true_false.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Created by modifying check_bool from import-standalone-type-check.
check_true <- function(x,
...,
allow_na = FALSE,
allow_null = FALSE,
arg = caller_arg(x),
call = caller_env()) {

if (!missing(x) && !isFALSE(x) &&.standalone_types_check_dot_call(ffi_standalone_is_bool_1.0.7, x, allow_na, allow_null)) {
return(invisible(NULL))
}

stop_input_type(
x,
c("`TRUE`"),
...,
allow_na = allow_na,
allow_null = allow_null,
arg = arg,
call = call
)
}
# Adapted from standalone-types-check.R
check_false <- function(x,
...,
allow_na = FALSE,
allow_null = FALSE,
arg = caller_arg(x),
call = caller_env()) {
if (!missing(x) && !isTRUE(x) && .standalone_types_check_dot_call(ffi_standalone_is_bool_1.0.7, x, allow_na, allow_null)) {
return(invisible(NULL))
}

stop_input_type(
x,
c("`FALSE`"),
...,
allow_na = allow_na,
allow_null = allow_null,
arg = arg,
call = call
)
}
Loading

0 comments on commit 54c1ccc

Please sign in to comment.