[PATCH 3/4] test: add S/MIME signature verification test for notmuch CLI
[notmuch-archives.git] / 34 / 5fa161763f897ef203d96465761eeaa6e6d28c
1 Return-Path: <too@guru-group.fi>\r
2 X-Original-To: notmuch@notmuchmail.org\r
3 Delivered-To: notmuch@notmuchmail.org\r
4 Received: from localhost (localhost [127.0.0.1])\r
5         by olra.theworths.org (Postfix) with ESMTP id 40A10431FBD\r
6         for <notmuch@notmuchmail.org>; Sat,  1 Sep 2012 02:32:14 -0700 (PDT)\r
7 X-Virus-Scanned: Debian amavisd-new at olra.theworths.org\r
8 X-Spam-Flag: NO\r
9 X-Spam-Score: 0\r
10 X-Spam-Level: \r
11 X-Spam-Status: No, score=0 tagged_above=-999 required=5 tests=[none]\r
12         autolearn=disabled\r
13 Received: from olra.theworths.org ([127.0.0.1])\r
14         by localhost (olra.theworths.org [127.0.0.1]) (amavisd-new, port 10024)\r
15         with ESMTP id roBYaiukSLPb for <notmuch@notmuchmail.org>;\r
16         Sat,  1 Sep 2012 02:32:13 -0700 (PDT)\r
17 Received: from guru.guru-group.fi (guru.guru-group.fi [46.183.73.34])\r
18         by olra.theworths.org (Postfix) with ESMTP id BA93F431FAF\r
19         for <notmuch@notmuchmail.org>; Sat,  1 Sep 2012 02:32:12 -0700 (PDT)\r
20 Received: by guru.guru-group.fi (Postfix, from userid 501)\r
21         id 476FB100635; Sat,  1 Sep 2012 12:32:19 +0300 (EEST)\r
22 From: Tomi Ollila <tomi.ollila@iki.fi>\r
23 To: notmuch@notmuchmail.org\r
24 Subject: [PATCH V2 1/2] devel: add release-checks.sh\r
25 Date: Sat,  1 Sep 2012 12:32:07 +0300\r
26 Message-Id: <1346491928-2356-1-git-send-email-tomi.ollila@iki.fi>\r
27 X-Mailer: git-send-email 1.7.1\r
28 Cc: Tomi Ollila <tomi.ollila@iki.fi>\r
29 X-BeenThere: notmuch@notmuchmail.org\r
30 X-Mailman-Version: 2.1.13\r
31 Precedence: list\r
32 List-Id: "Use and development of the notmuch mail system."\r
33         <notmuch.notmuchmail.org>\r
34 List-Unsubscribe: <http://notmuchmail.org/mailman/options/notmuch>,\r
35         <mailto:notmuch-request@notmuchmail.org?subject=unsubscribe>\r
36 List-Archive: <http://notmuchmail.org/pipermail/notmuch>\r
37 List-Post: <mailto:notmuch@notmuchmail.org>\r
38 List-Help: <mailto:notmuch-request@notmuchmail.org?subject=help>\r
39 List-Subscribe: <http://notmuchmail.org/mailman/listinfo/notmuch>,\r
40         <mailto:notmuch-request@notmuchmail.org?subject=subscribe>\r
41 X-List-Received-Date: Sat, 01 Sep 2012 09:32:14 -0000\r
42 \r
43 Currently Makefile.local contains some machine executable release\r
44 checking functionality. This is unnecessarily complex way to do it:\r
45 \r
46 Multiline script functionality is hard to embed -- from Makefile point\r
47 of view there is just one line split using backslashes and every line\r
48 ends with ';'. It is hard to maintain such "script" when it gets longer.\r
49 \r
50 The embedded script does not fail as robust as separate script; set -eu\r
51 could be added to get same level of robustness -- but the provided\r
52 Bourne Again Shell (bash) script exceeds this with 'set -o pipefail',\r
53 making the script to fail when any of the commands in pipeline fails\r
54 (and not just the last one).\r
55 \r
56 Checking for release is done very seldom compared to all other use;\r
57 The whole Makefile.local gets simpler and easier to grasp when most\r
58 release checking targets are removed.\r
59 \r
60 When release checking is done, the steps are executed sequentially;\r
61 nothing is allowed to be skipped due to some satisfied dependency.\r
62 ---\r
63 \r
64 This patch obsoletes (now moreinfo) patch in\r
65 \r
66 id:"1344456107-19308-1-git-send-email-tomi.ollila@iki.fi"\r
67 \r
68  devel/release-checks.sh | 211 ++++++++++++++++++++++++++++++++++++++++++++++++\r
69  1 file changed, 211 insertions(+)\r
70  create mode 100755 devel/release-checks.sh\r
71 \r
72 diff --git a/devel/release-checks.sh b/devel/release-checks.sh\r
73 new file mode 100755\r
74 index 0000000..7dadefa\r
75 --- /dev/null\r
76 +++ b/devel/release-checks.sh\r
77 @@ -0,0 +1,211 @@\r
78 +#!/usr/bin/env bash\r
79 +\r
80 +set -eu\r
81 +#set -x # or enter bash -x ... on command line\r
82 +\r
83 +if [ x"${BASH_VERSION-}" = x ]\r
84 +then   echo\r
85 +       echo "Please execute this script using 'bash' interpreter"\r
86 +       echo\r
87 +       exit 1\r
88 +fi\r
89 +\r
90 +set -o pipefail # bash feature\r
91 +\r
92 +# Avoid locale-specific differences in output of executed commands\r
93 +LANG=C LC_ALL=C; export LANG LC_ALL\r
94 +\r
95 +readonly DEFAULT_IFS="$IFS"\r
96 +\r
97 +readonly PV_FILE='bindings/python/notmuch/version.py'\r
98 +\r
99 +# Using array here turned out to be unnecessarily complicated\r
100 +emsgs=''\r
101 +append_emsg ()\r
102 +{\r
103 +       emsgs="${emsgs:+$emsgs\n}  $1"\r
104 +}\r
105 +\r
106 +for f in ./version debian/changelog NEWS "$PV_FILE"\r
107 +do\r
108 +       test -f $f || { append_emsg "File '$f' is missing"; continue; }\r
109 +       test -r $f || { append_emsg "File '$f' is unreadable"; continue; }\r
110 +       test -s $f ||   append_emsg "File '$f' is empty"\r
111 +done\r
112 +\r
113 +if [ -n "$emsgs" ]\r
114 +then\r
115 +       echo 'Release files problems; fix these and try again:'\r
116 +       echo -e "$emsgs"\r
117 +       exit 1\r
118 +fi\r
119 +\r
120 +if read VERSION\r
121 +then\r
122 +       if read rest\r
123 +       then    echo "'version' file contains more than one line"\r
124 +               exit 1\r
125 +       fi\r
126 +else\r
127 +       echo "Reading './version' file failed (suprisingly!)"\r
128 +       exit 1\r
129 +fi < ./version\r
130 +\r
131 +readonly VERSION\r
132 +\r
133 +verfail ()\r
134 +{\r
135 +       echo No.\r
136 +       echo "$@"\r
137 +       echo "Please follow the instructions in RELEASING to choose a version"\r
138 +       exit 1\r
139 +}\r
140 +\r
141 +echo -n "Checking that '$VERSION' is good with digits and periods... "\r
142 +if [ -z "${VERSION//[0123456789.]/}" ] # bash feature\r
143 +then\r
144 +       case $VERSION in\r
145 +               .*)     verfail "'$VERSION' begins with a period" ;;\r
146 +               *.)     verfail "'$VERSION' ends with a period" ;;\r
147 +               *..*)   verfail "'$VERSION' contains two consecutive periods" ;;\r
148 +               *.*)    echo Yes. ;;\r
149 +               *)      verfail "'$VERSION' is a single number" ;;\r
150 +       esac\r
151 +else\r
152 +       verfail "'$VERSION' contains other characters than digits and periods"\r
153 +fi\r
154 +\r
155 +\r
156 +# In the rest of this file, tests collect list of errors to be fixed\r
157 +\r
158 +echo -n "Checking that this is Debian package for notmuch... "\r
159 +read deb_notmuch deb_version rest < debian/changelog\r
160 +if [ "$deb_notmuch" = 'notmuch' ]\r
161 +then\r
162 +       echo Yes.\r
163 +else\r
164 +       echo No.\r
165 +       append_emsg "Package name '$deb_notmuch' is not 'notmuch' in debian/changelog"\r
166 +fi\r
167 +\r
168 +echo -n "Checking that Debian package version is $VERSION-1... "\r
169 +\r
170 +if [ "$deb_version" = "($VERSION-1)" ]\r
171 +then\r
172 +       echo Yes.\r
173 +else\r
174 +       echo No.\r
175 +       append_emsg "Version '$deb_version' is not '($VERSION-1)' in debian/changelog"\r
176 +fi\r
177 +\r
178 +echo -n "Checking that python bindings version is $VERSION... "\r
179 +py_version=`python -c "execfile('$PV_FILE'); print __VERSION__"`\r
180 +if [ "$py_version" = "$VERSION" ]\r
181 +then\r
182 +       echo Yes.\r
183 +else\r
184 +       echo No.\r
185 +       append_emsg "Version '$py_version' is not '$VERSION' in $PV_FILE"\r
186 +fi\r
187 +\r
188 +echo -n "Checking that this is Notmuch NEWS... "\r
189 +read news_notmuch news_version news_date < NEWS\r
190 +if [ "$news_notmuch" = "Notmuch" ]\r
191 +then\r
192 +       echo Yes.\r
193 +else\r
194 +       echo No.\r
195 +       append_emsg "First word '$news_notmuch' is not 'Notmuch' in NEWS file"\r
196 +fi\r
197 +\r
198 +echo -n "Checking that NEWS version is $VERSION... "\r
199 +if [ "$news_version" = "$VERSION" ]\r
200 +then\r
201 +       echo Yes.\r
202 +else\r
203 +       echo No.\r
204 +       append_emsg "Version '$news_version' in NEWS file is not '$VERSION'"\r
205 +fi\r
206 +\r
207 +#eval `date '+year=%Y mon=%m day=%d'`\r
208 +today0utc=`date --date=0Z +%s` # gnu date feature\r
209 +\r
210 +echo -n "Checking that NEWS date is right... "\r
211 +case $news_date in\r
212 + '('[2-9][0-9][0-9][0-9]-[01][0-9]-[0123][0-9]')')\r
213 +       newsdate0utc=`nd=${news_date#\\(}; date --date="${nd%)} 0Z" +%s`\r
214 +       ddiff=$((newsdate0utc - today0utc))\r
215 +       if [ $ddiff -lt -86400 ] # since beginning of yesterday...\r
216 +       then\r
217 +               echo No.\r
218 +               append_emsg "Date $news_date in NEWS file is too much in the past"\r
219 +       elif [ $ddiff -gt 172800 ] # up to end of tomorrow...\r
220 +       then\r
221 +               echo No.\r
222 +               append_emsg "Date $news_date in NEWS file is too much in the future"\r
223 +       else\r
224 +               echo Yes.\r
225 +       fi ;;\r
226 + *)\r
227 +       echo No.\r
228 +       append_emsg "Date '$news_date' in NEWS file is not in format (yyyy-mm-dd)"\r
229 +esac\r
230 +\r
231 +readonly DATE=${news_date//[()]/} # bash feature\r
232 +manthdata ()\r
233 +{\r
234 +       set x $*\r
235 +       if [ $# != 7 ]\r
236 +       then\r
237 +               append_emsg "'$mp' has too many '.TH' lines"\r
238 +               man_mismatch=1\r
239 +       fi\r
240 +       man_date=${5-} man_version=${7-}\r
241 +}\r
242 +\r
243 +echo -n "Checking that manual page dates and versions are $DATE and $VERSION... "\r
244 +manfiles=`find man -type f | sort`\r
245 +man_pages_ok=Yes\r
246 +for mp in $manfiles\r
247 +do\r
248 +       case $mp in *.[0-9]) ;; # fall below this 'case ... esac'\r
249 +               */Makefile.local | */Makefile ) continue ;;\r
250 +               */.gitignore)   continue ;;\r
251 +               *.bak)          continue ;;\r
252 +\r
253 +               *)      append_emsg "'$mp': extra file"\r
254 +                       man_pages_ok=No\r
255 +                       continue\r
256 +       esac\r
257 +       manthdata `sed -n '/^[.]TH NOTMUCH/ { y/"/ /; p; }' "$mp"`\r
258 +       if [ "$man_version" != "$VERSION" ]\r
259 +       then    append_emsg "Version '$man_version' is not '$VERSION' in $mp"\r
260 +               mman_pages_ok=No\r
261 +       fi\r
262 +       if [ "$man_date" != "$DATE" ]\r
263 +       then    append_emsg "DATE '$man_date' is not '$DATE' in $mp"\r
264 +               man_pages_ok=No\r
265 +       fi\r
266 +done\r
267 +echo $man_pages_ok.\r
268 +\r
269 +if [ -n "$emsgs" ]\r
270 +then\r
271 +       echo\r
272 +       echo 'Release check failed; check these issues:'\r
273 +       echo -e "$emsgs"\r
274 +       exit 1\r
275 +fi\r
276 +\r
277 +echo 'All checks this script executed completed successfully.'\r
278 +echo 'Make sure that everything else mentioned in RELEASING'\r
279 +echo 'file is in order, too.'\r
280 +\r
281 +exit 0\r
282 +\r
283 +# Local variables:\r
284 +# mode: shell-script\r
285 +# sh-basic-offset: 8\r
286 +# tab-width: 8\r
287 +# End:\r
288 +# vi: set sw=8 ts=8\r
289 --\r
290 1.7.11.4\r