Load global vars when saving app objects#307
Merged
Conversation
This reverts commit 8b38be8.
jcheng5
reviewed
Jan 11, 2023
Member
|
Am I correct that the main three cases we care about are:
The kind of cross-process de/serialization that this PR is fixing, totally makes sense to me for case 3. It makes me a lot less comfortable if people are relying on it for case 2. I'd love to see us make a formal recommendation for using shinytest2 with golem/rhino that doesn't involve serializing any code objects. |
Contributor
|
The biggest benefit that I personally wanted from this is to be able to test a shiny module. If there is another good way to test a shiny module, please let me know. library(shiny)
mod_ui <- function(id) {
ns <- NS(id)
textOutput(ns("foo"))
}
mod_server <- function(id) {
moduleServer(
id,
function(input, output, session) {
output$foo <- renderText("bar")
}
)
}
app <- shinyApp(
mod_ui("test"),
function(input, output, session) { mod_server("test") }
)
driver <- shinytest2::AppDriver$new(app)
driver$get_logs() # Error in mod_server("test") : could not find function "mod_server" |
Contributor
|
This PR does indeed fix my usecase in #303 |
schloerke
added a commit
that referenced
this pull request
Feb 19, 2023
* Better error message when both app.R and server.R are found * Lint * Explicitly load all global vars found * Test global vars being found by using a script to cuz of parent environments * Revert "Better error message when both app.R and server.R are found" This reverts commit 8b38be8. * `devtools::document()` (GitHub Actions) * Rather than assigning values, shim an environment. Test two apps * Fix lint * Update .lintr * Update NEWS.md * Create issue_295.R * Add test for issue 295 * Recursively look for globals * Use `list2env(globals, envir=globalenv())` to multi assign globals * Update issue_295.R * Only run tests on CI Co-authored-by: schloerke <schloerke@users.noreply.github.com> Co-authored-by: Joe Cheng <joe@rstudio.com>
schloerke
added a commit
that referenced
this pull request
Feb 22, 2023
* main:
Update cran-comments.md
Update cran-comments.md
Run revdep
Move crashpad file to setup test file
Update cran-comments.md
Remove detritus Crashpad file/directory on CRAN
Don't use github `{lintr}` or `{decor}` package
Run revdep on 12 pkgs; ✅
Remove C++11 from DESCRIPTION (#326)
News entries for #284 and #288
Load global vars when saving app objects (#307)
Better error message when both app.R and server.R are found (#284)
Don't assume preview overflow is of length 1 (#291)
Force JS code to be a character for `{glue}` support (#288)
fix typo: expect_unqiue_names -> expect_unique... (#270)
Fix typo: use_shinytest -> use_shinytest2 (#269)
`compare_screenshot_threshold()` should not error from `screenshot_max_difference()` (#276)
Increment version number to 0.2.1
Change default screenshot selector to `"scrollable_area"` (from bounding box of `"html"` DOM) (#325)
actions/test-app; Add multi app `app-dir` support; Default upload-snapshot to `true` (#322)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #303
Fixes #295
Ans: Shimming an environment between the server and global envlist2env(envir=globalenv()){future}/ callr to pass app object instead of saving to temp arg{future}does a great job at capturing what is needed, it does not work well with stdout/stderr. This is a deal breaker.