Prevent leaking environment information.

Only export the current environment and test (if testing is enabled).
Merge pull request #1827 from rwjblue/do-not-generate-modules-for-all-envs

Prevent leaking environment information.