def testRunStoryAndProcessErrorIfNeeded_tryAppCrash(self): tmp = tempfile.NamedTemporaryFile(delete=False) tmp.close() temp_file_path = tmp.name fake_app = fakes.FakeApp() fake_app.recent_minidump_path = temp_file_path try: app_crash_exception = exceptions.AppCrashException(fake_app, msg='foo') root_mock = self._CreateErrorProcessingMock( method_exceptions={'state.WillRunStory': app_crash_exception}) with self.assertRaises(exceptions.AppCrashException): story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test, self.finder_options) self.assertListEqual(root_mock.method_calls, [ mock.call.results.CreateArtifact('logs.txt'), mock.call.test.WillRunStory(root_mock.state.platform, root_mock.story), mock.call.state.WillRunStory(root_mock.story), mock.call.state.DumpStateUponStoryRunFailure( root_mock.results), mock.call.results.Fail( 'Exception raised running %s' % root_mock.story.name), mock.call.test.DidRunStory(root_mock.state.platform, root_mock.results), mock.call.state.DidRunStory(root_mock.results), ]) finally: os.remove(temp_file_path)
def testRunStoryAndProcessErrorIfNeeded_tryUnhandlable_finallyException( self): root_mock = self._CreateErrorProcessingMock( method_exceptions={ 'test.Measure': Exception('foo'), 'test.DidRunStory': Exception('bar') }) with self.assertRaisesRegexp(Exception, 'foo'): story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test, self.finder_options) self.assertEquals(root_mock.method_calls, [ mock.call.results.CreateArtifact('logs.txt'), mock.call.test.WillRunStory(root_mock.state.platform, root_mock.story), mock.call.state.WillRunStory(root_mock.story), mock.call.state.CanRunStory(root_mock.story), mock.call.state.RunStory(root_mock.results), mock.call.test.Measure(root_mock.state.platform, root_mock.results), mock.call.state.DumpStateUponStoryRunFailure(root_mock.results), mock.call.results.Fail( 'Exception raised running %s' % root_mock.story.name), mock.call.test.DidRunStory(root_mock.state.platform, root_mock.results), ])
def testRunStoryAndProcessErrorIfNeeded_tryTimeout_finallyException(self): root_mock = self._CreateErrorProcessingMock( method_exceptions={ 'state.RunStory': exceptions.TimeoutException('foo'), 'state.DidRunStory': Exception('bar') }) story_runner._RunStoryAndProcessErrorIfNeeded(root_mock.story, root_mock.results, root_mock.state, root_mock.test) self.assertEquals(root_mock.method_calls, [ mock.call.results.CreateArtifact('logs.txt'), mock.call.test.WillRunStory(root_mock.state.platform, root_mock.story), mock.call.state.WillRunStory(root_mock.story), mock.call.state.CanRunStory(root_mock.story), mock.call.state.RunStory(root_mock.results), mock.call.state.DumpStateUponStoryRunFailure(root_mock.results), mock.call.results.Fail( 'Exception raised running %s' % root_mock.story.name), mock.call.test.DidRunStory(root_mock.state.platform, root_mock.results), mock.call.state.DidRunStory(root_mock.results), ])
def testRunStoryAndProcessErrorIfNeeded_tryUnhandlable_finallyException( self): root_mock = self._CreateErrorProcessingMock( method_exceptions={ 'test.Measure': Exception('foo'), 'test.DidRunStory': Exception('bar') }) with self.assertRaisesRegexp(Exception, 'foo'): story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test) self.assertEquals(root_mock.method_calls, [ mock.call.state.platform.GetOSName(), mock.call.test.WillRunStory(root_mock.state.platform), mock.call.state.WillRunStory(root_mock.story), mock.call.state.CanRunStory(root_mock.story), mock.call.state.RunStory(root_mock.results), mock.call.test.Measure(root_mock.state.platform, root_mock.results), mock.call.state.DumpStateUponFailure(root_mock.story, root_mock.results), mock.call.results.AddValue(FailureValueMatcher('foo')), mock.call.state.DidRunStory(root_mock.results), mock.call.test.DidRunStory(root_mock.state.platform) ])
def testRunStoryAndProcessErrorIfNeeded_finallyException(self): exc = Exception('bar') root_mock = self._CreateErrorProcessingMock(method_exceptions={ 'state.DidRunStory': exc, }) with self.assertRaisesRegexp(Exception, 'bar'): story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test) self.assertEquals(root_mock.method_calls, [ mock.call.results.CreateArtifact('logs.txt'), mock.call.test.WillRunStory(root_mock.state.platform, root_mock.story), mock.call.state.WillRunStory(root_mock.story), mock.call.state.CanRunStory(root_mock.story), mock.call.state.RunStory(root_mock.results), mock.call.test.Measure(root_mock.state.platform, root_mock.results), mock.call.test.DidRunStory(root_mock.state.platform, root_mock.results), mock.call.state.DidRunStory(root_mock.results), mock.call.state.DumpStateUponStoryRunFailure(root_mock.results), ])
def testRunStoryAndProcessErrorIfNeeded_successLegacy(self): root_mock = self._CreateErrorProcessingMock(legacy_test=True) story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test) self.assertEquals(root_mock.method_calls, [ mock.call.state.WillRunStory(root_mock.story), mock.call.state.CanRunStory(root_mock.story), mock.call.state.RunStory(root_mock.results), mock.call.state.DidRunStory(root_mock.results), mock.call.test.DidRunPage(root_mock.state.platform) ])
def testRunStoryAndProcessErrorIfNeeded_tryUnsupportedAction_finallyException( self): root_mock = self._CreateErrorProcessingMock(method_exceptions={ 'test.WillRunStory': page_action.PageActionNotSupported('foo'), 'state.DidRunStory': Exception('bar') }) story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test) self.assertEquals(root_mock.method_calls, [ mock.call.test.WillRunStory(root_mock.state.platform), mock.call.results.AddValue(SkipValueMatcher()), mock.call.state.DidRunStory(root_mock.results) ])
def testRunStoryAndProcessErrorIfNeeded_tryUnhandlable(self): root_mock = self._CreateErrorProcessingMock(method_exceptions={ 'test.WillRunStory': Exception('foo') }) with self.assertRaisesRegexp(Exception, 'foo'): story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test) self.assertEquals(root_mock.method_calls, [ mock.call.test.WillRunStory(root_mock.state.platform), mock.call.state.DumpStateUponFailure(root_mock.story, root_mock.results), mock.call.results.AddValue(FailureValueMatcher('foo')), mock.call.state.DidRunStory(root_mock.results), mock.call.test.DidRunStory(root_mock.state.platform) ])
def testRunStoryAndProcessErrorIfNeeded_tryTimeout(self): root_mock = self._CreateErrorProcessingMock(method_exceptions={ 'state.WillRunStory': exceptions.TimeoutException('foo') }) story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test) self.assertEquals(root_mock.method_calls, [ mock.call.test.WillRunStory(root_mock.state.platform), mock.call.state.WillRunStory(root_mock.story), mock.call.state.DumpStateUponFailure(root_mock.story, root_mock.results), mock.call.results.AddValue(FailureValueMatcher('foo')), mock.call.state.DidRunStory(root_mock.results), mock.call.test.DidRunStory(root_mock.state.platform) ])
def testRunStoryAndProcessErrorIfNeeded_success(self): root_mock = self._CreateErrorProcessingMock() story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test) self.assertEquals(root_mock.method_calls, [ mock.call.results.CreateArtifact('logs.txt'), mock.call.test.WillRunStory(root_mock.state.platform, root_mock.story), mock.call.state.WillRunStory(root_mock.story), mock.call.state.CanRunStory(root_mock.story), mock.call.state.RunStory(root_mock.results), mock.call.test.Measure(root_mock.state.platform, root_mock.results), mock.call.test.DidRunStory(root_mock.state.platform, root_mock.results), mock.call.state.DidRunStory(root_mock.results), ])
def testRunStoryAndProcessErrorIfNeeded_tryUnsupportedAction(self): root_mock = self._CreateErrorProcessingMock(method_exceptions={ 'state.RunStory': page_action.PageActionNotSupported('foo') }) story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test) self.assertEquals(root_mock.method_calls, [ mock.call.results.CreateArtifact('logs.txt'), mock.call.test.WillRunStory(root_mock.state.platform, root_mock.story), mock.call.state.WillRunStory(root_mock.story), mock.call.state.CanRunStory(root_mock.story), mock.call.state.RunStory(root_mock.results), mock.call.results.Skip('Unsupported page action: foo'), mock.call.test.DidRunStory(root_mock.state.platform, root_mock.results), mock.call.state.DidRunStory(root_mock.results), ])
def testRunStoryAndProcessErrorIfNeeded_success(self): root_mock = self._CreateErrorProcessingMock() story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test) self.assertEquals(root_mock.method_calls, [ mock.call.state.platform.GetOSName(), mock.call.test.WillRunStory(root_mock.state.platform), mock.call.state.WillRunStory(root_mock.story), mock.call.state.CanRunStory(root_mock.story), mock.call.state.RunStory(root_mock.results), mock.call.test.Measure(root_mock.state.platform, root_mock.results), mock.call.state.DidRunStory(root_mock.results), mock.call.test.DidRunStory(root_mock.state.platform), mock.call.state.platform.GetOSName(), ])
def testRunStoryAndProcessErrorIfNeeded_finallyException(self): root_mock = self._CreateErrorProcessingMock(method_exceptions={ 'state.DidRunStory': Exception('bar') }) with self.assertRaisesRegexp(Exception, 'bar'): story_runner._RunStoryAndProcessErrorIfNeeded( root_mock.story, root_mock.results, root_mock.state, root_mock.test) self.assertEquals(root_mock.method_calls, [ mock.call.test.WillRunStory(root_mock.state.platform), mock.call.state.WillRunStory(root_mock.story), mock.call.state.CanRunStory(root_mock.story), mock.call.state.RunStory(root_mock.results), mock.call.test.Measure(root_mock.state.platform, root_mock.results), mock.call.state.DidRunStory(root_mock.results), mock.call.state.DumpStateUponFailure(root_mock.story, root_mock.results) ])