Skip to content

Commit

Permalink
changing root directory on tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertASmith committed Feb 1, 2024
1 parent a24925c commit 62d9ae5
Showing 1 changed file with 33 additions and 29 deletions.
62 changes: 33 additions & 29 deletions tests/testthat/test-check_functions.R
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
test_that("test no error when running folder function", {

if (testthat::testing_package() != ""){
path <- dirname(dirname(getwd()))
}else{
path <- getwd()
}
#if (testthat::testing_package() != ""){
# path <- dirname(dirname(getwd()))
#}else{
# path <- getwd()
#}

testthat::expect_silent(
assertHE::tabulate_functions_in_folder(
path = path,
path = testthat::test_path("."),
path_exclude = NULL,
collapse = T,
packages_to_exclude = c("base", "stats", "utils")
)
)

tmp <- assertHE::tabulate_functions_in_folder(
path = path,
path = testthat::test_path("."),
path_exclude = NULL,
collapse = T,
packages_to_exclude = c("base", "stats", "utils")
)
Expand All @@ -25,7 +27,8 @@ test_that("test no error when running folder function", {

testthat::expect_type(
assertHE::tabulate_functions_in_folder(
path = path,
path = testthat::test_path("."),
path_exclude = NULL,
collapse = F,
packages_to_exclude = c("base", "stats", "utils")
),
Expand All @@ -35,7 +38,8 @@ test_that("test no error when running folder function", {

testthat::expect_type(
assertHE::tabulate_functions_in_folder(
path = path,
path = testthat::test_path("."),
path_exclude = NULL,
collapse = F,
packages_to_exclude = NULL
),
Expand All @@ -49,24 +53,24 @@ test_that("test no error when running folder function", {

test_that("find_test can identify a test where it exists", {

if (testthat::testing_package() != ""){
path <- dirname(dirname(getwd()))
}else{
path <- getwd()
}
#if (testthat::testing_package() != ""){
# path <- dirname(dirname(getwd()))
#}else{
# path <- getwd()
#}

#if(testthat::testing_package() == ""){
path_to_test1 <-
assertHE:::find_test(v_functions = "check_markov_trace",
path = path,
path = testthat::test_path("example_project"),
test_path = "tests/testthat")

testthat::expect_length(object = path_to_test1, n = 1)

path_to_test2 <-
assertHE:::find_test(
v_functions = c("check_trans_prob_array", "mean"),
path = path,
path = testthat::test_path("example_project"),
test_path = "tests/testthat"
)

Expand All @@ -87,26 +91,26 @@ test_that("find_test can identify a test where it exists", {
test_that(
"tabulate_functions_in_folder_with_tests can identify functions, packages and test locations",
{
if (testthat::testing_package() != "") {
path <- dirname(dirname(getwd()))
} else{
path <- getwd()
}
# if (testthat::testing_package() != "") {
# path <- dirname(dirname(getwd()))
# } else{
# path <- getwd()
# }

#if(testthat::testing_package() == ""){
testthat::expect_silent(
assertHE:::tabulate_functions_in_folder_with_tests(
path = path,
path_exclude = "tests/testthat",
path = testthat::test_path("example_project"),
path_exclude = NULL,
packages_to_exclude = c("base", "stats", "utils"),
test_path = "tests/testthat"
)
)

testthat::expect_silent(
assertHE:::tabulate_functions_in_folder_with_tests(
path = path,
path_exclude = "tests/testthat",
path = testthat::test_path("example_project"),
path_exclude = NULL,
packages_to_exclude = NULL,
test_path = "tests/testthat"
)
Expand All @@ -115,16 +119,16 @@ test_that(

df_tests <-
assertHE:::tabulate_functions_in_folder_with_tests(
path = path,
path_exclude = "tests/testthat",
path = testthat::test_path("example_project"),
path_exclude = NULL,
packages_to_exclude = c("base", "stats", "utils"),
test_path = "tests/testthat"
)

df_tests2 <-
assertHE:::tabulate_functions_in_folder_with_tests(
path = path,
path_exclude = "tests/testthat",
path = testthat::test_path("example_project"),
path_exclude = NULL,
packages_to_exclude = NULL,
test_path = "tests/testthat"
)
Expand Down

0 comments on commit 62d9ae5

Please sign in to comment.