https://pantsbuild.org/ logo
#development
Title
# development
h

hundreds-breakfast-49010

08/29/2019, 11:55 PM
so I guess
run_rule
is the correct way to do this?
a

aloof-angle-91616

08/29/2019, 11:56 PM
let me check
nvm, mac updating. 12 mins
h

hundreds-breakfast-49010

08/29/2019, 11:57 PM
actually it looks like
run_rule
expects you to mock out a
yield Get
but that's exactly what I want to test here
a

aloof-angle-91616

08/29/2019, 11:58 PM
mock out a yield Get how?
h

hundreds-breakfast-49010

08/30/2019, 12:00 AM
the docstring says that if you use yield get in a rule, you have to provide a function that will do that
uh, maybe I don't need that here though
a

aloof-angle-91616

08/30/2019, 12:00 AM
omg
h

hundreds-breakfast-49010

08/30/2019, 12:06 AM
wait, no, that can't work
the intrinsic is exactly what I need to test here
and in non-test code that's exactly what the engine would handle implicitly in the yield
a

aloof-angle-91616

08/30/2019, 12:06 AM
that’s kind of why i was leaning towards the solution you first proposed
h

hundreds-breakfast-49010

08/30/2019, 12:06 AM
okay so acutally do go with product_request, then?
a

aloof-angle-91616

08/30/2019, 12:06 AM
well
h

hundreds-breakfast-49010

08/30/2019, 12:06 AM
I'm not 100% sure how that works, I just see other tests using it
a

aloof-angle-91616

08/30/2019, 12:07 AM
those other tests might not be all up to date
it works exactly the same as a yield Get
can confirm any of this in a few when my laptop restarts
h

hundreds-breakfast-49010

08/30/2019, 12:08 AM
ok
yeah I figured it was basically a yield Get, I just wanted to make sure it was still valid in v2 code
a

aloof-angle-91616

08/30/2019, 12:11 AM
the scheduler product_request() method in general is intended to be a hack for v1 and removing calls to it should be a v2 migration goal imo, at a very high level (someone correct me if i’m wrong) but for an intrinsic like you’re doing it seems like the right choice
h

hundreds-breakfast-49010

08/30/2019, 12:17 AM
so does that mean that eventually there should be another way of deliberately invoking an intrinsic from a python test?
or that this is the only thing that product_request() should be used for in v2?
a

aloof-angle-91616

08/30/2019, 12:19 AM
that’s vaguely what i was thinking, but not sure what that might look like as of now
h

hundreds-breakfast-49010

08/30/2019, 12:49 AM
when I run
./pants test tests/python/pants_test/engine:isolated_process
I get this error:
Copy code
E       pants.engine.scheduler.ExecutionError: 1 Exception encountered:
                     E       Computing Select(FileContent(path=some.filename, content=(len:23)), ExecuteProcessResult)
                     E         Computing Task(current_rule(), FileContent(path=some.filename, content=(len:23)), ExecuteProcessResult, true)
                     E           Throw(WithDeps(Inner(InnerEntry { params: {InputFileContent}, rule: Task(Task { product: ExecuteProcessResult, clause: [Select { product: InputFileContent }], gets: [Get { product: Digest, subject: InputFileContent }], func: current_rule(), cacheable: true }) })) did not declare a dependency on JustGet(Get { product: ExecuteProcessResult, subject: ExecuteProcessRequest }))
                     E             Traceback (no traceback):
                     E               <pants native internals>
                     E             Exception: WithDeps(Inner(InnerEntry { params: {InputFileContent}, rule: Task(Task { product: ExecuteProcessResult, clause: [Select { product: InputFileContent }], gets: [Get { product: Digest, subject: InputFileContent }], func: current_rule(), cacheable: true }) })) did not declare a dependency on JustGet(Get { product: ExecuteProcessResult, subject: ExecuteProcessRequest })
so, somehow I'm not setting up the rules correctly?
but other tests in that same file are somehow successfully getting an
ExecuteProcessResult
from an
ExecuteProcessRequest
(what I want to do here is basically generate a Digest from an InputFileContent, and then execute a process to cat it, and make sure the output is the same as the original file specification)
a

aloof-angle-91616

08/30/2019, 12:53 AM
oh wow, i thought we linted that
h

hundreds-breakfast-49010

08/30/2019, 12:53 AM
linted?
a

aloof-angle-91616

08/30/2019, 12:54 AM
i didn’t think that having a
yield Get()
as the final expression in a rule was supposed to work for some reason (but i don’t know why that shouldn’t work)
and i thought that we tried to lint for that in the
@rule
decorator
h

hundreds-breakfast-49010

08/30/2019, 12:54 AM
oh
a

aloof-angle-91616

08/30/2019, 12:55 AM
i have a laptop now, checking why that wouldn’t be it
h

hundreds-breakfast-49010

08/30/2019, 12:55 AM
well I disabled linting when I commited this since it's still a WIP
a

aloof-angle-91616

08/30/2019, 12:56 AM
when i said “lint” i meant that the
@rule
decorator raises an error when seeing certain constructs in rules
h

hundreds-breakfast-49010

08/30/2019, 12:57 AM
btw is there a way to only run a single test within a pants test target?
a

aloof-angle-91616

08/30/2019, 1:01 AM
use passthrough args or test.pytest --args to add the argument
-k regexp
to match the name of the test you want to run. pytest has several other options too
h

hundreds-breakfast-49010

08/30/2019, 1:01 AM
ah, ok
need to head out for the day now, I'll pick this up again tomorrow
a

aloof-angle-91616

08/30/2019, 1:01 AM
i just looked at the
@rule
decorator and your rule is supposed to be working
so yeah let’s pick this up tomorrow
h

hundreds-breakfast-49010

08/30/2019, 1:01 AM
but yeah removing the Get from the end of the line now mkaes the error be something in the rust code
that looks FFI-related
a

aloof-angle-91616

08/30/2019, 1:01 AM
amazing
h

hundreds-breakfast-49010

08/30/2019, 1:01 AM
which sucks but at least I"m past this problem
a

aloof-angle-91616

08/30/2019, 1:01 AM
yes indeed
i might ask you to please add a TODO above the Get noting that it should work to have a yield Get() at the end of a rule, but currently doesn’t, and that we should check this or fix it
i’d investigate but v tired right now
ok, i am tired but also have managed to repro the final yield Get() issue with a test rule in test_scheduler.py, so i plan to investigate on the plane or tomorrow
h

hundreds-breakfast-49010

08/30/2019, 5:58 PM
oh cool
a

aloof-angle-91616

08/31/2019, 2:43 AM
`@rule`s can now end in
yield Get(...)
expressions: https://github.com/pantsbuild/pants/pull/8227
🎉 2
h

hundreds-breakfast-49010

09/03/2019, 5:56 PM
cool, I'll take a look at this