示例#1
0
  def RunStorySetAndGetResults(self, story_set):
    dummy_test = test_stories.DummyStoryTest()
    with results_options.CreateResults(self.options) as results:
      story_runner.RunStorySet(dummy_test, story_set, self.options, results)

    test_results = results_options.ReadIntermediateResults(
        self.options.intermediate_dir)['testResults']
    self.assertEqual(len(test_results), 1)
    return test_results[0]
  def testAddMeasurementAsScalar(self):
    with self.CreateResults() as results:
      results.WillRunPage(self.pages[0])
      results.AddMeasurement('a', 'seconds', 3)
      results.DidRunPage(self.pages[0])

    test_results = results_options.ReadIntermediateResults(
        self.intermediate_dir)['testResults']
    self.assertTrue(len(test_results), 1)
    measurements = results_options.ReadMeasurements(test_results[0])
    self.assertEqual(measurements, {'a': {'unit': 'seconds', 'samples': [3]}})
  def testAddMeasurementAsHistogram(self):
    # TODO(999484): Temporary test while we migrate benchmarks writing "ad hoc"
    # histograms to directly use measurements instead.
    with self.CreateResults() as results:
      results.WillRunPage(self.pages[0])
      results.AddHistogram(histogram_module.Histogram.Create(
          'a', 'ms', [1000, 2000, 3000]))
      results.DidRunPage(self.pages[0])

    test_results = results_options.ReadIntermediateResults(
        self.intermediate_dir)['testResults']
    self.assertTrue(len(test_results), 1)
    measurements = results_options.ReadMeasurements(test_results[0])
    self.assertEqual(measurements,
                     {'a': {'unit': 'ms', 'samples': [1000, 2000, 3000]}})
 def RunBenchmarkAndReadResults(self, test_benchmark):
     story_runner.RunBenchmark(test_benchmark, self.options)
     test_results = results_options.ReadIntermediateResults(
         self.options.intermediate_dir)['testResults']
     self.assertEqual(len(test_results), 1)
     return test_results[0]