blob: fd901a01de65a0a2f5b500073c49e359e5c762cf [file] [log] [blame]
dsinclair2a8a20c2016-04-25 09:46:17 -07001#!/usr/bin/env python
2# Copyright 2016 The PDFium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
dsinclair849284d2016-05-17 06:13:36 -07006import functools
7import multiprocessing
dsinclair2a8a20c2016-04-25 09:46:17 -07008import optparse
9import os
10import re
dsinclair849284d2016-05-17 06:13:36 -070011import shutil
dsinclair2a8a20c2016-04-25 09:46:17 -070012import subprocess
13import sys
14
15import common
stephanafa05e972017-01-02 06:19:41 -080016import gold
dsinclair2a8a20c2016-04-25 09:46:17 -070017import pngdiffer
18import suppressor
19
Ryan Harrison70cca362018-08-10 18:55:46 +000020# Arbitrary timestamp, expressed in seconds since the epoch, used to make sure
21# that tests that depend on the current time are stable. Happens to be the
22# timestamp of the first commit to repo, 2014/5/9 17:48:50.
23TEST_SEED_TIME = "1399672130"
24
Lei Zhang30543372019-11-19 19:02:30 +000025
26class KeyboardInterruptError(Exception):
27 pass
28
dsinclair849284d2016-05-17 06:13:36 -070029
dsinclair2a8a20c2016-04-25 09:46:17 -070030# Nomenclature:
31# x_root - "x"
32# x_filename - "x.ext"
33# x_path - "path/to/a/b/c/x.ext"
34# c_dir - "path/to/a/b/c"
35
Lei Zhang30543372019-11-19 19:02:30 +000036
dsinclair849284d2016-05-17 06:13:36 -070037def TestOneFileParallel(this, test_case):
38 """Wrapper to call GenerateAndTest() and redirect output to stdout."""
39 try:
40 input_filename, source_dir = test_case
Lei Zhang30543372019-11-19 19:02:30 +000041 result = this.GenerateAndTest(input_filename, source_dir)
dsinclair849284d2016-05-17 06:13:36 -070042 return (result, input_filename, source_dir)
43 except KeyboardInterrupt:
44 raise KeyboardInterruptError()
45
46
Lei Zhang5767aca2018-12-05 19:57:46 +000047def DeleteFiles(files):
48 """Utility function to delete a list of files"""
49 for f in files:
50 if os.path.exists(f):
51 os.remove(f)
52
53
dsinclair2a8a20c2016-04-25 09:46:17 -070054class TestRunner:
Lei Zhang30543372019-11-19 19:02:30 +000055
dsinclair2a8a20c2016-04-25 09:46:17 -070056 def __init__(self, dirname):
Ryan Harrison80302c72018-05-10 18:27:25 +000057 # Currently the only used directories are corpus, javascript, and pixel,
58 # which all correspond directly to the type for the test being run. In the
59 # future if there are tests that don't have this clean correspondence, then
60 # an argument for the type will need to be added.
dsinclair2a8a20c2016-04-25 09:46:17 -070061 self.test_dir = dirname
Ryan Harrison80302c72018-05-10 18:27:25 +000062 self.test_type = dirname
Lei Zhang5767aca2018-12-05 19:57:46 +000063 self.delete_output_on_success = False
Henrique Nakashima3bcabf32017-06-27 09:48:24 -040064 self.enforce_expected_images = False
Dan Sinclairaeadad12017-07-18 16:43:41 -040065 self.oneshot_renderer = False
dsinclair2a8a20c2016-04-25 09:46:17 -070066
stephanafa05e972017-01-02 06:19:41 -080067 # GenerateAndTest returns a tuple <success, outputfiles> where
68 # success is a boolean indicating whether the tests passed comparison
69 # tests and outputfiles is a list tuples:
70 # (path_to_image, md5_hash_of_pixelbuffer)
dsinclair2a8a20c2016-04-25 09:46:17 -070071 def GenerateAndTest(self, input_filename, source_dir):
Ryan Harrison1118a662018-05-31 19:26:52 +000072 use_ahem = 'use_ahem' in source_dir
73
dsinclair2a8a20c2016-04-25 09:46:17 -070074 input_root, _ = os.path.splitext(input_filename)
75 expected_txt_path = os.path.join(source_dir, input_root + '_expected.txt')
76
77 pdf_path = os.path.join(self.working_dir, input_root + '.pdf')
78
79 # Remove any existing generated images from previous runs.
80 actual_images = self.image_differ.GetActualFiles(input_filename, source_dir,
81 self.working_dir)
Lei Zhang5767aca2018-12-05 19:57:46 +000082 DeleteFiles(actual_images)
dsinclair2a8a20c2016-04-25 09:46:17 -070083
84 sys.stdout.flush()
85
86 raised_exception = self.Generate(source_dir, input_filename, input_root,
87 pdf_path)
88
Henrique Nakashima3bcabf32017-06-27 09:48:24 -040089 if raised_exception is not None:
90 print 'FAILURE: %s; %s' % (input_filename, raised_exception)
stephanafa05e972017-01-02 06:19:41 -080091 return False, []
dsinclair2a8a20c2016-04-25 09:46:17 -070092
stephanafa05e972017-01-02 06:19:41 -080093 results = []
dsinclair2a8a20c2016-04-25 09:46:17 -070094 if os.path.exists(expected_txt_path):
95 raised_exception = self.TestText(input_root, expected_txt_path, pdf_path)
96 else:
Ryan Harrison1118a662018-05-31 19:26:52 +000097 raised_exception, results = self.TestPixel(input_root, pdf_path, use_ahem)
dsinclair2a8a20c2016-04-25 09:46:17 -070098
Henrique Nakashima3bcabf32017-06-27 09:48:24 -040099 if raised_exception is not None:
100 print 'FAILURE: %s; %s' % (input_filename, raised_exception)
stephanafa05e972017-01-02 06:19:41 -0800101 return False, results
dsinclair2a8a20c2016-04-25 09:46:17 -0700102
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400103 if actual_images:
dsinclair2a8a20c2016-04-25 09:46:17 -0700104 if self.image_differ.HasDifferences(input_filename, source_dir,
105 self.working_dir):
Henrique Nakashima15bc9742018-04-26 15:55:07 +0000106 self.RegenerateIfNeeded_(input_filename, source_dir)
stephanafa05e972017-01-02 06:19:41 -0800107 return False, results
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400108 else:
Lei Zhang30543372019-11-19 19:02:30 +0000109 if (self.enforce_expected_images and
110 not self.test_suppressor.IsImageDiffSuppressed(input_filename)):
Henrique Nakashima15bc9742018-04-26 15:55:07 +0000111 self.RegenerateIfNeeded_(input_filename, source_dir)
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400112 print 'FAILURE: %s; Missing expected images' % input_filename
113 return False, results
114
Lei Zhang5767aca2018-12-05 19:57:46 +0000115 if self.delete_output_on_success:
116 DeleteFiles(actual_images)
stephanafa05e972017-01-02 06:19:41 -0800117 return True, results
dsinclair2a8a20c2016-04-25 09:46:17 -0700118
Henrique Nakashima15bc9742018-04-26 15:55:07 +0000119 def RegenerateIfNeeded_(self, input_filename, source_dir):
Lei Zhang30543372019-11-19 19:02:30 +0000120 if (not self.options.regenerate_expected or
121 self.test_suppressor.IsResultSuppressed(input_filename) or
122 self.test_suppressor.IsImageDiffSuppressed(input_filename)):
Henrique Nakashima15bc9742018-04-26 15:55:07 +0000123 return
124
125 platform_only = (self.options.regenerate_expected == 'platform')
Lei Zhang30543372019-11-19 19:02:30 +0000126 self.image_differ.Regenerate(input_filename, source_dir, self.working_dir,
127 platform_only)
Henrique Nakashima15bc9742018-04-26 15:55:07 +0000128
dsinclair2a8a20c2016-04-25 09:46:17 -0700129 def Generate(self, source_dir, input_filename, input_root, pdf_path):
130 original_path = os.path.join(source_dir, input_filename)
131 input_path = os.path.join(source_dir, input_root + '.in')
132
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400133 input_event_path = os.path.join(source_dir, input_root + '.evt')
dsinclair849284d2016-05-17 06:13:36 -0700134 if os.path.exists(input_event_path):
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400135 output_event_path = os.path.splitext(pdf_path)[0] + '.evt'
dsinclair849284d2016-05-17 06:13:36 -0700136 shutil.copyfile(input_event_path, output_event_path)
137
dsinclair2a8a20c2016-04-25 09:46:17 -0700138 if not os.path.exists(input_path):
139 if os.path.exists(original_path):
140 shutil.copyfile(original_path, pdf_path)
141 return None
142
143 sys.stdout.flush()
dsinclair849284d2016-05-17 06:13:36 -0700144
Lei Zhang30543372019-11-19 19:02:30 +0000145 return common.RunCommand([
146 sys.executable, self.fixup_path, '--output-dir=' + self.working_dir,
147 input_path
148 ])
dsinclair2a8a20c2016-04-25 09:46:17 -0700149
dsinclair2a8a20c2016-04-25 09:46:17 -0700150 def TestText(self, input_root, expected_txt_path, pdf_path):
151 txt_path = os.path.join(self.working_dir, input_root + '.txt')
152
153 with open(txt_path, 'w') as outfile:
Lei Zhang30543372019-11-19 19:02:30 +0000154 cmd_to_run = [
155 self.pdfium_test_path, '--send-events', '--time=' + TEST_SEED_TIME,
156 pdf_path
157 ]
dsinclair2a8a20c2016-04-25 09:46:17 -0700158 subprocess.check_call(cmd_to_run, stdout=outfile)
159
160 cmd = [sys.executable, self.text_diff_path, expected_txt_path, txt_path]
161 return common.RunCommand(cmd)
162
Ryan Harrison1118a662018-05-31 19:26:52 +0000163 def TestPixel(self, input_root, pdf_path, use_ahem):
Lei Zhang30543372019-11-19 19:02:30 +0000164 cmd_to_run = [
165 self.pdfium_test_path, '--send-events', '--png', '--md5',
166 '--time=' + TEST_SEED_TIME
167 ]
Ryan Harrison1118a662018-05-31 19:26:52 +0000168
Dan Sinclairaeadad12017-07-18 16:43:41 -0400169 if self.oneshot_renderer:
170 cmd_to_run.append('--render-oneshot')
Ryan Harrison1118a662018-05-31 19:26:52 +0000171
172 if use_ahem:
173 cmd_to_run.append('--font-dir=%s' % self.font_dir)
174
stephanafa05e972017-01-02 06:19:41 -0800175 cmd_to_run.append(pdf_path)
176 return common.RunCommandExtractHashedFiles(cmd_to_run)
dsinclair2a8a20c2016-04-25 09:46:17 -0700177
178 def HandleResult(self, input_filename, input_path, result):
dan sinclair00d40642017-01-30 19:48:54 -0800179 success, image_paths = result
Henrique Nakashimaea4a56d2017-11-29 19:34:19 +0000180
181 if image_paths:
182 for img_path, md5_hash in image_paths:
183 # The output filename without image extension becomes the test name.
184 # For example, "/path/to/.../testing/corpus/example_005.pdf.0.png"
185 # becomes "example_005.pdf.0".
186 test_name = os.path.splitext(os.path.split(img_path)[1])[0]
187
Stephan Altmuellerbcd66f52018-06-21 14:45:44 +0000188 matched = "suppressed"
Henrique Nakashimaea4a56d2017-11-29 19:34:19 +0000189 if not self.test_suppressor.IsResultSuppressed(input_filename):
190 matched = self.gold_baseline.MatchLocalResult(test_name, md5_hash)
191 if matched == gold.GoldBaseline.MISMATCH:
192 print 'Skia Gold hash mismatch for test case: %s' % test_name
Lei Zhang30543372019-11-19 19:02:30 +0000193 elif matched == gold.GoldBaseline.NO_BASELINE:
Henrique Nakashimaea4a56d2017-11-29 19:34:19 +0000194 print 'No Skia Gold baseline found for test case: %s' % test_name
195
196 if self.gold_results:
Lei Zhang30543372019-11-19 19:02:30 +0000197 self.gold_results.AddTestResult(test_name, md5_hash, img_path,
198 matched)
stephanafa05e972017-01-02 06:19:41 -0800199
dsinclair2a8a20c2016-04-25 09:46:17 -0700200 if self.test_suppressor.IsResultSuppressed(input_filename):
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400201 self.result_suppressed_cases.append(input_filename)
dan sinclair00d40642017-01-30 19:48:54 -0800202 if success:
dsinclair2a8a20c2016-04-25 09:46:17 -0700203 self.surprises.append(input_path)
204 else:
dan sinclair00d40642017-01-30 19:48:54 -0800205 if not success:
dsinclair2a8a20c2016-04-25 09:46:17 -0700206 self.failures.append(input_path)
207
dsinclair2a8a20c2016-04-25 09:46:17 -0700208 def Run(self):
209 parser = optparse.OptionParser()
stephanafa05e972017-01-02 06:19:41 -0800210
Lei Zhang30543372019-11-19 19:02:30 +0000211 parser.add_option(
212 '--build-dir',
213 default=os.path.join('out', 'Debug'),
214 help='relative path from the base source directory')
stephanafa05e972017-01-02 06:19:41 -0800215
Lei Zhang30543372019-11-19 19:02:30 +0000216 parser.add_option(
217 '-j',
218 default=multiprocessing.cpu_count(),
219 dest='num_workers',
220 type='int',
221 help='run NUM_WORKERS jobs in parallel')
stephanafa05e972017-01-02 06:19:41 -0800222
Lei Zhang30543372019-11-19 19:02:30 +0000223 parser.add_option(
224 '--gold_properties',
225 default='',
226 dest="gold_properties",
227 help='Key value pairs that are written to the top level '
228 'of the JSON file that is ingested by Gold.')
stephanafa05e972017-01-02 06:19:41 -0800229
Lei Zhang30543372019-11-19 19:02:30 +0000230 parser.add_option(
231 '--gold_key',
232 default='',
233 dest="gold_key",
234 help='Key value pairs that are added to the "key" field '
235 'of the JSON file that is ingested by Gold.')
stephanafa05e972017-01-02 06:19:41 -0800236
Lei Zhang30543372019-11-19 19:02:30 +0000237 parser.add_option(
238 '--gold_output_dir',
239 default='',
240 dest="gold_output_dir",
241 help='Path of where to write the JSON output to be '
242 'uploaded to Gold.')
stephanafa05e972017-01-02 06:19:41 -0800243
Lei Zhang30543372019-11-19 19:02:30 +0000244 parser.add_option(
245 '--gold_ignore_hashes',
246 default='',
247 dest="gold_ignore_hashes",
248 help='Path to a file with MD5 hashes we wish to ignore.')
stephanad5320362017-01-26 15:18:54 -0800249
Lei Zhang30543372019-11-19 19:02:30 +0000250 parser.add_option(
251 '--regenerate_expected',
252 default='',
253 dest="regenerate_expected",
254 help='Regenerates expected images. Valid values are '
255 '"all" to regenerate all expected pngs, and '
256 '"platform" to regenerate only platform-specific '
257 'expected pngs.')
Henrique Nakashima06673ed2017-10-25 17:31:13 -0400258
Lei Zhang30543372019-11-19 19:02:30 +0000259 parser.add_option(
260 '--ignore_errors',
261 action="store_true",
262 dest="ignore_errors",
263 help='Prevents the return value from being non-zero '
264 'when image comparison fails.')
stephanafa05e972017-01-02 06:19:41 -0800265
Henrique Nakashima06673ed2017-10-25 17:31:13 -0400266 self.options, self.args = parser.parse_args()
dsinclair2a8a20c2016-04-25 09:46:17 -0700267
Lei Zhang30543372019-11-19 19:02:30 +0000268 if (self.options.regenerate_expected and
269 self.options.regenerate_expected not in ['all', 'platform']):
Henrique Nakashima352e2512017-10-26 11:22:52 -0400270 print 'FAILURE: --regenerate_expected must be "all" or "platform"'
271 return 1
272
Henrique Nakashima06673ed2017-10-25 17:31:13 -0400273 finder = common.DirectoryFinder(self.options.build_dir)
dsinclair2a8a20c2016-04-25 09:46:17 -0700274 self.fixup_path = finder.ScriptPath('fixup_pdf_template.py')
275 self.text_diff_path = finder.ScriptPath('text_diff.py')
Ryan Harrison1118a662018-05-31 19:26:52 +0000276 self.font_dir = os.path.join(finder.TestingDir(), 'resources', 'fonts')
dsinclair2a8a20c2016-04-25 09:46:17 -0700277
dsinclair2a8a20c2016-04-25 09:46:17 -0700278 self.source_dir = finder.TestingDir()
dsinclair849284d2016-05-17 06:13:36 -0700279 if self.test_dir != 'corpus':
280 test_dir = finder.TestingDir(os.path.join('resources', self.test_dir))
281 else:
282 test_dir = finder.TestingDir(self.test_dir)
283
dsinclair2a8a20c2016-04-25 09:46:17 -0700284 self.pdfium_test_path = finder.ExecutablePath('pdfium_test')
285 if not os.path.exists(self.pdfium_test_path):
286 print "FAILURE: Can't find test executable '%s'" % self.pdfium_test_path
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400287 print 'Use --build-dir to specify its location.'
dsinclair2a8a20c2016-04-25 09:46:17 -0700288 return 1
289
290 self.working_dir = finder.WorkingDir(os.path.join('testing', self.test_dir))
Lei Zhang96eff7c2019-09-19 21:08:58 +0000291 shutil.rmtree(self.working_dir, ignore_errors=True)
292 os.makedirs(self.working_dir)
dsinclair2a8a20c2016-04-25 09:46:17 -0700293
Lei Zhang30543372019-11-19 19:02:30 +0000294 self.feature_string = subprocess.check_output(
295 [self.pdfium_test_path, '--show-config'])
dsinclair2a8a20c2016-04-25 09:46:17 -0700296 self.test_suppressor = suppressor.Suppressor(finder, self.feature_string)
297 self.image_differ = pngdiffer.PNGDiffer(finder)
Henrique Nakashima40be5052018-10-10 23:18:14 +0000298 error_message = self.image_differ.CheckMissingTools(
299 self.options.regenerate_expected)
300 if error_message:
301 print "FAILURE: %s" % error_message
302 return 1
dsinclair2a8a20c2016-04-25 09:46:17 -0700303
Henrique Nakashimaea4a56d2017-11-29 19:34:19 +0000304 self.gold_baseline = gold.GoldBaseline(self.options.gold_properties)
305
Lei Zhang30543372019-11-19 19:02:30 +0000306 walk_from_dir = finder.TestingDir(test_dir)
dsinclair2a8a20c2016-04-25 09:46:17 -0700307
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400308 self.test_cases = []
309 self.execution_suppressed_cases = []
Henrique Nakashima62d50762017-06-27 13:06:23 -0400310 input_file_re = re.compile('^.+[.](in|pdf)$')
Henrique Nakashima06673ed2017-10-25 17:31:13 -0400311 if self.args:
312 for file_name in self.args:
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400313 file_name.replace('.pdf', '.in')
dsinclair2a8a20c2016-04-25 09:46:17 -0700314 input_path = os.path.join(walk_from_dir, file_name)
315 if not os.path.isfile(input_path):
316 print "Can't find test file '%s'" % file_name
317 return 1
318
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400319 self.test_cases.append((os.path.basename(input_path),
Lei Zhang30543372019-11-19 19:02:30 +0000320 os.path.dirname(input_path)))
dsinclair2a8a20c2016-04-25 09:46:17 -0700321 else:
322 for file_dir, _, filename_list in os.walk(walk_from_dir):
323 for input_filename in filename_list:
324 if input_file_re.match(input_filename):
325 input_path = os.path.join(file_dir, input_filename)
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400326 if self.test_suppressor.IsExecutionSuppressed(input_path):
327 self.execution_suppressed_cases.append(input_path)
328 else:
dsinclair2a8a20c2016-04-25 09:46:17 -0700329 if os.path.isfile(input_path):
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400330 self.test_cases.append((input_filename, file_dir))
dsinclair2a8a20c2016-04-25 09:46:17 -0700331
Lei Zhang1ee96012018-04-09 17:31:14 +0000332 self.test_cases.sort()
dsinclair2a8a20c2016-04-25 09:46:17 -0700333 self.failures = []
334 self.surprises = []
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400335 self.result_suppressed_cases = []
dsinclair2a8a20c2016-04-25 09:46:17 -0700336
stephanafa05e972017-01-02 06:19:41 -0800337 # Collect Gold results if an output directory was named.
338 self.gold_results = None
Henrique Nakashima06673ed2017-10-25 17:31:13 -0400339 if self.options.gold_output_dir:
Lei Zhang30543372019-11-19 19:02:30 +0000340 self.gold_results = gold.GoldResults(
341 self.test_type, self.options.gold_output_dir,
342 self.options.gold_properties, self.options.gold_key,
343 self.options.gold_ignore_hashes)
stephanafa05e972017-01-02 06:19:41 -0800344
Henrique Nakashima06673ed2017-10-25 17:31:13 -0400345 if self.options.num_workers > 1 and len(self.test_cases) > 1:
dsinclair849284d2016-05-17 06:13:36 -0700346 try:
Henrique Nakashima06673ed2017-10-25 17:31:13 -0400347 pool = multiprocessing.Pool(self.options.num_workers)
dsinclair849284d2016-05-17 06:13:36 -0700348 worker_func = functools.partial(TestOneFileParallel, self)
349
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400350 worker_results = pool.imap(worker_func, self.test_cases)
dsinclair849284d2016-05-17 06:13:36 -0700351 for worker_result in worker_results:
352 result, input_filename, source_dir = worker_result
353 input_path = os.path.join(source_dir, input_filename)
354
355 self.HandleResult(input_filename, input_path, result)
356
357 except KeyboardInterrupt:
358 pool.terminate()
359 finally:
360 pool.close()
361 pool.join()
362 else:
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400363 for test_case in self.test_cases:
dsinclair849284d2016-05-17 06:13:36 -0700364 input_filename, input_file_dir = test_case
365 result = self.GenerateAndTest(input_filename, input_file_dir)
366 self.HandleResult(input_filename,
367 os.path.join(input_file_dir, input_filename), result)
dsinclair2a8a20c2016-04-25 09:46:17 -0700368
stephanafa05e972017-01-02 06:19:41 -0800369 if self.gold_results:
370 self.gold_results.WriteResults()
371
dsinclair2a8a20c2016-04-25 09:46:17 -0700372 if self.surprises:
373 self.surprises.sort()
374 print '\n\nUnexpected Successes:'
375 for surprise in self.surprises:
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400376 print surprise
dsinclair2a8a20c2016-04-25 09:46:17 -0700377
378 if self.failures:
379 self.failures.sort()
380 print '\n\nSummary of Failures:'
381 for failure in self.failures:
382 print failure
dan sinclair00d40642017-01-30 19:48:54 -0800383
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400384 self._PrintSummary()
385
386 if self.failures:
Henrique Nakashima06673ed2017-10-25 17:31:13 -0400387 if not self.options.ignore_errors:
dan sinclair00d40642017-01-30 19:48:54 -0800388 return 1
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400389
dsinclair2a8a20c2016-04-25 09:46:17 -0700390 return 0
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400391
392 def _PrintSummary(self):
393 number_test_cases = len(self.test_cases)
394 number_failures = len(self.failures)
395 number_suppressed = len(self.result_suppressed_cases)
396 number_successes = number_test_cases - number_failures - number_suppressed
397 number_surprises = len(self.surprises)
398 print
399 print 'Test cases executed: %d' % number_test_cases
400 print ' Successes: %d' % number_successes
401 print ' Suppressed: %d' % number_suppressed
402 print ' Surprises: %d' % number_surprises
403 print ' Failures: %d' % number_failures
404 print
405 print 'Test cases not executed: %d' % len(self.execution_suppressed_cases)
406
Lei Zhang5767aca2018-12-05 19:57:46 +0000407 def SetDeleteOutputOnSuccess(self, new_value):
408 """Set whether to delete generated output if the test passes."""
409 self.delete_output_on_success = new_value
410
Henrique Nakashima3bcabf32017-06-27 09:48:24 -0400411 def SetEnforceExpectedImages(self, new_value):
412 """Set whether to enforce that each test case provide an expected image."""
413 self.enforce_expected_images = new_value
Dan Sinclairaeadad12017-07-18 16:43:41 -0400414
415 def SetOneShotRenderer(self, new_value):
416 """Set whether to use the oneshot renderer. """
417 self.oneshot_renderer = new_value