OLD | NEW |
---|---|
(Empty) | |
1 #!/bin/bash | |
2 | |
3 # Copyright 2013 Google Inc. | |
4 # | |
5 # Use of this source code is governed by a BSD-style license that can be | |
6 # found in the LICENSE file. | |
7 | |
8 if [ "${1}" == '-h' ] || [ "${1}" == '--help' ] | |
9 then | |
10 echo 'test_all_pdfs.sh | |
11 Usage: Run from the trunk directory of a Skia tree to convert a folder of PDFs i nto PNGs. | |
12 Many threads will be run simultaneously using the "parallel" tool if that tool is | |
13 installed. "parallel" can be installed on linux using "sudo apt-get insta ll parallel." | |
scroggo
2013/11/12 14:51:44
edisonn wrote:
| |
14 Requires that skdiff and pdfviewer have already been built. | |
15 | |
16 Arguments: | |
17 folder Folder containing PDF files. The PNG results will be placed in " folder/new". | |
18 If folder contains a folder named "old", the PNGs in "folder/new " will be | |
19 compared to PNGs in "folder/old" with the same name, and the dif ferences | |
20 will be stored in a "folder/d".' | |
21 exit | |
22 fi | |
23 | |
24 # Early exit if pdfviewer has not been built. | |
25 # TODO (scroggo): Use release version if debug is unavailable | |
26 if [ ! -f out/Debug/pdfviewer ] | |
27 then | |
28 echo 'debug version of pdfviewer is required.' | |
29 exit | |
30 fi | |
31 | |
32 if [ -z $1 ] | |
33 then | |
34 echo 'folder is a required argument.' | |
35 exit | |
36 fi | |
37 | |
38 if [ ! -d $1 ] | |
39 then | |
40 echo 'folder must be a valid directory.' | |
41 exit | |
42 fi | |
43 | |
44 # Create the directory to contain the new results. If old new results exist, rem ove them. | |
45 if [ -d $1/new ] | |
46 then | |
47 rm -rf $1/new | |
48 fi | |
49 | |
50 mkdir $1/new/ | |
51 | |
52 # Run the script to read each PDF and convert it to a PNG. | |
53 if command -v parallel >/dev/null 2>&1 | |
54 then | |
55 echo 'Running in parallel' | |
56 ls -1 $1/*.pdf | sed "s/^/experimental\/PdfViewer\/scripts\/vm_pdf_viewer_ru n_one_pdf.sh /" \ | |
57 | parallel | |
58 else | |
59 echo 'Converting each file sequentially. Install "parallel" to convert in pa rallel.' | |
60 echo '"parallel" can be installed on linux with "sudo apt-get install parall el".' | |
61 ls -1 $1/*.pdf | xargs experimental/PdfViewer/scripts/vm_pdf_viewer_run_one_ pdf.sh | |
62 fi | |
63 | |
64 # Next, compare to the old results. Exit now if there is no folder with old resu lts. | |
65 if [ ! -d $1/old ] | |
66 then | |
67 exit | |
68 fi | |
69 | |
70 # Check to make sure that skdiff has been built. | |
71 RELEASE_SKDIFF=out/Release/skdiff | |
72 DEBUG_SKDIFF=out/Debug/skdiff | |
73 if [ -f $RELEASE_SKDIFF ] | |
74 then | |
75 SKDIFF=$RELEASE_SKDIFF | |
76 elif [ -f $DEBUG_SKDIFF ] | |
77 then | |
78 SKDIFF=$DEBUG_SKDIFF | |
79 else | |
80 echo 'Build skdiff in order to do comparisons.' | |
81 exit | |
82 fi | |
83 | |
84 # Create the diff folder, after deleting old diffs if necessary. | |
85 if [ -d $1/d ] | |
86 then | |
87 rm -rf $1/d | |
88 fi | |
89 | |
90 mkdir $1/d | |
91 | |
92 $SKDIFF $1/old $1/new $1/d | |
OLD | NEW |