~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/testing/__init__.py

[rs=buildbot-poller] automatic merge from stable. Revisions: 14253,
        14254, 14255, 14256, 14257, 14258, 14259 included.

Show diffs side-by-side

added added

removed removed

Lines of Context:
827
827
 
828
828
    layer = None
829
829
    suite_name = ''
830
 
    js_timeout = 30000
 
830
    # 30 seconds for the suite.
 
831
    suite_timeout = 30000
 
832
    # By default we do not restrict per-test or times.  yuixhr tests do.
 
833
    incremental_timeout = None
 
834
    initial_timeout = None
831
835
    html_uri = None
832
836
    test_path = None
833
837
 
858
862
        # twisted tests to break because of gtk's initialize.
859
863
        import html5browser
860
864
        client = html5browser.Browser()
861
 
        page = client.load_page(self.html_uri, timeout=self.js_timeout)
 
865
        page = client.load_page(self.html_uri,
 
866
                                timeout=self.suite_timeout,
 
867
                                initial_timeout=self.initial_timeout,
 
868
                                incremental_timeout=self.incremental_timeout)
 
869
        report = None
 
870
        if page.content:
 
871
            report = simplejson.loads(page.content)
862
872
        if page.return_code == page.CODE_FAIL:
863
873
            self._yui_results = self.TIMEOUT
 
874
            self._last_test_info = report
864
875
            return
865
876
        # Data['type'] is complete (an event).
866
877
        # Data['results'] is a dict (type=report)
867
878
        # with 1 or more dicts (type=testcase)
868
879
        # with 1 for more dicts (type=test).
869
 
        report = simplejson.loads(page.content)
870
880
        if report.get('type', None) != 'complete':
871
881
            # Did not get a report back.
872
882
            self._yui_results = self.MISSING_REPORT
890
900
        from here.
891
901
        """
892
902
        if self._yui_results == self.TIMEOUT:
893
 
            self.fail("js timed out.")
 
903
            msg = 'JS timed out.'
 
904
            if self._last_test_info is not None:
 
905
                try:
 
906
                    msg += ('  The last test that ran to '
 
907
                            'completion before timing out was '
 
908
                            '%(testCase)s:%(testName)s.  The test %(type)sed.'
 
909
                            % self._last_test_info)
 
910
                except (KeyError, TypeError):
 
911
                    msg += ('  The test runner received an unexpected error '
 
912
                            'when trying to show information about the last '
 
913
                            'test to run.  The data it received was %r.'
 
914
                            % (self._last_test_info,))
 
915
            elif (self.incremental_timeout is not None or
 
916
                  self.initial_timeout is not None):
 
917
                msg += '  The test may never have started.'
 
918
            self.fail(msg)
894
919
        elif self._yui_results == self.MISSING_REPORT:
895
920
            self.fail("The data returned by js is not a test report.")
896
921
        elif self._yui_results is None or len(self._yui_results) == 0: