Fix test_execute_fail.

Review Request #2461 - Created July 11, 2015 and submitted

John Sirois
gmalmquist, zundel

This fixes test_execute, but not the underlying global state used in
DummyTask. Its that state, that appears to have supported a successful
run under certain sharding / test method ordering, although I was not
able to positively identify a sequence of calls that would lead to
test_execute ever passing.

In particular, it had 2 local errors that look systemic:

  1. The raises regex did not escape the parens.
    Before this fix, the regex only could match 'Failed to generate
    targets' - with 's' being in an unused capture group.
  2. The assertRaisesRegexp callable argument was not a callable.
    The result of task.execute() was passed instead of the task.execute

These system errors were in addition to the lack of setup of the global
strategy explicitly. That strategy is needed to ensure DummyGen's
execute_codegen is called leading to the raise. Using the isolated
strategy (which was the default) with no targets short circuits the
execute_codegen call, failing to ever engage the should_fail forced

tests/python/pants_test/backend/codegen/tasks/ | 17 +++++++----------
1 file changed, 7 insertions(+), 10 deletions(-)


$ ./pants test tests/python/pants_test/backend/codegen/tasks:simple_codegen_task
tests/python/pants_test/backend/codegen/tasks/ .....F.

==================== FAILURES ====================
____ SimpleCodegenTaskTest.test_execute_fail _____

self = <test_simple_codegen_task.SimpleCodegenTaskTest testMethod=test_execute_fail>

   def test_execute_fail(self):
     task = self._create_dummy_task()
     task.should_fail = True
>     self.assertRaisesRegexp(TaskError, 'Failed to generate target(s)', task.execute())
E     TypeError: 'NoneType' object is not callable

tests/python/pants_test/backend/codegen/tasks/ TypeError

After - success.

CI went green here:

John Sirois
John Sirois
Eric Ayers
John Sirois
Eric Ayers
John Sirois
John Sirois
John Sirois
Review request changed

Status: Closed (submitted)