Example #1
0
  def test_trace_includes_rule_exception_traceback(self):
    rules = [
      TaskRule(A, [Select(B)], nested_raise)
    ]

    scheduler = create_native_scheduler({B}, rules)
    subject = B()
    scheduler.add_root_selection(subject, Select(A))
    scheduler.run_and_return_stat()

    trace = '\n'.join(scheduler.graph_trace())
    # NB removing location info to make trace repeatable
    trace = remove_locations_from_traceback(trace)

    assert_equal_with_printing(self, dedent('''
                     Computing Select(<pants_test.engine.test_scheduler.B object at 0xEEEEEEEEE>, =A)
                       Computing Task(<function nested_raise at 0xEEEEEEEEE>, <pants_test.engine.test_scheduler.B object at 0xEEEEEEEEE>, =A)
                         Throw(An exception for B)
                           Traceback (most recent call last):
                             File LOCATION-INFO, in extern_invoke_runnable
                               val = runnable(*args)
                             File LOCATION-INFO, in nested_raise
                               fn_raises(x)
                             File LOCATION-INFO, in fn_raises
                               raise Exception('An exception for {}'.format(type(x).__name__))
                           Exception: An exception for B''').lstrip() + '\n\n', # Traces include two empty lines after.
                               trace)
Example #2
0
    def test_trace_includes_rule_exception_traceback(self):
        rules = [RootRule(B), TaskRule(A, [Select(B)], nested_raise)]

        scheduler = create_native_scheduler(rules)
        request = scheduler._native.new_execution_request()
        subject = B()
        scheduler.add_root_selection(request, subject, A)
        scheduler.run_and_return_roots(request)

        trace = '\n'.join(scheduler.graph_trace(request))
        # NB removing location info to make trace repeatable
        trace = remove_locations_from_traceback(trace)

        assert_equal_with_printing(
            self,
            dedent('''
                     Computing Select(<pants_test.engine.test_scheduler.B object at 0xEEEEEEEEE>, =A)
                       Computing Task(<function nested_raise at 0xEEEEEEEEE>, <pants_test.engine.test_scheduler.B object at 0xEEEEEEEEE>, =A)
                         Throw(An exception for B)
                           Traceback (most recent call last):
                             File LOCATION-INFO, in extern_invoke_runnable
                               val = runnable(*args)
                             File LOCATION-INFO, in nested_raise
                               fn_raises(x)
                             File LOCATION-INFO, in fn_raises
                               raise Exception('An exception for {}'.format(type(x).__name__))
                           Exception: An exception for B''').lstrip() +
            '\n\n',  # Traces include two empty lines after.
            trace)
Example #3
0
  def test_trace_includes_rule_exception_traceback(self):
    rules = [
      RootRule(B),
      TaskRule(A, [Select(B)], nested_raise)
    ]

    scheduler = create_scheduler(rules)
    request = scheduler._native.new_execution_request()
    subject = B()
    scheduler.add_root_selection(request, subject, A)
    session = scheduler.new_session()
    scheduler._run_and_return_roots(session._session, request)

    trace = '\n'.join(scheduler.graph_trace(request))
    # NB removing location info to make trace repeatable
    trace = remove_locations_from_traceback(trace)

    assert_equal_with_printing(self, dedent('''
                     Computing Select(<pants_test.engine.test_scheduler.B object at 0xEEEEEEEEE>, =A)
                       Computing Task(nested_raise, <pants_test.engine.test_scheduler.B object at 0xEEEEEEEEE>, =A)
                         Throw(An exception for B)
                           Traceback (most recent call last):
                             File LOCATION-INFO, in call
                               val = func(*args)
                             File LOCATION-INFO, in nested_raise
                               fn_raises(x)
                             File LOCATION-INFO, in fn_raises
                               raise Exception('An exception for {}'.format(type(x).__name__))
                           Exception: An exception for B''').lstrip() + '\n\n', # Traces include two empty lines after.
                               trace)
Example #4
0
 def test_trace_includes_rule_exception_traceback(self):
   # Execute a request that will trigger the nested raise, and then directly inspect its trace.
   request = self.scheduler.execution_request([A], [B()])
   self.scheduler.execute(request)
   
   trace = remove_locations_from_traceback('\n'.join(self.scheduler.trace(request)))
   assert_equal_with_printing(self, dedent('''
                    Computing Select(<pants_test.engine.test_scheduler.B object at 0xEEEEEEEEE>, A)
                      Computing Task(nested_raise(), <pants_test.engine.test_scheduler.B object at 0xEEEEEEEEE>, A, true)
                        Throw(An exception for B)
                          Traceback (most recent call last):
                            File LOCATION-INFO, in call
                              val = func(*args)
                            File LOCATION-INFO, in nested_raise
                              fn_raises(x)
                            File LOCATION-INFO, in fn_raises
                              raise Exception('An exception for {}'.format(type(x).__name__))
                          Exception: An exception for B''').lstrip() + '\n\n', # Traces include two empty lines after.
                              trace)
Example #5
0
  def test_trace_includes_rule_exception_traceback(self):
    # Execute a request that will trigger the nested raise, and then directly inspect its trace.
    request = self.scheduler.execution_request([A], [B()])
    self.scheduler.execute(request)

    trace = remove_locations_from_traceback('\n'.join(self.scheduler.trace(request)))
    assert_equal_with_printing(self, dedent('''
                     Computing Select(<pants_test.engine.test_scheduler.B object at 0xEEEEEEEEE>, A)
                       Computing Task(nested_raise(), <pants_test.engine.test_scheduler.B object at 0xEEEEEEEEE>, A, true)
                         Throw(An exception for B)
                           Traceback (most recent call last):
                             File LOCATION-INFO, in call
                               val = func(*args)
                             File LOCATION-INFO, in nested_raise
                               fn_raises(x)
                             File LOCATION-INFO, in fn_raises
                               raise Exception('An exception for {}'.format(type(x).__name__))
                           Exception: An exception for B''').lstrip() + '\n\n', # Traces include two empty lines after.
                               trace)