[engine] Allow injecting of intrinsic providers to ease testing

Review Request #4263 — Created Sept. 26, 2016 and submitted

nhoward_tw
pants
3905
pants-reviews
kwlzn, stuhood, yujiec

It's currently a little hard to test the interactions between task rules and intrinsics because they are injected directly by the NodeBuilder. This change allows the intrinsic providers
to be overridden for testing.

I also added an error condition if two intrinsics have the same key.

It seems a little big, but that's mostly due to the moving of the intrinsic rule class declarations.

CI passed at https://travis-ci.org/pantsbuild/pants/builds/162879047, I ran engine tests locally.

  • 0
  • 0
  • 1
  • 0
  • 1
Description From Last Updated
NH
NH
WI
  1. 
      
  2. src/python/pants/engine/rules.py (Diff revision 1)
     
     
     
     
     
     

    Would it be better to find out all the conflicting keys instead of raising one at a time?

  3. 
      
NH
WI
  1. 
      
  2. src/python/pants/engine/rules.py (Diff revisions 1 - 2)
     
     

    maybe use intersection?

    >>> {1,2,3}.intersection({2,3,4})
    set([2, 3])
    
  3. 
      
ST
  1. 
      
  2. src/python/pants/engine/rules.py (Diff revision 2)
     
     
     

    The shuffle within the file seems to have broken formatting here. It's also makes it hard to tell whether you changed anything meaningful in these classes...

    1. I didn't change anything meaningful. I went with def ...(...=(Const, Const)) which meant that the classes needed to be declared before the NodeBuilder. I could have used the if ... is None: then default pattern instead, but I felt this was less complicated.

  3. 
      
KW
  1. Ship It!
  2. 
      
NH
Review request changed

Status: Closed (submitted)

Change Summary:

Submitted as https://github.com/pantsbuild/pants/commit/3d41b7bb430b298ed17c104988959757ef6ddee8
Loading...