コード例 #1
0
    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)
コード例 #2
0
    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),
        ])
コード例 #3
0
    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),
        ])
コード例 #4
0
    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)
        ])
コード例 #5
0
    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),
        ])
コード例 #6
0
  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)
    ])
コード例 #7
0
  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)
    ])
コード例 #8
0
  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)
    ])
コード例 #9
0
  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)
    ])
コード例 #10
0
  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)
    ])
コード例 #11
0
  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)
    ])
コード例 #12
0
  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),
    ])
コード例 #13
0
  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)
    ])
コード例 #14
0
  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),
    ])
コード例 #15
0
  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(),
    ])
コード例 #16
0
  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)
    ])