hundreds-breakfast-49010
02/14/2020, 2:45 AMgoal_rule_test_base
framework to test a new goalhundreds-father-404
02/14/2020, 2:52 AMrules()
function.
If a rule in the file directly uses PythonSetup
, for example, then register subsystem_rule(PythonSetup)
, even if that was registered by a transitive rule so it’s not strictly necessary. The engine will deduplicate the rules
This is similar to BUILD file hygiene. It’s best practice to declare every direct dependency, even if you don’t need to because a transitive dependency already includes it
The impact of this would be that tests only need to register the rules()
for the file they are directly testing and no longer need to register all the transitive rules used, like they currently do. Should make test setup much simplerwitty-crayon-22786
02/14/2020, 4:31 AMhundreds-breakfast-49010
02/14/2020, 7:03 PMrule()
function, and then making sure that we keep that in sync going forwardhundreds-father-404
02/14/2020, 7:03 PMand then making sure that we keep that in sync going forwardWhich isn’t wonderful. See how painful it is to keep in sync BUILD files
hundreds-breakfast-49010
02/14/2020, 7:04 PME Exception: No installed @rules can compute Repl for input Params((AddressSpecs, Console, Factory, InteractiveRunner, OptionsBootstrapper, Workspace)).
right now. I think what might be going on is that there's a bunch of rules around handling AddressSpecs in build_files.py
that I'm not includingAddressMapper
which I don't really understand how to mock; but in any case this is pretty far away from the original problem I'm trying to solve)hundreds-father-404
02/14/2020, 7:06 PMbuild_files.py
in other tests, including ones that use FilesystemSpecs
and AddressesWithOrigins
hundreds-breakfast-49010
02/14/2020, 7:08 PMparam_inputs
into the error messages in find_root_edges
find_root_edges
in rule_graph/src/lib.rs
)0 if params.is_subset(&self.root_param_types) => {
hundreds-father-404
02/14/2020, 7:15 PMRootRule(PythonRepl)
src/python/pants/backend/python/rules/repl_integration_test.py
should not use GoalRuleTestBase
because it’s not testing a goal. It should use TestBase
and self.request_single_product
hundreds-breakfast-49010
02/14/2020, 7:18 PMRootRule(PythonRepl)
does nothingwitty-crayon-22786
02/14/2020, 7:41 PMSelect(Repl)
hundreds-father-404
02/14/2020, 7:43 PM./pants --native-engine-visualize-to=viz/
. I have a little script to then open it up in Chrome:
#!/usr/bin/env python3
import argparse
import subprocess
def main() -> None:
fp = create_parser().parse_args().fp
subprocess.run(["dot", "-Tpdf", "-O", fp])
subprocess.run(["open", "-a", "Google Chrome", f"{fp}.pdf"])
def create_parser() -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(description='Visualize graph and open as PDF.')
parser.add_argument('fp', help='e.g. 000 or 013')
return parser
if __name__ == '__main__':
main()
witty-crayon-22786
02/14/2020, 7:43 PMSelect(Repl)
rootshundreds-father-404
02/14/2020, 7:43 PM./viz/viz.py viz/rule_graph.dot
witty-crayon-22786
02/14/2020, 7:44 PMhundreds-breakfast-49010
02/14/2020, 7:49 PMwitty-crayon-22786
02/14/2020, 7:49 PMSelect(Repl)
nodes.hundreds-breakfast-49010
02/14/2020, 7:50 PMException: No installed @rules can compute Repl for input Params((AddressSpecs, Console, Factory, InteractiveRunner, OptionsBootstrapper, Workspace)).
, with no suggestionswitty-crayon-22786
02/14/2020, 7:51 PMRepl
is definitely installed...?Repl
, otherwise the graph would have failed to be constructed even earlyhundreds-breakfast-49010
02/14/2020, 7:52 PMrepl
becuase I was copying code raound in this commitwitty-crayon-22786
02/14/2020, 7:52 PMhundreds-breakfast-49010
02/14/2020, 7:53 PMwitty-crayon-22786
02/14/2020, 7:53 PMhundreds-breakfast-49010
02/14/2020, 7:53 PMwitty-crayon-22786
02/14/2020, 7:53 PMhundreds-breakfast-49010
02/14/2020, 7:54 PMwitty-crayon-22786
02/14/2020, 7:54 PMbasically, if there are no ways to compute some type, then ... you haven't installed the rule that computes it.
if there are any ways to compute some type, they should be rendered as suggestions there.
hundreds-breakfast-49010
02/14/2020, 7:55 PMproduc
?witty-crayon-22786
02/14/2020, 7:56 PMhundreds-breakfast-49010
02/14/2020, 7:56 PMwitty-crayon-22786
02/14/2020, 7:58 PM} else {
suggestions.sort();
format!(
- ", but there were @rules that could compute it using:\n {}",
+ " for input Params({}), but there were @rules that could compute it using:\n {}",
suggestions.join("\n ")
)
};
Err(format!(
- "No installed @rules can compute {} for input Params({}){}",
+ "No installed @rules can compute {}{}",
product,
params_str(¶ms),
suggestions_str,
No installed @rules can compute Repl.
hundreds-breakfast-49010
02/14/2020, 8:08 PMwitty-crayon-22786
02/14/2020, 8:10 PMhundreds-breakfast-49010
02/14/2020, 9:03 PM