gentle-wolf-58752
12/16/2019, 7:42 PMtest
- adding an option to run within an interactive session) and am running into couple hiccups. Notably:
• How to best mock out options being passed to a rule (using the run_rule
test util, I didn’t catch anything in / after Erics change in https://github.com/pantsbuild/pants/pull/8742 that served as an example)
• How to best constrain the rule to a single BFA when the option is provided (following https://github.com/pantsbuild/pants/pull/8586 it seems I could do this via specs, wasn’t sure if there was something more elegant)gentle-wolf-58752
12/16/2019, 9:42 PMgentle-wolf-58752
12/17/2019, 9:57 PMhundreds-father-404
12/17/2019, 11:00 PMhundreds-father-404
12/17/2019, 11:00 PMgentle-wolf-58752
12/17/2019, 11:02 PMrun_rule
test helperhundreds-father-404
12/17/2019, 11:07 PMgentle-wolf-58752
12/18/2019, 12:05 AMfmt
rule (or tests), and I wasn’t able to find any other rules that took options that were under tests.
Failure on current tests looks like:
ValueError: Rule expected to receive arguments of the form: (<class 'pants.engine.console.Console'>, <class 'pants.rules.core.test.TestOptions'>, pants.engine.addressable.BuildFileAddresses); got: [<pants.testutil.engine.util.MockConsole object at 0x112cdaa58>, (BuildFileAddress(some/target/BUILD, target),)]
So while the rule can fetch the options, it seems the run_rule
helper can’t do the same (ie. can’t mock out a Get
for the goal options).
Using a simple Mock
(for options) looks promising, currently swimming in errors around missing `MockGet`s - appreciate the insights / feedback in the meantime.hundreds-father-404
12/18/2019, 12:15 AMargs
gentle-wolf-58752
12/18/2019, 12:19 AM