Skip to content

Commit 7cf13ac

Browse files
committed
fix the test where we dont want to eval the code
1 parent c3b25e6 commit 7cf13ac

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

tests/testthat/test-qenv_get_code.R

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ testthat::test_that("detects cooccurrence properly even if all objects are on lh
635635
# @ ---------------------------------------------------------------------------------------------------------------
636636

637637
testthat::test_that("understands @ usage and do not treat rhs of @ as objects (only lhs)", {
638-
testthat::skip("This breaks on CI but not locally with: Error: cannot add bindings to a locked environment")
638+
639639
code <- c(
640640
"setClass('aclass', slots = c(a = 'numeric', x = 'numeric', y = 'numeric')) # @linksto a x",
641641
"x <- new('aclass', a = 1:3, x = 1:3, y = 1:3)",
@@ -645,7 +645,22 @@ testthat::test_that("understands @ usage and do not treat rhs of @ as objects (o
645645
"a@x <- x@a"
646646
)
647647
q <- qenv()
648-
q <- eval_code(q, code)
648+
code_split <- as.list(split_code(paste(code, collapse = "\n")))
649+
650+
dependency <-
651+
lapply(
652+
code_split,
653+
function(current_code){
654+
parsed_code <- parse(text = current_code, keep.source = TRUE)
655+
extract_dependency(parsed_code)
656+
}
657+
)
658+
659+
for(i in seq_along(code_split)){
660+
attr(code_split[[i]], "dependency") <- dependency[[i]]
661+
}
662+
663+
q@code <- code_split
649664
testthat::expect_identical(
650665
get_code(q, names = "x"),
651666
pasten(code[1:2])

0 commit comments

Comments
 (0)