Skip to content

Commit

Permalink
test: skipping non interactive tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ymansiaux committed Sep 27, 2024
1 parent e0972b2 commit 5b8c349
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/testthat/test-build_fusen_chunks.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ dir.create(dummydir)
path_foosen <- file.path(dummydir, "foosen")

test_that("build_fusen_chunks add lines with export as expected", {
skip_if_not(interactive())

withr::with_dir(dummydir, {
dev_file <- create_fusen(path_foosen, template = "minimal", open = FALSE)
fill_description(pkg = path_foosen, fields = list(Title = "Dummy Package"))
Expand Down Expand Up @@ -153,6 +155,7 @@ dir.create(dummydir)
path_foosen <- file.path(dummydir, "foosen")

test_that("build_fusen_chunks add lines with noRd as expected", {
skip_if_not(interactive())
withr::with_dir(dummydir, {
dev_file <- create_fusen(path_foosen, template = "minimal", open = FALSE)
fill_description(pkg = path_foosen, fields = list(Title = "Dummy Package"))
Expand Down
22 changes: 22 additions & 0 deletions tests/testthat/test-create_fusen_rsproject.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ expected_rmd_template_with_fusen_name <- readLines(system.file("flat-template-fu

withr::with_dir(dummypackage, {
test_that("Create fusen works", {
skip_if_not(interactive())

path_foosen <- file.path(dummypackage, "foosen")

path_dev_history <- suppressMessages(
Expand Down Expand Up @@ -35,6 +37,8 @@ withr::with_dir(dummypackage, {
## Test overwrite existing dir ----
withr::with_dir(dummypackage, {
test_that("Overwrite fusen dir is possible with message", {
skip_if_not(interactive())

path_foosen <- file.path(dummypackage, "foosen")

# Can not overwrite
Expand Down Expand Up @@ -74,6 +78,8 @@ for (template.to.try in fusen:::create_fusen_choices) {

withr::with_dir(dummypackage, {
test_that(paste("Create fusen works with template:", template.to.try), {
skip_if_not(interactive())

if (template.to.try %in% "dev_history") {
expected_rmd_template_with_fusen_name <- NULL
} else {
Expand Down Expand Up @@ -138,6 +144,8 @@ for (template.to.try in fusen:::create_fusen_choices) {
## Create in a subdirectory ----
dummysubdir <- tempfile(pattern = "subdir/subdir2/dummy")
test_that("Can create in a subdirectory", {
skip_if_not(interactive())

expect_error(suppressMessages(create_fusen(dummysubdir, template = "full", open = FALSE)), regexp = NA)
expect_true(dir.exists(dummysubdir))
})
Expand All @@ -159,6 +167,8 @@ for (template.to.try in c("full", "minimal", "teaching", "dev_history")) {
dummygui <- create_dummygui()
withr::with_dir(dummygui$dirname, {
test_that(paste("Can create in a project with gui for:", template.to.try), {
skip_if_not(interactive())

dev_path <- expect_error(
suppressMessages(
create_fusen_gui(dummygui$basename, template = template.to.try, with_git = FALSE)
Expand Down Expand Up @@ -191,6 +201,8 @@ if (git_output != 0) {
dir.create(dummypackage)
withr::with_dir(dummypackage, {
test_that("Create a fusen project with git at the cli", {
skip_if_not(interactive())

path_gigit <- file.path(dummypackage, "gigit")
expect_warning(
create_fusen(path_gigit, template = "full", open = FALSE, with_git = TRUE),
Expand All @@ -216,6 +228,8 @@ if (git_output != 0) {
dir.create(dummypackage)
withr::with_dir(dummypackage, {
test_that("Create a fusen project with git at the cli", {
skip_if_not(interactive())

path_gigit <- file.path(dummypackage, "gigit")
dev_path <- suppressMessages(create_fusen(path_gigit, template = "full", open = FALSE, with_git = TRUE))

Expand All @@ -235,6 +249,8 @@ if (git_output != 0) {
dir.create(dummypackage)
withr::with_dir(dummypackage, {
test_that("Create a fusen project without git at the cli", {
skip_if_not(interactive())

path_gigit <- file.path(dummypackage, "gigit")
dev_path <- suppressMessages(create_fusen(path_gigit, template = "full", open = FALSE, with_git = FALSE))

Expand All @@ -253,6 +269,8 @@ if (git_output != 0) {
dummygui <- create_dummygui()
withr::with_dir(dummygui$dirname, {
test_that("Create a fusen project with git using Rstudio GUI", {
skip_if_not(interactive())

dev_file <- expect_error(
suppressMessages(
create_fusen_gui(dummygui$basename, template = "teaching", with_git = TRUE)
Expand All @@ -273,6 +291,8 @@ if (git_output != 0) {
dummygui <- create_dummygui()
withr::with_dir(dummygui$dirname, {
test_that("Create a fusen project without git using Rstudio GUI", {
skip_if_not(interactive())

dev_file <- expect_error(
suppressMessages(
create_fusen_gui(dummygui$basename, template = "teaching", with_git = FALSE)
Expand All @@ -295,6 +315,8 @@ dummypackage <- tempfile(pattern = "dummy")
dir.create(dummypackage)
withr::with_dir(dummypackage, {
test_that("Create a fusen project with git at the cli", {
skip_if_not(interactive())

path_bad_name <- file.path(dummypackage, "bad-name")
expect_error(
create_fusen(path_bad_name, template = "full", open = FALSE),
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test-inflate-part2.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ for (pkgname in create_choices_test) {
# pkgname <- create_choices_test[1]
# No "additional" with create_fusen
# {fusen} steps
skip_if_not(interactive())
path_foosen <- normalize_path_winslash(file.path(alltemp, pkgname), mustWork = FALSE)
dev_file <- create_fusen(path_foosen, template = pkgname, open = FALSE)
flat_file <- dev_file[grepl("flat_", dev_file)]
Expand Down
3 changes: 3 additions & 0 deletions tests/testthat/test-user-story.R
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
skip_if_not(interactive())

# Test users full classical process ----
all_templates_second <- fusen:::flat_template_choices[!fusen:::flat_template_choices %in% c("dev_history", "dev")]
test_that("create_fusen and use it as users do", {
Expand Down Expand Up @@ -39,6 +41,7 @@ for (template in all_templates_second) {
check = FALSE
))


test_that(paste0("full process -", template, "- first minimal basis ok"), {
expect_true(file.exists("DESCRIPTION"))
expect_true(file.exists("dev/flat_first.Rmd"))
Expand Down

0 comments on commit 5b8c349

Please sign in to comment.