Compile/Test "changed" targets

Review Request #1572 - Created Jan. 7, 2015 and submitted

David Taylor
benjyw, dturner-tw, jsirois, patricklaw, zundel

I think pretty much everyone has implmented some variation on this in wrappers, but with some refactoring recently in WhatChanged and elsehwere, actual implementation of this as a proper pants task is pretty trivial now -- the comments are longer then the code.

  • SCM changed target calculation is provided by a mixin (the same as is used by WhatChanged).
  • The actual "compile" or "test" is just done by the existing goal -- this just asks round manager to schedule that.

Thus "compile-changed" doesn't subclass a compile task, or even have any "compile" related functionality, but rather just asks the round manager to run "compile" for it after it replaces the target roots by consulting WhatChanged at the begining of its prepare method.

I'm not super crazy about doing the root replacement in prepare -- ideally I'd prefer a dedicated method on Task that can optionally return alternative target roots. Tasks that want to find their own targets, like those in this change, would override that, then the round engine could ensure at-most-one target returned non-None and do the swap. However that currently isn't possible (discussed further here:

Thanks to, the approach used here should be safe though -- that change should at least ensure that if one of these tasks were mis-scheduled, it would crash and fail tests quickly, rather than potentially harming correctness more sublety later.

PANTS_DEV=1 ./pants test tests/python/pants_test/tasks:changed_target_integration

Note the change to actually needs to be merged in a separate commit first, and its SHA placed in ref_for_greet_change in the integration test. An integration test seemed like the best way to test this, but unfortunately that makes mocking SCM difficult, so this needs an actual change ref in the pants commit log that changes a known target for it to compile/test.


  • 0
  • 7
  • 0
  • 7
Description From Last Updated
David Taylor
David Turner
David Turner
David Turner
Benjy Weinberger
Patrick Lawson
David Taylor
Review request changed

Status: Closed (submitted)

Change Summary: