Skip to content

Code export test writes the required channel core no longer has #15

Description

@nbenn

The test "show code builds a deferred board without evaluating it" in tests/testthat/test-plugin.R errors against blockr.core main since BristolMyersSquibb/blockr.core#337 merged:

Error in `rlang::eval_tidy(quosure, mask, rlang::caller_env())`: attempt to apply non-function

It makes the board lazy by writing vis$required[["a"]](TRUE), and later reads vis$required[["b"]]() to check that the export left the front-end's channel alone. Core#337 removed that channel: a board is now made lazy by a callback returning eager(owner, blocks), and what each owner holds evaluated is board$eager_blocks(). The package code does not use the channel, and the other six tests in the file pass against core main. The package is not among the downstreams core's merge queue checks, which is why the break was not caught there.

The change below keeps what the test checks — the export builds the deferred block, leaves it dormant, and adds nothing to what is held evaluated — and the whole file passes with it against core main:

@@ -92,7 +92,6 @@ test_that("show code builds a deferred board without evaluating it", {
   testServer(
     get_s3_method("board_server", board),
     {
-      vis$required[["a"]](TRUE)
       vis$visible[["a"]](TRUE)
       session$flushReact()
 
@@ -105,11 +104,15 @@ test_that("show code builds a deferred board without evaluating it", {
         before = before,
         after = names(rv$blocks),
         status = reval_if(rv$eval[["b"]]),
-        required = vis$required[["b"]](),
+        eager = rv$eager_blocks(),
         body = as.character(output$`generate_code-code_out`$html)
       )
     },
-    args = list(x = board, plugins = plugins(generate_flat_code()))
+    args = list(
+      x = board,
+      plugins = plugins(generate_flat_code()),
+      callbacks = function(...) eager("front-end", "a")
+    )
   )
 
   # The off-screen block starts unbuilt, and showing the code builds it
@@ -119,7 +122,7 @@ test_that("show code builds a deferred board without evaluating it", {
   # Built for its expression and left dormant: the export needs blocks present,
   # not run, so the board stays as lazy as it was
   expect_identical(out$status, "dormant")
-  expect_true(is.na(out$required))
+  expect_identical(out$eager, list(`front-end` = "a"))
 
   # The whole script is exported, rather than an `NA` assignment standing in for
   # the block that was missing

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions