Introduce a PythonEval task.

Review Request #1772 — Created Feb. 15, 2015 and submitted

jsirois
pants
jsirois/python/compile
1106
1725, 1773
0cfbb6c...
pants-reviews
benjyw, nhoward_tw, stuhood, zundel
This task can be used to smoke out broken python code at "compile" time.
In particular, invalid imports (missing BUILD deps), top-level syntax
errors and top-level checks can be detected.

 src/python/pants/backend/python/tasks/BUILD                                  |  15 +++-
 src/python/pants/backend/python/tasks/python_eval.py                         | 149 ++++++++++++++++++++++++++++++++
 src/python/pants/backend/python/tasks/templates/python_eval/eval.py.mustache |  44 ++++++++++
 tests/python/pants_test/backend/python/BUILD                                 |   1 +
 tests/python/pants_test/backend/python/tasks/BUILD                           |  21 +++++
 tests/python/pants_test/backend/python/tasks/__init__.py                     |   0
 tests/python/pants_test/backend/python/tasks/test_python_eval.py             | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++
 tests/python/pants_test/tasks/BUILD                                          |   1 +
 tests/python/pants_test/tasks/test_base.py                                   |   8 ++
 9 files changed, 470 insertions(+), 3 deletions(-)
CI went green here:
  https://travis-ci.org/pantsbuild/pants/builds/50805808
  • 0
  • 0
  • 1
  • 0
  • 1
Description From Last Updated
JS
  1. This was spawned from discussion on https://rbcommons.com/s/twitter/r/1725/
  2. 
      
JS
JS
  1. Final note: this RB is built upon by https://rbcommons.com/s/twitter/r/1773/ where the PythonEval task in installed and used in pants ci to check pants source code.
  2. 
      
BE
  1. Looks cool! Must have been fun to write.

  2. Remove the trailing hash.

  3. I don't like the idea of the return value of execute() being some freeform thing any task can do whatever it wants with. Maybe these should be products that the test can then check for?

    I could be convinced that this is OK for now, I guess, but once we lock down the lifecycle in the new engine, these should just be products.

    1. Agreed - I think the trade of good test coverage from the get-go is well worth it though.
  4. This could use a comment about what the template generates.

  5. 
      
JS
JS
  1. Thanks Benjy - submitted @ https://github.com/pantsbuild/pants/commit/7b09326d985751c3077d7eb603d2bb45ef19f9c0
  2. 
      
JS
Review request changed

Status: Closed (submitted)

BE
  1. Which reminds me - let's make sure that the new product engine has a robust story around testing...

  2. 
      
Loading...