summaryrefslogtreecommitdiff
path: root/testing/tools
diff options
context:
space:
mode:
authordsinclair <dsinclair@chromium.org>2016-04-28 06:17:40 -0700
committerCommit bot <commit-bot@chromium.org>2016-04-28 06:17:40 -0700
commit3b5cb78353f92ad7d23ace4e452ed26acf9aeaa7 (patch)
treedd0c2972880da75840a94c9dbe538607aaa10c05 /testing/tools
parentbb0d446df18ee34504a165f3fc96fbb81b274f31 (diff)
downloadpdfium-3b5cb78353f92ad7d23ace4e452ed26acf9aeaa7.tar.xz
Remove output redirect from corpus test runner.
The corpus tests redirect output to a string but they just output it later anyway. This CL removes the output redirect and removes the redirect_output flag which will always be False now. Review-Url: https://codereview.chromium.org/1927633002
Diffstat (limited to 'testing/tools')
-rwxr-xr-xtesting/tools/common.py7
-rwxr-xr-xtesting/tools/pngdiffer.py9
-rwxr-xr-xtesting/tools/run_corpus_tests.py22
3 files changed, 11 insertions, 27 deletions
diff --git a/testing/tools/common.py b/testing/tools/common.py
index 6e9de7c82c..1e1d257f48 100755
--- a/testing/tools/common.py
+++ b/testing/tools/common.py
@@ -18,12 +18,9 @@ def os_name():
raise Exception('Confused, can not determine OS, aborting.')
-def RunCommand(cmd, redirect_output=False):
+def RunCommand(cmd):
try:
- if redirect_output:
- sys.stdout.write(subprocess.check_output(cmd, stderr=subprocess.STDOUT))
- else:
- subprocess.check_call(cmd)
+ subprocess.check_call(cmd)
return None
except subprocess.CalledProcessError as e:
return e
diff --git a/testing/tools/pngdiffer.py b/testing/tools/pngdiffer.py
index 79d1b7588a..a1533b8329 100755
--- a/testing/tools/pngdiffer.py
+++ b/testing/tools/pngdiffer.py
@@ -38,8 +38,7 @@ class PNGDiffer():
i += 1
return actual_paths
- def HasDifferences(self, input_filename, source_dir, working_dir,
- redirect_output=False):
+ def HasDifferences(self, input_filename, source_dir, working_dir):
template_paths = self._GetTemplatePaths(
input_filename, source_dir, working_dir)
actual_path_template = template_paths[0];
@@ -62,16 +61,14 @@ class PNGDiffer():
sys.stdout.flush()
if os.path.exists(expected_path):
error = common.RunCommand(
- [self.pdfium_diff_path, expected_path, actual_path],
- redirect_output)
+ [self.pdfium_diff_path, expected_path, actual_path])
else:
error = 1;
if error:
# When failed, we check against platform based results.
if os.path.exists(platform_expected_path):
error = common.RunCommand(
- [self.pdfium_diff_path, platform_expected_path, actual_path],
- redirect_output)
+ [self.pdfium_diff_path, platform_expected_path, actual_path])
if error:
print "FAILURE: " + input_filename + "; " + str(error)
return True
diff --git a/testing/tools/run_corpus_tests.py b/testing/tools/run_corpus_tests.py
index 82c3d2aefe..2c3c191c88 100755
--- a/testing/tools/run_corpus_tests.py
+++ b/testing/tools/run_corpus_tests.py
@@ -26,8 +26,7 @@ class KeyboardInterruptError(Exception): pass
# c_dir - "path/to/a/b/c"
def test_one_file(input_filename, source_dir, working_dir,
- pdfium_test_path, image_differ, drmem_wrapper,
- redirect_output=False):
+ pdfium_test_path, image_differ, drmem_wrapper):
input_path = os.path.join(source_dir, input_filename)
pdf_path = os.path.join(working_dir, input_filename)
# Remove any existing generated images from previous runs.
@@ -45,29 +44,21 @@ def test_one_file(input_filename, source_dir, working_dir,
os.path.splitext(input_filename)[0])
cmd_to_run.extend([pdfium_test_path, '--png', pdf_path])
# run test
- error = common.RunCommand(cmd_to_run, redirect_output)
+ error = common.RunCommand(cmd_to_run)
if error:
print "FAILURE: " + input_filename + "; " + str(error)
return False
- return not image_differ.HasDifferences(input_filename, source_dir,
- working_dir, redirect_output)
+ return not image_differ.HasDifferences(input_filename, source_dir, working_dir)
def test_one_file_parallel(working_dir, pdfium_test_path, image_differ,
test_case):
"""Wrapper function to call test_one_file() and redirect output to stdout."""
try:
- old_stdout = sys.stdout
- old_stderr = sys.stderr
- sys.stdout = cStringIO.StringIO()
- sys.stderr = sys.stdout
input_filename, source_dir = test_case
result = test_one_file(input_filename, source_dir, working_dir,
- pdfium_test_path, image_differ, "", True);
- output = sys.stdout
- sys.stdout = old_stdout
- sys.stderr = old_stderr
- return (result, output.getvalue(), input_filename, source_dir)
+ pdfium_test_path, image_differ, "");
+ return (result, input_filename, source_dir)
except KeyboardInterrupt:
raise KeyboardInterruptError()
@@ -138,9 +129,8 @@ def main():
pdfium_test_path, image_differ)
worker_results = pool.imap(worker_func, test_cases)
for worker_result in worker_results:
- result, output, input_filename, source_dir = worker_result
+ result, input_filename, source_dir = worker_result
input_path = os.path.join(source_dir, input_filename)
- sys.stdout.write(output)
handle_result(test_suppressor, input_filename, input_path, result,
surprises, failures)
pool.close()