summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2015-10-28 17:06:04 -0400
committerDan Sinclair <dsinclair@chromium.org>2015-10-28 17:06:04 -0400
commitda6254ff78553773b7bb637ee1e3f5111c083c74 (patch)
tree472a53e1d61b31f623c5a8856eb2f8fcbbedbd50
parent55ed2880e9d19e79717063b117aa5eee40dd454b (diff)
downloadpdfium-da6254ff78553773b7bb637ee1e3f5111c083c74.tar.xz
Allow running individual tests.
This CL adds the ability to run a given test from the corpus, javascript and pixel test runners. The filename to provide is relative to the testing directory in question. Because the directories for javascript and pixel are flat you just provide the filename (it will rewrite the .pdf to .in if .pdf is provided). For corpus tests you have to provide the path from the corpus directory. Development/pdfium/pdfium % ./testing/tools/run_javascript_tests.py apply.pdf Rendering PDF file /Development/pdfium/pdfium/out/Debug/gen/pdfium/testing/javascript/apply.pdf. Non-linearized path... Rendered 1 pages. Skipped 0 bad pages. Development/pdfium/pdfium % ./testing/tools/run_pixel_tests.py bug_524043_1.pdf Rendering PDF file /Development/pdfium/pdfium/out/Debug/gen/pdfium/testing/pixel/bug_524043_1.pdf. Linearized path... Rendered 1 pages. Skipped 0 bad pages. Checking /Development/pdfium/pdfium/out/Debug/gen/pdfium/testing/pixel/bug_524043_1.pdf.0.png diff: 0.00% passed Development/pdfium/pdfium % ./testing/tools/run_corpus_tests.py third_party/tcpdf/example_065.pdf Rendering PDF file /Development/pdfium/pdfium/out/Debug/gen/pdfium/testing/corpus/example_065.pdf. Non-linearized path... Rendered 1 pages. Skipped 0 bad pages. Checking /Development/pdfium/pdfium/out/Debug/gen/pdfium/testing/corpus/example_065.pdf.0.png diff: 0.14% failed FAILURE: example_065.pdf; Command '['/Development/pdfium/pdfium/out/Debug/pdfium_diff', '/Development/pdfium/pdfium/testing/corpus/third_party/tcpdf/example_065_expected.pdf.0.png', '/Development/pdfium/pdfium/out/Debug/gen/pdfium/testing/corpus/example_065.pdf.0.png']' returned non-zero exit status 1 Summary of Failures: /Development/pdfium/pdfium/testing/corpus/third_party/tcpdf/example_065.pdf R=thestig@chromium.org Review URL: https://codereview.chromium.org/1407913005 .
-rwxr-xr-xtesting/tools/run_corpus_tests.py25
-rwxr-xr-xtesting/tools/run_javascript_tests.py10
-rwxr-xr-xtesting/tools/run_pixel_tests.py9
3 files changed, 35 insertions, 9 deletions
diff --git a/testing/tools/run_corpus_tests.py b/testing/tools/run_corpus_tests.py
index b6cbff7537..29f23b504a 100755
--- a/testing/tools/run_corpus_tests.py
+++ b/testing/tools/run_corpus_tests.py
@@ -104,14 +104,25 @@ def main():
walk_from_dir = finder.TestingDir('corpus');
input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]pdf$')
test_cases = []
- for source_dir, _, filename_list in os.walk(walk_from_dir):
- for input_filename in filename_list:
- if input_file_re.match(input_filename):
- input_path = os.path.join(source_dir, input_filename)
- if os.path.isfile(input_path):
- test_cases.append((input_filename, source_dir))
- if options.num_workers > 1:
+ if len(args):
+ for file_name in args:
+ input_path = os.path.join(walk_from_dir, file_name)
+ if not os.path.isfile(input_path):
+ print "Can't find test file '%s'" % file_name
+ return 1
+
+ test_cases.append((os.path.basename(input_path),
+ os.path.dirname(input_path)))
+ else:
+ for source_dir, _, filename_list in os.walk(walk_from_dir):
+ for input_filename in filename_list:
+ if input_file_re.match(input_filename):
+ input_path = os.path.join(source_dir, input_filename)
+ if os.path.isfile(input_path):
+ test_cases.append((input_filename, source_dir))
+
+ if options.num_workers > 1 and len(test_cases) > 1:
try:
pool = multiprocessing.Pool(options.num_workers)
worker_func = functools.partial(test_one_file_parallel, working_dir,
diff --git a/testing/tools/run_javascript_tests.py b/testing/tools/run_javascript_tests.py
index f9344a145f..e2fdc66918 100755
--- a/testing/tools/run_javascript_tests.py
+++ b/testing/tools/run_javascript_tests.py
@@ -42,6 +42,7 @@ def main():
parser.add_option('--build-dir', default=os.path.join('out', 'Debug'),
help='relative path from the base source directory')
options, args = parser.parse_args()
+
finder = common.DirectoryFinder(options.build_dir)
fixup_path = finder.ScriptPath('fixup_pdf_template.py')
text_diff_path = finder.ScriptPath('text_diff.py')
@@ -55,9 +56,16 @@ def main():
if not os.path.exists(working_dir):
os.makedirs(working_dir)
+ input_files = []
+ if len(args):
+ for file_name in args:
+ input_files.append(file_name.replace(".pdf", ".in"))
+ else:
+ input_files = os.listdir(source_dir)
+
failures = []
input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$')
- for input_filename in os.listdir(source_dir):
+ for input_filename in input_files:
if input_file_re.match(input_filename):
input_path = os.path.join(source_dir, input_filename)
if os.path.isfile(input_path):
diff --git a/testing/tools/run_pixel_tests.py b/testing/tools/run_pixel_tests.py
index c65a67aa17..b167923b86 100755
--- a/testing/tools/run_pixel_tests.py
+++ b/testing/tools/run_pixel_tests.py
@@ -66,9 +66,16 @@ def main():
test_suppressor = suppressor.Suppressor(finder)
image_differ = pngdiffer.PNGDiffer(finder)
+ input_files = []
+ if len(args):
+ for file_name in args:
+ input_files.append(file_name.replace(".pdf", ".in"))
+ else:
+ input_files = os.listdir(source_dir)
+
failures = []
input_file_re = re.compile('^[a-zA-Z0-9_.]+[.]in$')
- for input_filename in os.listdir(source_dir):
+ for input_filename in input_files:
if input_file_re.match(input_filename):
input_path = os.path.join(source_dir, input_filename)
if os.path.isfile(input_path):