common/: Use socket.url
[libquvi-scripts.git] / tests / run_tests.sh
blob8040f321f7d5f0d67601c2fdc1d62fb9a03bc9c3
1 #!/bin/sh
3 # libquvi-scripts
4 # Copyright (C) 2012 Toni Gundogdu <legatvs@gmail.com>
6 # This library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # This library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with this library; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 # 02110-1301 USA
21 set -e
23 # cmds
24 Z='zenity'
25 # arrays
26 T= # tests
28 find_tests()
30 f="`dirname $0`/find_tests.sh"
31 T=`$f | sort -hr` || {
32 echo "error: $! ($?)"
33 exit 1
35 [ -n "$T" ] || {
36 echo "error: tests not found"
37 exit 1
41 enter_custom_test_skip()
43 T=`$Z --entry --text="Enter:" \
44 --entry-text="(comma-separated, patterns OK)" \
45 --width=320 --height=180 \
46 --title="Enter a custom value for TEST_SKIP"`
47 export TEST_SKIP="$T"
48 echo "TEST_SKIP=$TEST_SKIP"
49 return 0
52 choose_skipped_tests()
54 a=; for t in $T; do
55 a="FALSE $t $a"
56 done
57 o='--list --width 320 --height 480 --separator=,'
58 o="$o --column Skip --column Test"
59 T=`$Z $o --checklist false enter_custom $a`
60 expr "$T" : ".*enter_custom.*" >/dev/null && enter_custom_test_skip
61 export TEST_SKIP="$T"
62 # echo "TEST_SKIP=$TEST_SKIP"
63 return 0
66 choose_test_level()
68 o='--list --radiolist --width 320 --height 240'
69 o="$o --column Enable --column Level true basic false complete"
70 T=`$Z $o`
71 export TEST_LEVEL="$T"
72 # echo "TEST_LEVEL=$TEST_LEVEL"
73 return 0
76 choose_test_opts()
78 c='--column Enable --column Test'
79 a='false TEST_GEOBLOCKED false TEST_VERBOSE false TEST_NSFW false TEST_FIXME'
80 r=`$Z --width 320 --height 240 --list --checklist $c $a`
81 expr "$r" : ".*GEOBLOCKED.*" >/dev/null && export TEST_GEOBLOCKED=1
82 expr "$r" : ".*VERBOSE.*" >/dev/null && export TEST_VERBOSE=1
83 expr "$r" : ".*FIXME.*" >/dev/null && export TEST_FIXME=1
84 expr "$r" : ".*NSFW.*" >/dev/null && export TEST_NSFW=1
85 return 0
88 run_tests()
90 echo "TEST_GEOBLOCKED=$TEST_GEOBLOCKED"
91 echo "TEST_VERBOSE=$TEST_VERBOSE"
92 echo "TEST_FIXME=$TEST_FIXME"
93 echo "TEST_NSFW=$TEST_NSFW"
94 make test
95 return 0
98 help()
100 echo "Usage: $0 [OPTIONS]
102 $0 is a convenience script for running the tests.
104 OPTIONS
105 -h Show this help and exit
107 NOTE: Run 'configure' script first
109 Example:
110 cd \$top_srcdir ; mkdir tmp ; cd tmp
111 ../configure && make && ../$0
113 $0 sets the following environment variables before
114 running the tests:
115 TEST_GEOBLOCKED
116 TEST_VERBOSE
117 TEST_FIXME
118 TEST_NSFW
119 TEST_SKIP
121 NOTE: You must set any HTTP proxy environment variables (e.g.
122 http_proxy) manually. Refer to curl(1) manual page for a list
123 of the supported variables."
124 exit 0
127 while [ $# -gt 0 ]
129 case "$1" in
130 -h) help;;
131 *) break;;
132 esac
133 shift
134 done
136 [ -f "config.log" ] || {
137 echo "error: config.log not found: have you run configure?"
138 exit 1
141 find_tests
142 choose_skipped_tests
143 choose_test_level
144 choose_test_opts
145 run_tests
147 # vim: set ts=2 sw=2 tw=72 expandtab: