Skip to content

Commit 3b374cb

Browse files
authored
CI(depends): Fix depends-only CRAN checks (#430)
1 parent 1714ca4 commit 3b374cb

File tree

6 files changed

+49
-23
lines changed

6 files changed

+49
-23
lines changed

tests/testthat/test-app-export.R

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
skip_if_not_installed("ggplot2")
2+
13
library(shiny)
24
library(ggplot2)
35

tests/testthat/test-app-screenshot-size.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ library(shiny)
33

44
test_that("images are captured via expect_values", {
55
skip_on_cran()
6+
skip_if_not_installed("png")
67

78
img_height <- 501
89
img_width <- 502

tests/testthat/test-migration-file.R

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1+
skip_if_not_installed("shinytest")
2+
13
expect_text_migration <- function(original_txt, new_txt, ...) {
24
info_env <- make_info_env(..., app_var = NULL) # nolint
35
suppressMessages({
4-
converted_text <- m__parse_test_text(original_txt, "test-migration-file", info_env)
6+
converted_text <- m__parse_test_text(
7+
original_txt,
8+
"test-migration-file",
9+
info_env
10+
)
511
})
612
testthat::expect_equal(converted_text, new_txt)
713
info_env
814
}
915

1016
test_that("file contents are converted", {
1117
info_env <- expect_text_migration(
12-
"
18+
"
1319
# Comment
1420
1+ 1; 1 +1; 1+1;
1521
@@ -36,7 +42,7 @@ test_that("file contents are converted", {
3642
app$setInputs(bins = app$getAllValues()$input$bins, values_ = FALSE)
3743
app$snapshot()
3844
",
39-
"
45+
"
4046
# Comment
4147
1+ 1; 1 +1; 1+1;
4248
@@ -63,7 +69,6 @@ app$expect_values()",
6369

6470

6571
test_that("`$expect_screenshot()` only shows up when `compareImages == TRUE` and `screenshot == TRUE`", {
66-
6772
# No suffix, compare_images = TRUE
6873
expect_text_migration(
6974
"app <- ShinyDriver$new(\"../..\"); app$snapshotInit(\"mytest\"); app$snapshot()",
@@ -86,13 +91,15 @@ test_that("`$expect_screenshot()` only shows up when `compareImages == TRUE` and
8691
expect_text_migration(
8792
"app <- ShinyDriver$new(\"custom/path\"); app$snapshot()",
8893
"app <- AppDriver$new(\"custom/path\")\napp$expect_values()",
89-
suffix = NULL, compare_images = FALSE
94+
suffix = NULL,
95+
compare_images = FALSE
9096
)
9197

9298
# compare_images = FALSE w/ screenshot = TRUE; compare_images wins
9399
expect_text_migration(
94100
"app <- ShinyDriver$new(\"../..\"); app$snapshotInit(\"mytest\", screenshot = TRUE); app$snapshot()",
95101
"app <- AppDriver$new()\napp$expect_values()",
96-
suffix = NULL, compare_images = FALSE
102+
suffix = NULL,
103+
compare_images = FALSE
97104
)
98105
})

tests/testthat/test-migration-migrate.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Too many possibilities for tests to randomly fail (e.g. file paths on windows, etc.)
22
# The other test files cover this fairly well. CI is good enough
33
skip_on_cran()
4+
skip_if_not_installed("shinytest")
45

56

67
expect_migration <- function(test_app_folder, ...) {

tests/testthat/test-migration-transformation.R

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
skip_if_not_installed("shinytest")
2+
13
expect_msg_helper <- function(expr, message, fixed, expect_fn, ...) {
24
if (is.na(message)) {
35
if (interactive()) {
@@ -52,10 +54,10 @@ expect_migration_error <- function(
5254
) {
5355
expect_msg_helper(
5456
# migrated_expr <-
55-
m__shinytest_lang(
56-
rlang::enexpr(original_expr),
57-
info_env
58-
),
57+
m__shinytest_lang(
58+
rlang::enexpr(original_expr),
59+
info_env
60+
),
5961
message = message,
6062
fixed = fixed,
6163
expect_fn = testthat::expect_error
@@ -65,7 +67,6 @@ expect_migration_error <- function(
6567
}
6668

6769

68-
6970
test_that("setInputs is converted", {
7071
expect_migration(
7172
app$setInputs(x = 1, allowInputNoBinding_ = TRUE, y = 2),
@@ -137,15 +138,17 @@ test_that("click is converted", {
137138
})
138139

139140

140-
141141
test_that("executeScript is converted", {
142142
expect_migration(
143143
app$executeScript("1 + 1"),
144144
app$get_js(script = "1 + 1", timeout = 10000)
145145
)
146146
expect_migration(
147147
app$executeScript("1 + 1", x = 1, y = 2),
148-
app$get_js(script = "let arguments_ = {\"x\":1,\"y\":2};\n1 + 1", timeout = 10000)
148+
app$get_js(
149+
script = "let arguments_ = {\"x\":1,\"y\":2};\n1 + 1",
150+
timeout = 10000
151+
)
149152
)
150153
})
151154

@@ -470,7 +473,12 @@ test_that("takeScreenshot is converted", {
470473
)
471474

472475
expect_migration(
473-
app$uploadFile(timeout_ = 2, myid = "file.png", wait_ = FALSE, values_ = FALSE),
476+
app$uploadFile(
477+
timeout_ = 2,
478+
myid = "file.png",
479+
wait_ = FALSE,
480+
values_ = FALSE
481+
),
474482
app$upload_file(myid = "file.png", wait_ = FALSE, timeout_ = 2)
475483
)
476484
})
@@ -495,7 +503,12 @@ test_that("waitForShiny is converted", {
495503
test_that("waitForValue is converted", {
496504
expect_migration(
497505
app$waitForValue(myname, ignore = foo(), timeout = 2, checkInterval = 3),
498-
app$wait_for_value(input = myname, ignore = foo(), timeout = 2, interval = 3)
506+
app$wait_for_value(
507+
input = myname,
508+
ignore = foo(),
509+
timeout = 2,
510+
interval = 3
511+
)
499512
)
500513
expect_migration(
501514
app$waitForValue(myname, iotype = "output"),
@@ -544,23 +557,26 @@ test_that("snapshot is converted", {
544557
rlang::exprs(
545558
app$expect_values(),
546559
app$expect_screenshot()
547-
), enexpr_new_expr = FALSE
560+
),
561+
enexpr_new_expr = FALSE
548562
)
549563
# Use a char
550564
expect_snapshot_migration(
551565
app$snapshot(items = list(output = "myoutput")),
552566
rlang::exprs(
553567
app$expect_values(output = "myoutput"),
554568
app$expect_screenshot()
555-
), enexpr_new_expr = FALSE
569+
),
570+
enexpr_new_expr = FALSE
556571
)
557572
# Respect language
558573
expect_snapshot_migration(
559574
app$snapshot(items = list(output = myoutputvar)),
560575
rlang::exprs(
561576
app$expect_values(output = myoutputvar),
562577
app$expect_screenshot()
563-
), enexpr_new_expr = FALSE
578+
),
579+
enexpr_new_expr = FALSE
564580
)
565581
# Turn off expect_screenshot if compare_images is false
566582
expect_snapshot_migration(

vignettes/use-application-audit.Rmd

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,8 @@ knitr::opts_chunk$set(
1313
collapse = TRUE,
1414
comment = "#>"
1515
)
16-
library(shinytest2)
17-
library(shiny)
18-
library(deSolve)
16+
# library(shinytest2)
17+
# library(shiny)
1918
```
2019

2120
# Audit Shiny apps with {shinytest2}
@@ -45,7 +44,7 @@ server <- function(input, output) {
4544
output$brussels <- renderPlot({
4645
y0 <- c(X = input$X, Y = input$Y)
4746
times <- seq(0, 1000, .01)
48-
out <- ode(y0, times, van_der_pol, input$mu)
47+
out <- deSolve::ode(y0, times, van_der_pol, input$mu)
4948
par(mfrow = c(1, 1))
5049
plot(out[, 2:3], type = "l", xlab = "X", ylab = "Y", main = "state diagram")
5150
})
@@ -144,7 +143,7 @@ recorder_bg <- function(port) {
144143

145144
We can pass this to the `start_r_bg()` function:
146145

147-
```r
146+
``` r
148147
start_r_bg <- function(fun, path = NULL, port = 3515) {
149148

150149
# remove NULL elements

0 commit comments

Comments
 (0)