Пример #1
0
def _gather_unexpected_results(filesystem, options):
    """Returns the unexpected results from the previous run, if any."""
    last_unexpected_results = []
    if options.print_last_failures or options.retest_last_failures:
        unexpected_results_filename = filesystem.join(
            options.results_directory, "unexpected_results.json")
        if filesystem.exists(unexpected_results_filename):
            content = filesystem.read_text_file(unexpected_results_filename)
            results = simplejson.loads(content)
            last_unexpected_results = results['tests'].keys()
    return last_unexpected_results
                old_results = results_file.read()
            except urllib2.HTTPError, http_error:
                # A non-4xx status code means the bot is hosed for some reason
                # and we can't grab the results.json file off of it.
                if (http_error.code < 400 and http_error.code >= 500):
                    error = http_error
            except urllib2.URLError, url_error:
                error = url_error

        if old_results:
            # Strip the prefix and suffix so we can get the actual JSON object.
            old_results = old_results[len(self.JSON_PREFIX):
                                      len(old_results) - len(self.JSON_SUFFIX)]

            try:
                results_json = simplejson.loads(old_results)
            except:
                _log.debug("results.json was not valid JSON. Clobbering.")
                # The JSON file is not valid JSON. Just clobber the results.
                results_json = {}
        else:
            _log.debug('Old JSON results do not exist. Starting fresh.')
            results_json = {}

        return results_json, error

    def _insert_failure_summaries(self, results_for_builder):
        """Inserts aggregate pass/failure statistics into the JSON.
        This method reads self._test_results and generates
        FIXABLE, FIXABLE_COUNT and ALL_FIXABLE_COUNT entries.
def load_json(filesystem, file_path):
    content = filesystem.read_text_file(file_path)
    content = strip_json_wrapper(content)
    return simplejson.loads(content)
def load_json(filesystem, file_path):
    content = filesystem.read_text_file(file_path)
    content = strip_json_wrapper(content)
    return simplejson.loads(content)
            info = results_file.info()
            old_results = results_file.read()
        except urllib2.HTTPError, http_error:
            # A non-4xx status code means the bot is hosed for some reason
            # and we can't grab the results.json file off of it.
            if (http_error.code < 400 and http_error.code >= 500):
                error = http_error
        except urllib2.URLError, url_error:
            error = url_error

        if old_results:
            # Strip the prefix and suffix so we can get the actual JSON object.
            old_results = strip_json_wrapper(old_results)

            try:
                results_json = simplejson.loads(old_results)
            except:
                _log.debug("results.json was not valid JSON. Clobbering.")
                # The JSON file is not valid JSON. Just clobber the results.
                results_json = {}
        else:
            _log.debug('Old JSON results do not exist. Starting fresh.')
            results_json = {}

        return results_json, error

    def _insert_failure_summaries(self, results_for_builder):
        """Inserts aggregate pass/failure statistics into the JSON.
        This method reads self._test_results and generates
        FIXABLE, FIXABLE_COUNT and ALL_FIXABLE_COUNT entries.