summaryrefslogtreecommitdiff
path: root/testing/tools/make_expected.sh
blob: a70df797c2353ed8acf0f02a3b450e02407aa7f7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
#
# Copyright 2015 PDFium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
#
# Script to generate expected result files.

# Do this before "set -e" so "which" failing is not fatal.
PNGOPTIMIZER="$(which optipng)"

set -e
while (( "$#" )); do
  INFILE="$1"
  echo $INFILE | grep -qs ' ' && echo space in filename detected && exit 1
  EVTFILE="${INFILE%.*}.evt"
  if [ -f "$EVTFILE" ]; then
    out/Debug/pdfium_test --send-events --png $INFILE
  else
    out/Debug/pdfium_test --png $INFILE
  fi
  RESULTS="$INFILE.*.png"
  for RESULT in $RESULTS ; do
    EXPECTED=`echo -n $RESULT | sed 's/[.]pdf[.]/_expected.pdf./'`
    mv $RESULT $EXPECTED
    if [ -n "$PNGOPTIMIZER" ]; then
      "$PNGOPTIMIZER" $EXPECTED
    fi
  done
  shift
done