This repository has been archived by the owner on Nov 26, 2019. It is now read-only.
forked from synfig/synfig-tests-regressions
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrender.sh
executable file
·199 lines (169 loc) · 4.67 KB
/
render.sh
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/bin/bash
#set -x
set -e
# Gets required version of synfig
MODE=$1 # references / results
VERSION="1.0.2"
SYNFIG=""
# For test results
THRESHOLD=5000
PASS=0
FAIL=0
FAILED_TEST=""
get-synfig-tar () {
SYNFIG="/tmp/synfig-$VERSION/synfig"
if [ ! -d "/tmp/synfig-$VERSION" ]; then
wget --quiet "https://sourceforge.net/projects/synfig/files/releases/$VERSION/linux/synfigstudio-$VERSION.x86_64.tar.bz2/download" -O "/tmp/synfig-$VERSION.tar.bz2"
mkdir -p /tmp/synfig-$VERSION
tar jxf /tmp/synfig-$VERSION.tar.bz2 -C /tmp/synfig-$VERSION --strip-components=1
fi
}
get-synfig-appimage () {
SYNFIG="/tmp/synfig-$VERSION.appimage --appimage-exec synfig"
if [ ! -e "/tmp/synfig-$VERSION.appimage" ]; then
if [ "$#" -eq 3 ]; then
LINK=$3
else
LINK="https://sourceforge.net/projects/synfig/files/releases/$VERSION/linux/synfigstudio-$2.appimage/download"
fi
wget --quiet --no-check-certificate $LINK -O "/tmp/synfig-$VERSION.appimage"
chmod +x /tmp/synfig-$VERSION.appimage
fi
}
get-synfig () {
VERSION=$1
PARSED_VERSION=${VERSION//./}
if [ $PARSED_VERSION -lt 120 ]; then
get-synfig-tar $VERSION
elif [ $PARSED_VERSION -eq 120 ]; then
get-synfig-appimage $VERSION "1.2.0-64bit-r2"
elif [ $PARSED_VERSION -eq 121 ]; then
get-synfig-appimage $VERSION "1.2.1-64bit"
elif [ $PARSED_VERSION -eq 122 ]; then
get-synfig-appimage $VERSION "18.09.14-linux64-286f1" "https://sourceforge.net/projects/synfig/files/releases/1.2.2/SynfigStudio-1.2.2-18.09.14-linux64-286f1.appimage/download"
elif [ $PARSED_VERSION -eq 131020181101 ]; then
get-synfig-appimage $VERSION "1.3.10.2018.11.01" "https://dev.icystar.com/downloads/SynfigStudio-1.3.10-testing-18.11.01-linux64-28c73.appimage"
fi
}
# if default version is changed force generate all reference
# if particular layer reference is changed generate it's reference
# if some files are added generate references for them
test-result () {
NAME=$1
TEST=$(compare -metric RMSE $TRAVIS_BUILD_DIR/references/$NAME.png $TRAVIS_BUILD_DIR/results/$NAME.png NULL 2>&1)
TEST=${TEST% *}
TEST=${TEST%.*}
if [ $TEST -lt $THRESHOLD ]; then
echo "$NAME passed"
PASS=$((PASS+1))
else
echo "SNAME failed"
FAIL=$((FAIL+1))
FAILED_TEST="$FAILED_TEST $NAME \n"
fi
}
set-version () {
FILE=$1
pushd $TRAVIS_BUILD_DIR
# FILE="/home/reSHARMA/synfig-test-regressions/sources/layers/circle/circle-radius-0.txt"
TEMP=$TRAVIS_BUILD_DIR
FILE=${FILE##*$TEMP/} # TODO: do this in a better way
IFS='/'
read -r -a array <<< "$FILE"
unset IFS
# array={sources, layers, circle, circle-radius-0.txt}
size=${#array[@]}
# size=4
array[$size - 1]=${array[$size - 1]%.*}
# array={sources, layers, circle, circle-radius-0}
NAME=${array[$size - 1]}
unset "array[$size - 1]"
for element in "${array[@]}"
do
cd $element && \
if [ -f "$element.txt" ]; then
VERSION=`cat $element.txt`
fi
done && \
if [ -f "$NAME.txt" ]; then
VERSION=`cat $NAME.txt`
fi
for element in "${array[@]}"
do
cd ../
done
popd
}
synfig-render () {
FILE=$1
NAME=${FILE##*sources/} # TODO: do this in a better way
DIR=${NAME%/*}
NAME=${NAME%.*}
FILE=${FILE%.*}
if [[ -f "${TRAVIS_BUILD_DIR}/$FILE.sif" ]]; then
if [ ! -d "${TRAVIS_BUILD_DIR}/$MODE/$DIR" ]; then
mkdir -p "${TRAVIS_BUILD_DIR}/$MODE/$DIR"
echo $DIR" created...."
fi
$SYNFIG -v 10 --time 0 -i "${TRAVIS_BUILD_DIR}/$FILE.sif" -o "${TRAVIS_BUILD_DIR}/$MODE/$NAME.png"
if [ "$MODE" = "results" ]; then
test-result $NAME
fi
fi
}
render-only-one-file () {
FILE=$1
set-version $FILE
get-synfig $VERSION
synfig-render $FILE
}
render-dir () {
DIR=$1
cd $DIR && \
for file in *; do
if [[ -e $1/$file ]]; then
if [[ -f $1/$file ]]; then
pwd
render-only-one-file "$1/$file"
else
render-dir "$1/$file"
fi
fi
done
}
render-only-one-dir () {
FILE=$1
DIR=${FILE%/*}
render-dir "$TRAVIS_BUILD_DIR/$DIR"
}
# Get the modified files from the commit
if [ -z "$TRAVIS_BUILD_DIR" ]; then
TRAVIS_BUILD_DIR=$(cd `dirname "$0"`; pwd) # gets directory of current script
fi
cd "$TRAVIS_BUILD_DIR"
if [ -z "$TRAVIS_COMMIT_RANGE" ]; then
# rebuild everything
CHANGED_FILES="sources/sources.txt"
else
CHANGED_FILES=`git diff --name-only $TRAVIS_COMMIT_RANGE`
fi
for file in $CHANGED_FILES; do
EXT=${file##*.}
DIR=${file%/*}
NAME=${file##*/}
NAME=${NAME%.*}
PARENT_DIR_NAME=${DIR##*/}
# eg: sources/layers/rectangle/rectangle-0.sif
# EXT = "sif"
# DIR = "sources/layers/rectangle"
# NAME = "rectangle-0"
if [ "$EXT" = "sif" ]; then
render-only-one-file $file
elif [ "$EXT" = "txt" ]; then
if [ "$PARENT_DIR_NAME" = "$NAME" ]; then
render-only-one-dir $file
else
render-only-one-file "$TRAVIS_BUILD_DIR/$file"
fi
fi
done