Guard scala_library from linking itself as a dep.

Review Request #251 — Created April 18, 2014 and submitted

jsirois
pants
jsirois/scala_java/avoid_stitched_cycles
72
pants-reviews
benjyw, ity, tejal, travis
commit 3894ca2f12d7550090b3c404b76bc37dc0c32e6a
Author: John Sirois <jsirois@twitter.com>
Date:   Fri Apr 18 11:23:43 2014 -0700

    Guard scala_library from linking itself as a dep.
    
    In situations where we have a mixed scala-java library we
    add the java_library deps into the scala_library during a linking
    phase.  This linking was not filtering out the scala_library
    itself, leading to a linked cycle.  Fix this and add a unit
    test to verify linking semantics.

 src/python/pants/targets/scala_library.py             |  5 ++--
 tests/python/pants_test/targets/BUILD                 | 11 ++++++++
 tests/python/pants_test/targets/test_scala_library.py | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 2 deletions(-)
New unit test without the fix:
$ ./pants tests/python/pants_test/targets:scala_library -v --tb=line
Build operating on targets: OrderedSet([PythonTests(tests/python/pants_test/targets/BUILD:scala_library)])
============================================================================================================================== test session starts ===============================================================================================================================
platform linux3 -- Python 2.6.8 -- py-1.4.20 -- pytest-2.5.2 -- /home/jsirois/dev/3rdparty/pyenv/versions/2.6.8/bin/python
plugins: cov
collected 1 items 

tests/python/pants_test/targets/test_scala_library.py:62: ScalaLibraryTest.test_mixed_linkage FAILED

==================================================================================================================================== FAILURES ====================================================================================================================================
/home/jsirois/dev/3rdparty/pantsbuild-pants/tests/python/pants_test/targets/test_scala_library.py:64: AssertionError: The scala end of a mixed language logical lib should be linked with the javacode deps excluding itself.



And with the fix we are green:
$ ./pants tests/python/pants_test/targets:scala_library -v --tb=line
Build operating on targets: OrderedSet([PythonTests(tests/python/pants_test/targets/BUILD:scala_library)])
============================================================================================================================== test session starts ===============================================================================================================================
platform linux3 -- Python 2.6.8 -- py-1.4.20 -- pytest-2.5.2 -- /home/jsirois/dev/3rdparty/pyenv/versions/2.6.8/bin/python
plugins: cov
collected 1 items 

tests/python/pants_test/targets/test_scala_library.py:62: ScalaLibraryTest.test_mixed_linkage PASSED

============================================================================================================================ 1 passed in 0.24 seconds ============================================================================================================================
TR
  1. Ship It!
  2. 
      
JS
TR
  1. Ship It!
  2. 
      
IT
  1. Ship It!
  2. 
      
JS
  1. Thanks folks - merged.
  2. 
      
JS
Review request changed

Status: Closed (submitted)

Loading...