Skip to content

rlang warnings in ggplot2 unit tests #3552

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
clauswilke opened this issue Oct 5, 2019 · 5 comments · Fixed by #3597
Closed

rlang warnings in ggplot2 unit tests #3552

clauswilke opened this issue Oct 5, 2019 · 5 comments · Fixed by #3597
Milestone

Comments

@clauswilke
Copy link
Member

When I run the ggplot2 unit tests, I get two rlang warnings. Does anybody else see this? Is this a misconfiguration on my end or is something not quite right with the test or the code base?

==> devtools::test()

Loading ggplot2
Testing ggplot2
✔ |  OK F W S | Context
✔ |   1   2   | Adding plot elements
───────────────────────────────────────
test-add.R:4: warning: mapping class is preserved when adding uneval objects
Subsetting quosures with `[[` is deprecated as of rlang 0.4.0
Please use `quo_get_expr()` instead.
This warning is displayed once per session.

test-add.R:4: warning: mapping class is preserved when adding uneval objects
Subsetting quosures with `[` is deprecated as of rlang 0.4.0
Please use `quo_get_expr()` instead.
This warning is displayed once per session.
───────────────────────────────────────
✔ |  14       | test-aes-calculated.r
✔ |   9       | Aesthetics (grouping) [0.4 s]
✔ |  10       | Aes - setting values [0.5 s]
...

Strangely, I cannot reproduce these warnings in a reprex:

library(ggplot2)
library(testthat)

# the test from test-add.R, line 4
p <- ggplot(mtcars) + aes(wt, mpg)
expect_identical(class(p$mapping), "uneval")

Created on 2019-10-05 by the reprex package (v0.3.0)

@karawoo
Copy link
Member

karawoo commented Oct 6, 2019

I see this too when I run the tests locally, and also can't reproduce outside of running the tests.

@yutannihilation
Copy link
Member

This seems because rlang:: signal_soft_deprecated() behaves differently when it runs in testthat environment.

#' * `signal_soft_deprecated()` warns only if called from the global
#'   environment (so the user can change their script) or from the
#'   package currently being tested (so the package developer can fix
#'   the package).

https://github.com/r-lib/rlang/blob/1f65d7c79315eee74b17991d289edeea6626467f/R/compat-lifecycle.R#L90-L98

@thomasp85
Copy link
Member

Have anyone successfully identified where the calls occur? I can only provoke these during testing, not by replaying the tests in the console, and searching for [[ is pretty hopeless

@yutannihilation
Copy link
Member

It says strip_dots(). So, probably here?

library(ggplot2)
library(testthat)

trace("[[.quosure", quote(lobstr::cst()), where = asNamespace("rlang"))
#> Tracing function "[[.quosure" in package "namespace:rlang"
#> [1] "[[.quosure"

p <- ggplot(mtcars) + aes(wt, mpg)
#> Tracing `[[.quosure`(expr, 1) on entry 
#>      x
#>   1. \-ggplot2:::`+.gg`(ggplot(mtcars), aes(wt, mpg))
#>   2.   \-ggplot2:::add_ggplot(e1, e2, e2name) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/plot-construction.r:51:2
#>   3.     +-ggplot2::ggplot_add(object, p, objectname) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/plot-construction.r:69:2
#>   4.     \-ggplot2:::ggplot_add.uneval(object, p, objectname) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/plot-construction.r:87:2
#>   5.       \-ggplot2:::make_labels(object) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/plot-construction.r:126:2
#>   6.         \-base::Map(default_label, names(mapping), mapping) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/aes-calculated.r:104:2
#>   7.           \-base::mapply(FUN = f, ..., SIMPLIFY = FALSE)
#>   8.             \-(function (aesthetic, mapping) ...
#>   9.               \-ggplot2:::strip_dots(mapping) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/aes-calculated.r:95:4
#>  10.                 +-expr[[1]] C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/aes-calculated.r:70:4
#>  11.                 \-rlang:::`[[.quosure`(expr, 1) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/aes-calculated.r:70:4
#>  12.                   +-base::.doTrace(lobstr::cst(), "on entry")
#>  13.                   | \-base::eval.parent(exprObj)
#>  14.                   |   \-base::eval(expr, p)
#>  15.                   |     \-base::eval(expr, p)
#>  16.                   \-lobstr::cst()
#> Tracing `[[.quosure`(expr, 1) on entry 
#>      x
#>   1. \-ggplot2:::`+.gg`(ggplot(mtcars), aes(wt, mpg))
#>   2.   \-ggplot2:::add_ggplot(e1, e2, e2name) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/plot-construction.r:51:2
#>   3.     +-ggplot2::ggplot_add(object, p, objectname) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/plot-construction.r:69:2
#>   4.     \-ggplot2:::ggplot_add.uneval(object, p, objectname) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/plot-construction.r:87:2
#>   5.       \-ggplot2:::make_labels(object) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/plot-construction.r:126:2
#>   6.         \-base::Map(default_label, names(mapping), mapping) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/aes-calculated.r:104:2
#>   7.           \-base::mapply(FUN = f, ..., SIMPLIFY = FALSE)
#>   8.             \-(function (aesthetic, mapping) ...
#>   9.               \-ggplot2:::strip_dots(mapping) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/aes-calculated.r:95:4
#>  10.                 +-expr[[1]] C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/aes-calculated.r:70:4
#>  11.                 \-rlang:::`[[.quosure`(expr, 1) C:/Users/hiroaki-yutani/Documents/repo/R/ggplot2/R/aes-calculated.r:70:4
#>  12.                   +-base::.doTrace(lobstr::cst(), "on entry")
#>  13.                   | \-base::eval.parent(exprObj)
#>  14.                   |   \-base::eval(expr, p)
#>  15.                   |     \-base::eval(expr, p)
#>  16.                   \-lobstr::cst()
expect_identical(class(p$mapping), "uneval")

Created on 2019-10-07 by the reprex package (v0.3.0)

@lock
Copy link

lock bot commented May 5, 2020

This old issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with reprex) and link to this issue. https://reprex.tidyverse.org/

@lock lock bot locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants