Is it possible to figure out if pants has the resu...
# general
a
Is it possible to figure out if pants has the results of running tests in cache?
h
Like, figure it out without running pants and looking at the stdout?
a
I'm okay with running pants to the point where it needs to run tests, then if it needs to run tests, it exits with an error code, or something.
We have a lot of situations where we could just not run these tests, but we spin up several large instances to run them, spin up the associated infra, and then pants goes "ah, nvm, had this in cache all along"
h
Oh, hah, no that is not possible, but it is a valid use-case!
Will need to think on that one
You could write the tests to optionally crash if they actually run (by checking an env var, say)
And then run them on a small machine with that env var set
And see if they crash
Hacky…
a
That's not a terrible idea, though, would pants cache the results in that case?
I mean, the env is not considered when deciding whether something can be satisfied from the cache?
h
No, it won’t cache the failure
Oh, dang, yes the env is part of the cache key
🤦
So it could consult a sentinel file
if
/tmp/crashme
exists…
a
hm, that might explain why we don't get stuff from the cache
h
Well, only the env vars that you plumb through to the test are in the cache key, not the entire env
you would never get cache hits otherwise, the env is constantly fluctuating
a
hm, okay, then I don't know why that doesn't work, heh, but we can definitely do an env var for this
if I ever get a couple of hours to play around, I'll try this, thanks
h
No, you can’t do an env var for this, because you would have to plumb it through
if the test can see it, then it is part of the cache key
a
oh, the tests clear the env
h
A filtered env is passed through to the tests
if you want the test to see
CRASHME
then you must plumb it through, in which case it becomes part of the cache key
so you will never get a cache hit, because the test crashed when that was set
but that’s OK, check a file instead
a
I've been meaning to force a pytest plugin on all tests, but some of our codebase didn't use to depend on the testing framework
I had to fix that when we upgraded, so we can try that
e
I'm also interested in this use-case (check if any tests need running before bothering to start the docker stack). commenting to follow
a
Nothing useful on this topic, but, if you mouse over on any message and click the three dots (more actions), you can turn on notifications without replying 🙂
e
🤦 forgot about that one
g
I'm also interested in this use-case (check if any tests need running before bothering to start the docker stack)
Specifically for this,
pants --changed-since=<TREEISH> --dependents=transitive list
will get you quite far.