blob: c9a6c9da21cd018ab391e8f27560d35e1636bd06 [file] [log] [blame]
epoger@google.com494548b2012-04-24 15:19:23 +00001#!/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
24function say() {
25 # set color to yellow
26 tput setaf 3
27 echo $1
28 tput sgr0
29}
30
31function warn() {
32 # set color to red
33 tput setaf 1
34 echo $1
35 tput sgr0
36}
37
38REVISION="HEAD^"
39
40if [[ $# -eq 1 ]];
41then
42 REVISION="$1"
43fi
44
45tput clear
46
47say "Checking sanity..."
48git diff --exit-code > /dev/null
49if [[ $? -ne 0 ]];
50then
51 warn "You have uncommitted changes!"
52 exit 1
53fi
54git diff --cached --exit-code > /dev/null
55if [[ $? -ne 0 ]];
56then
57 warn "You have uncommitted changes!"
58 exit 1
59fi
60
61say "Preparing Directories..."
62rm -rf {before,after,diff}
63mkdir {before,after,diff}
64
65PREVIOUS_BRANCH=`git branch --no-color | grep "^*" | awk '{ print $2}'`
66
67say "Running GM for current revision..."
68./gyp_skia
69make BUILDTYPE=Release -j10
70if [[ $? -ne 0 ]];
71then
72 warn "Failed to compile!"
73 exit 1
74fi
75./out/Release/gm -w after
76
77say "Running GM for revision $REVISION..."
78# we run the test in a detached branch
79git checkout --detach "$REVISION"
80./gyp_skia
81make BUILDTYPE=Release -j10
82if [[ $? -ne 0 ]];
83then
84 warn "Failed to compile!"
85 say "Back to original revision..."
86 git checkout "$PREVIOUS_BRANCH"
87 exit 1
88fi
89./out/Release/gm -w before
90
91say "Back to original revision..."
92git checkout "$PREVIOUS_BRANCH"
93
94say "Comparing..."
95./out/Release/skdiff before after diff