Skip to content

Conversation

@kalibera
Copy link
Contributor

@kalibera kalibera commented Sep 5, 2016

This patch ensures that test_pkg runs package tests with top-level environment being set to the namespace of the tested package. This makes the environment structure more similar to real execution of package code. This patch is necessary to make testit work with the R byte-code compiler, which is less permissive on the environment structure than the R AST interpreter.

A similar solution is used in testthat (see sys.source2, with_top_env functions), yet overall testthat uses a more complicated way of setting up environments for running packages (e.g. to support S4, functions - see test_pkg_env).

@yihui
Copy link
Owner

yihui commented Sep 6, 2016

I wish sys.source() accept the top environment as an argument so we don't have to copy its source code and modify only one place. Anyway, could you show me how to make leaflet fail first?

@kalibera
Copy link
Contributor Author

kalibera commented Sep 6, 2016

Regular user will not see the error yet - the compiler silently falls back to the AST interpreter exactly for the reason that end users are not now affected by errors like this. If you really want to debug the error yourself, modify "tryCmpfun" in compiler.nw (then you need to rebuild R/cmp.R and run make again in the whole R tree). Then you can run "env R_ENABLE_JIT=3 ./bin/R CMD check leaflet_1.0.1.tar.gz" or just the unit tests for it. You can also run directly the function in the compiler that performs the checks on the environments (compiler:::frameTypes).

@yihui yihui merged commit 4b22514 into yihui:master Sep 6, 2016
yihui added a commit that referenced this pull request Sep 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants