memestra icon indicating copy to clipboard operation
memestra copied to clipboard

memestra tests are sensitive to global mutable state

Open cpcloud opened this issue 4 years ago • 5 comments

When running tests for pythons 3.8 and 3.9 after running tests for python 3.7 without the necessary changes to gast and beniget, both to support NamedExprs, the tests pass. With a clean cache (rm -rf $XDG_CONFIG_HOME/memestra) the tests fail as they ought to. Whatever is being stored in $XDG_CONFIG_HOME isn't taking into account enough information to make the behavior of the tool the same as it would be without a cache.

cpcloud avatar Jul 23 '21 14:07 cpcloud

To reproduce:

  1. Run tests with python 3.7
  2. Run tests with python 3.8. This should fail, but it doesn't

cpcloud avatar Jul 23 '21 15:07 cpcloud

Maybe a dumb question, but is the cache actually necessary? It seems like if it's causing incorrect behavior then it might be reasonable to take the performance hit until there's enough testing in place to ensure that the introduction of an optimization like a cache doesn't break things.

cpcloud avatar Jul 23 '21 15:07 cpcloud

The cache is important, because it caches the transversal of the standard library, which is used by most modules. I need to dive into this some more...

serge-sans-paille avatar Jul 24 '21 20:07 serge-sans-paille

The cache needs to be isolated to the running interpreter though, not shared by any python interpreter that comes along. What about using a location for the cache that is tied to the running interpreter, instead of a system-wide cache?

cpcloud avatar Jul 24 '21 21:07 cpcloud

One way to do this would be to create a directory under $XDG_CONFIG_HOME/memestra/usr/bin/python3 for example. Conda environments, nix store paths, virtualenvs etc would all be isolated from each other under this scheme.

cpcloud avatar Jul 24 '21 21:07 cpcloud