コード例 #1
0
    def test_test_timings_trie(self):
        test_port = test.TestPort(MockHost())
        individual_test_timings = []
        individual_test_timings.append(json_results_generator.TestResult("foo/bar/baz.html", elapsed_time=1.2))
        individual_test_timings.append(json_results_generator.TestResult("bar.html", elapsed_time=0.0001))
        trie = json_results_generator.test_timings_trie(test_port, individual_test_timings)

        expected_trie = {"bar.html": 0, "foo": {"bar": {"baz.html": 1200}}}

        self.assertEqual(simplejson.dumps(trie), simplejson.dumps(expected_trie))
コード例 #2
0
    def _generate_json_file(self, json, file_path):
        # Specify separators in order to get compact encoding.
        json_data = simplejson.dumps(json, separators=(',', ':'))
        json_string = self.JSON_PREFIX + json_data + self.JSON_SUFFIX

        results_file = codecs.open(file_path, "w", "utf-8")
        results_file.write(json_string)
        results_file.close()
コード例 #3
0
    def test_test_timings_trie(self):
        test_port = test.TestPort()
        individual_test_timings = []
        individual_test_timings.append(json_results_generator.TestResult('foo/bar/baz.html', elapsed_time=1.2))
        individual_test_timings.append(json_results_generator.TestResult('bar.html', elapsed_time=0.0001))
        trie = json_results_generator.test_timings_trie(test_port, individual_test_timings)

        expected_trie = {
          'bar.html': 0,
          'foo': {
              'bar': {
                  'baz.html': 1200,
              }
          }
        }

        self.assertEqual(simplejson.dumps(trie), simplejson.dumps(expected_trie))
コード例 #4
0
    def _generate_json_file(self, json, file_path):
        # Specify separators in order to get compact encoding.
        json_data = simplejson.dumps(json, separators=(',', ':'))
        json_string = self.JSON_PREFIX + json_data + self.JSON_SUFFIX

        results_file = codecs.open(file_path, "w", "utf-8")
        results_file.write(json_string)
        results_file.close()
コード例 #5
0
    def test_test_timings_trie(self):
        test_port = test.TestPort(MockHost())
        individual_test_timings = []
        individual_test_timings.append(
            json_results_generator.TestResult('foo/bar/baz.html',
                                              elapsed_time=1.2))
        individual_test_timings.append(
            json_results_generator.TestResult('bar.html', elapsed_time=0.0001))
        trie = json_results_generator.test_timings_trie(
            test_port, individual_test_timings)

        expected_trie = {
            'bar.html': 0,
            'foo': {
                'bar': {
                    'baz.html': 1200,
                }
            }
        }

        self.assertEqual(simplejson.dumps(trie),
                         simplejson.dumps(expected_trie))
コード例 #6
0
    def _get_json(self):
        """Gets the results for the results.json file."""
        results_json, error = self._get_archived_json_results()
        if error:
            # If there was an error don't write a results.json
            # file at all as it would lose all the information on the bot.
            _log.error("Archive directory is inaccessible. Not modifying "
                       "or clobbering the results.json file: " + str(error))
            return None

        builder_name = self._builder_name
        if results_json and builder_name not in results_json:
            _log.debug("Builder name (%s) is not in the results.json file."
                       % builder_name)

        self._convert_json_to_current_version(results_json)

        if builder_name not in results_json:
            results_json[builder_name] = (
                self._create_results_for_builder_json())

        results_for_builder = results_json[builder_name]

        self._insert_generic_metadata(results_for_builder)

        self._insert_failure_summaries(results_for_builder)

        # Update the all failing tests with result type and time.
        tests = results_for_builder[self.TESTS]
        all_failing_tests = set(self._failures.iterkeys())
        all_failing_tests.update(tests.iterkeys())
        for test in all_failing_tests:
            self._insert_test_time_and_result(test, tests)

        # Specify separators in order to get compact encoding.
        results_str = simplejson.dumps(results_json, separators=(',', ':'))
        return self.JSON_PREFIX + results_str + self.JSON_SUFFIX
コード例 #7
0
    def _get_json(self):
        """Gets the results for the results.json file."""
        results_json, error = self._get_archived_json_results()
        if error:
            # If there was an error don't write a results.json
            # file at all as it would lose all the information on the bot.
            _log.error("Archive directory is inaccessible. Not modifying "
                       "or clobbering the results.json file: " + str(error))
            return None

        builder_name = self._builder_name
        if results_json and builder_name not in results_json:
            _log.debug("Builder name (%s) is not in the results.json file." %
                       builder_name)

        self._convert_json_to_current_version(results_json)

        if builder_name not in results_json:
            results_json[builder_name] = (
                self._create_results_for_builder_json())

        results_for_builder = results_json[builder_name]

        self._insert_generic_metadata(results_for_builder)

        self._insert_failure_summaries(results_for_builder)

        # Update the all failing tests with result type and time.
        tests = results_for_builder[self.TESTS]
        all_failing_tests = set(self._failures.iterkeys())
        all_failing_tests.update(tests.iterkeys())
        for test in all_failing_tests:
            self._insert_test_time_and_result(test, tests)

        # Specify separators in order to get compact encoding.
        results_str = simplejson.dumps(results_json, separators=(',', ':'))
        return self.JSON_PREFIX + results_str + self.JSON_SUFFIX
コード例 #8
0
def write_json(filesystem, json_object, file_path):
    # Specify separators in order to get compact encoding.
    json_data = simplejson.dumps(json_object, separators=(',', ':'))
    json_string = _JSON_PREFIX + json_data + _JSON_SUFFIX
    filesystem.write_text_file(file_path, json_string)
コード例 #9
0
 def _generate_json_file(self, json, file_path):
     # Specify separators in order to get compact encoding.
     json_data = simplejson.dumps(json, separators=(',', ':'))
     json_string = self.JSON_PREFIX + json_data + self.JSON_SUFFIX
     self._fs.write_text_file(file_path, json_string)
コード例 #10
0
def write_json(filesystem, json_object, file_path):
    # Specify separators in order to get compact encoding.
    json_data = simplejson.dumps(json_object, separators=(',', ':'))
    json_string = _JSON_PREFIX + json_data + _JSON_SUFFIX
    filesystem.write_text_file(file_path, json_string)