Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(314)

Unified Diff: experimental/PdfViewer/scripts/test_all_pdfs.sh

Issue 62103008: Add a script for running pdfviewer and comparing to existing results. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Respond to comments Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | experimental/PdfViewer/scripts/vm_pdf_viewer_run_one_pdf.sh » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: experimental/PdfViewer/scripts/test_all_pdfs.sh
diff --git a/experimental/PdfViewer/scripts/test_all_pdfs.sh b/experimental/PdfViewer/scripts/test_all_pdfs.sh
new file mode 100755
index 0000000000000000000000000000000000000000..924c531bca5d35dfbd3696dc206965c9df7c3c5d
--- /dev/null
+++ b/experimental/PdfViewer/scripts/test_all_pdfs.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+
+# Copyright 2013 Google Inc.
+#
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+if [ "${1}" == '-h' ] || [ "${1}" == '--help' ]
+then
+echo 'test_all_pdfs.sh
+Usage: Run from the trunk directory of a Skia tree to convert a folder of PDFs into PNGs.
+ Many threads will be run simultaneously using the "parallel" tool if that tool is
+ installed. "parallel" can be installed on linux using "sudo apt-get install parallel."
scroggo 2013/11/12 14:51:44 edisonn wrote:
+ Requires that skdiff and pdfviewer have already been built.
+
+Arguments:
+ folder Folder containing PDF files. The PNG results will be placed in "folder/new".
+ If folder contains a folder named "old", the PNGs in "folder/new" will be
+ compared to PNGs in "folder/old" with the same name, and the differences
+ will be stored in a "folder/d".'
+exit
+fi
+
+# Early exit if pdfviewer has not been built.
+# TODO (scroggo): Use release version if debug is unavailable
+if [ ! -f out/Debug/pdfviewer ]
+then
+ echo 'debug version of pdfviewer is required.'
+ exit
+fi
+
+if [ -z $1 ]
+then
+ echo 'folder is a required argument.'
+ exit
+fi
+
+if [ ! -d $1 ]
+then
+ echo 'folder must be a valid directory.'
+ exit
+fi
+
+# Create the directory to contain the new results. If old new results exist, remove them.
+if [ -d $1/new ]
+then
+ rm -rf $1/new
+fi
+
+mkdir $1/new/
+
+# Run the script to read each PDF and convert it to a PNG.
+if command -v parallel >/dev/null 2>&1
+then
+ echo 'Running in parallel'
+ ls -1 $1/*.pdf | sed "s/^/experimental\/PdfViewer\/scripts\/vm_pdf_viewer_run_one_pdf.sh /" \
+ | parallel
+else
+ echo 'Converting each file sequentially. Install "parallel" to convert in parallel.'
+ echo '"parallel" can be installed on linux with "sudo apt-get install parallel".'
+ ls -1 $1/*.pdf | xargs experimental/PdfViewer/scripts/vm_pdf_viewer_run_one_pdf.sh
+fi
+
+# Next, compare to the old results. Exit now if there is no folder with old results.
+if [ ! -d $1/old ]
+then
+ exit
+fi
+
+# Check to make sure that skdiff has been built.
+RELEASE_SKDIFF=out/Release/skdiff
+DEBUG_SKDIFF=out/Debug/skdiff
+if [ -f $RELEASE_SKDIFF ]
+then
+ SKDIFF=$RELEASE_SKDIFF
+elif [ -f $DEBUG_SKDIFF ]
+then
+ SKDIFF=$DEBUG_SKDIFF
+else
+ echo 'Build skdiff in order to do comparisons.'
+ exit
+fi
+
+# Create the diff folder, after deleting old diffs if necessary.
+if [ -d $1/d ]
+then
+ rm -rf $1/d
+fi
+
+mkdir $1/d
+
+$SKDIFF $1/old $1/new $1/d
« no previous file with comments | « no previous file | experimental/PdfViewer/scripts/vm_pdf_viewer_run_one_pdf.sh » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698