Fix PythonThriftBuilder to operate on 1 target.

Review Request #2696 - Created Aug. 24, 2015 and submitted

Information
John Sirois
pants
jsirois/issues/2005
2005, 2054, 2062
5da15e6...
Reviewers
pants-reviews
benjyw, kwlzn, zundel
Previously it operated on the closure of thrift files depended on by a
single PythonThriftLibrary and this trampled on work both PythonChroot
and SetupPy did to walk the closure and link together CodeGenerator
outputs.  This brings PythonThriftBuilder into line PythonAntlrBuilder
and fixes 2 bugs.

Tests are added that fail before the fix and pass after.

 src/python/pants/backend/python/BUILD                         |  5 +--
 src/python/pants/backend/python/python_chroot.py              |  9 +----
 src/python/pants/backend/python/tasks/setup_py.py             | 10 +++--
 src/python/pants/backend/python/thrift_builder.py             | 58 ++++++++++-------------------
 tests/python/pants_test/backend/python/tasks/BUILD            |  1 +
 tests/python/pants_test/backend/python/tasks/test_setup_py.py | 99 +++++++++++++++++++++++++++++++++++++++++++-------
 tests/python/pants_test/backend/python/test_python_chroot.py  | 54 ++++++++++++++++++++++-----
 7 files changed, 161 insertions(+), 75 deletions(-)

After adding the 2 tests but before the fix:

$ ./pants test tests/python/pants_test/backend/python/tasks/:setup_py -- -vktest_exported_thrift_issues_2005
...
         with extracted_sdist(target2, 'test.exported_dependee-0.0.0') as (py_files, path):
           self.assertEqual({path('setup.py'),
                             path('src/__init__.py'),
                             path('src/exported_dependee/__init__.py'),
                             path('src/exported_dependee/constants.py'),
                             path('src/exported_dependee/ttypes.py')},
 >                          py_files)
 E         AssertionError: Items in the second set but not the first:
 E         '/tmp/tmpMLYtFG/test.exported_dependee-0.0.0/src/exported/constants.py'
 E         '/tmp/tmpMLYtFG/test.exported_dependee-0.0.0/src/exported/__init__.py'
 E         '/tmp/tmpMLYtFG/test.exported_dependee-0.0.0/src/exported/ttypes.py'
...

$ ./pants test tests/python/pants_test/backend/python:python_chroot -- -vktest_thrift_issues_2005
...
 tests/python/pants_test/backend/python/test_python_chroot.py:200: in do_test_thrift
     inspect_chroot(python_chroot)
 tests/python/pants_test/backend/python/test_python_chroot.py:241: in inspect_chroot
     self.assertEqual(2, len(all_constants_files))
 E   AssertionError: 2 != 3
...

Both green after the fix.

This pants also works on the test Wyatt created on the thrift-include
branch of https://github.com/wyattanderson/pantstest

CI went green here:
https://travis-ci.org/pantsbuild/pants/builds/77183330

Benjy Weinberger
John Sirois
John Sirois
John Sirois
Review request changed

Status: Closed (submitted)

Loading...