Explicitly track when synthetic targets are injected.

Review Request #3277 — Created Dec. 20, 2015 and submitted

patricklaw
pants
2749
pants-reviews
benjyw, jsirois, molsen, zundel

Previously some degree of tracking was done in Context to ensure
that synthetic targets were pulled into context.targets() if their
concrete ancestors were in the root targets of the graph. However,
recent work by Matt Olsen in https://rbcommons.com/s/twitter/r/3225/
revealed a more subtle issue with BuildGraph's handling of
synthetic targets: some synthetic targets do not have meaningful
ancestors, and we currently don't model that case.

This change makes it so that being "derived from" some other target
is sufficient but no longer necessary to be considered "synthetic".
Callers of BuildGraph.inject_target can now pass synthetic=True
to force this attribute of a target, even if it does not derive
from another target. In particular, BuildGraph.inject_synthetic_target
passes synthetic=True.

CI is green:
https://travis-ci.org/pantsbuild/pants/builds/97998009

PA
BE
  1. Ship It!
  2. 
      
ZU
  1. Now we are tracking synthetic targets in two places. I think there is code in context.py that tracks synthetic targets in Context._synthetic_targets that could be thrown out in favor of tracking synthetic targets in BuildGraph.

  2. Add a test for this

    1. What specifically about it? The tests I added cover both the negative and the positive case of a target being within this set.

    2. What I was thinking of is resetting the build graph and making sure the set of synthetic targets is reset along with it.

    3. Ah, I see. I'm going to punt on that since it's shoring up something we might need to test, but this change is fixing an outstanding bug others are blocking on. If reset() wasn't working in practice, we would have seen it long ago in many of our unit tests that rely on it.

  3. 
      
PA
ZU
  1. 
      
  2. 
      
PA
PA
Review request changed

Status: Closed (submitted)

Change Summary:

Upstream @ 25dc26d988ef59da8e1b00385cc0570f1ca06f5f

Loading...