Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove hard testthat dependency. #107

Merged
merged 9 commits into from
Dec 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
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,14 +132,19 @@
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."

Check warning on line 138 in R/bbt_continue.R

View check run for this annotation

Codecov / codecov/patch

R/bbt_continue.R#L137-L138

Added lines #L137 - L138 were not covered by tests
)
}
if (!file.exists(normalizePath(inference_model$mcmc$tracelog$filename))) {
stop(
"'mcmc$tracelog$filename' not found. \n",
"inference_model$mcmc$tracelog$filename: ",
inference_model$mcmc$tracelog$filename, " \n",

Check warning on line 145 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=145,col=8,[indentation_linter] Indentation should be 6 spaces but is 8 spaces.
"normalizePath(inference_model$mcmc$tracelog$filename): ",
normalizePath(inference_model$mcmc$tracelog$filename), " \n",

Check warning on line 147 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=147,col=8,[indentation_linter] Indentation should be 6 spaces but is 8 spaces.
"This can be caused by:\n",
" * (Linux) the home folder is encrypted\n",
" * (MacOS) if `babette` is run in a folder monitored by DropBox\n"
Expand All @@ -152,7 +157,7 @@
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 @@
)
)
)
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 @@
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.")

Check warning on line 199 in R/bbt_continue.R

View check run for this annotation

Codecov / codecov/patch

R/bbt_continue.R#L199

Added line #L199 was not covered by tests
}
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")

Check warning on line 204 in R/bbt_continue.R

View check run for this annotation

Codecov / codecov/patch

R/bbt_continue.R#L204

Added line #L204 was not covered by tests
}

# 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,10 +127,12 @@
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 warning on line 131 in R/bbt_run_from_model.R

View check run for this annotation

Codecov / codecov/patch

R/bbt_run_from_model.R#L131

Added line #L131 was not covered by tests
}
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(
"'mcmc$tracelog$filename' not found. \n",
"This can be caused by:\n",
Expand All @@ -156,7 +158,8 @@
)
)
)
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 @@
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.")

Check warning on line 190 in R/bbt_run_from_model.R

View check run for this annotation

Codecov / codecov/patch

R/bbt_run_from_model.R#L190

Added line #L190 was not covered by tests
}
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.")

Check warning on line 194 in R/bbt_run_from_model.R

View check run for this annotation

Codecov / codecov/patch

R/bbt_run_from_model.R#L194

Added line #L194 was not covered by tests
}

# 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.")

Check warning on line 20 in R/bbt_self_test.R

View check run for this annotation

Codecov / codecov/patch

R/bbt_self_test.R#L20

Added line #L20 was not covered by tests
}
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`"),

Check warning on line 15 in R/check_true_false.R

View check run for this annotation

Codecov / codecov/patch

R/check_true_false.R#L13-L15

Added lines #L13 - L15 were not covered by tests
...,
allow_na = allow_na,
allow_null = allow_null,
arg = arg,
call = call

Check warning on line 20 in R/check_true_false.R

View check run for this annotation

Codecov / codecov/patch

R/check_true_false.R#L17-L20

Added lines #L17 - L20 were not covered by tests
)
}
# 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))

Check warning on line 31 in R/check_true_false.R

View check run for this annotation

Codecov / codecov/patch

R/check_true_false.R#L30-L31

Added lines #L30 - L31 were not covered by tests
}

stop_input_type(
x,
c("`FALSE`"),

Check warning on line 36 in R/check_true_false.R

View check run for this annotation

Codecov / codecov/patch

R/check_true_false.R#L34-L36

Added lines #L34 - L36 were not covered by tests
...,
allow_na = allow_na,
allow_null = allow_null,
arg = arg,
call = call

Check warning on line 41 in R/check_true_false.R

View check run for this annotation

Codecov / codecov/patch

R/check_true_false.R#L38-L41

Added lines #L38 - L41 were not covered by tests
)
}
Loading
Loading