Home | History | Annotate | Download | only in tools
      1 #!/bin/sh
      2 #
      3 # Copyright 2012 Intel 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 # This script builds and runs GM in current workspace with another Skia
      9 # revision user specifies, and then compares their results. This script is
     10 # useful when developers want to know whether their changes would cause any
     11 # regression.
     12 #
     13 # As the name of this script tells, it only works for git repository. :)
     14 #
     15 # Usage:
     16 #   Put this script into where your PATH can find it.
     17 #   And then invoke:
     18 #       $ git skia-verify [sha1-to-compare-default-is-HEAD^]
     19 #   It would delete {before,after,diff} directory under the current directory,
     20 #   so be warned!
     21 #   After it's done, check out diff/index.html for the possible differences.
     22 
     23 
     24 function say() {
     25     # set color to yellow
     26     tput setaf 3
     27     echo $1
     28     tput sgr0
     29 }
     30 
     31 function warn() {
     32     # set color to red
     33     tput setaf 1
     34     echo $1
     35     tput sgr0
     36 }
     37 
     38 REVISION="HEAD^"
     39 
     40 if [[ $# -eq 1 ]];
     41 then
     42     REVISION="$1"
     43 fi
     44 
     45 tput clear
     46 
     47 say "Checking sanity..."
     48 git diff --exit-code > /dev/null
     49 if [[ $? -ne 0 ]];
     50 then
     51     warn "You have uncommitted changes!"
     52     exit 1
     53 fi
     54 git diff --cached --exit-code > /dev/null
     55 if [[ $? -ne 0 ]];
     56 then
     57     warn "You have uncommitted changes!"
     58     exit 1
     59 fi
     60 
     61 say "Preparing Directories..."
     62 rm -rf {before,after,diff}
     63 mkdir {before,after,diff}
     64 
     65 PREVIOUS_BRANCH=`git branch --no-color | grep "^*" | awk '{ print $2}'`
     66 
     67 say "Running GM for current revision..."
     68 ./gyp_skia
     69 make BUILDTYPE=Release -j10
     70 if [[ $? -ne 0 ]];
     71 then
     72     warn "Failed to compile!"
     73     exit 1
     74 fi
     75 ./out/Release/gm -w after
     76 
     77 say "Running GM for revision $REVISION..."
     78 # we run the test in a detached branch
     79 git checkout --detach "$REVISION"
     80 ./gyp_skia
     81 make BUILDTYPE=Release -j10
     82 if [[ $? -ne 0 ]];
     83 then
     84     warn "Failed to compile!"
     85     say "Back to original revision..."
     86     git checkout "$PREVIOUS_BRANCH"
     87     exit 1
     88 fi
     89 ./out/Release/gm -w before
     90 
     91 say "Back to original revision..."
     92 git checkout "$PREVIOUS_BRANCH"
     93 
     94 say "Comparing..."
     95 ./out/Release/skdiff before after diff
     96