Skip to content

rlang warnings in ggplot2 unit tests #3552

Closed

Description

@clauswilke

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)

Activity

  1. karawoo commented on Oct 6, 2019

    @karawoo
    Member

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

  2. yutannihilation commented on Oct 7, 2019

    @yutannihilation
    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

  3. thomasp85 commented on Oct 7, 2019

    @thomasp85
    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

  4. yutannihilation commented on Oct 7, 2019

    @yutannihilation
    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)

  5. added this to the ggplot2 3.3.0 milestone on Oct 7, 2019
  6. added a commit that references this issue on Oct 29, 2019
    46478b5
  7. added a commit that references this issue on Oct 29, 2019
    36b50fe
  8. lock commented on May 5, 2020

    @lock

    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/

  9. locked and limited conversation to collaborators on May 5, 2020
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions